using System.Data

0 downloads 0 Views 573KB Size Report
Linq; using System.Web; using System.Data; using System.Data.SqlClient; using System.Text. ...... Convert.ToString("data:image/png;base64. ,") + base64String;. } catch. { return null;. } ..... var thumbnailImg = new Bitmap(newWidth,. newHeight);.
Using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data; using System.Data.SqlClient; using System.Text.RegularExpressions; /// /// Summary description for database /// public class database { public database() { } SqlConnection vCon = new SqlConnection(@"Data Source=DELL-3000;Initial Catalog=VMCDB;Integrated Security=True"); public bool isValidEmail(string inputEmail) { string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" + @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" + @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"; Regex re = new Regex(strRegex); if (re.IsMatch(inputEmail)) return (true); else return (false); } public string ValidateContact(string ContactNo) { string userInput = ContactNo; Regex regexPhoneNumber = new Regex(@"^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$"); if (regexPhoneNumber.IsMatch(userInput)) { return regexPhoneNumber.Replace(userInput, "($1) $2-$3"); } else { return "0"; } } //-----------Function [dbo].[spChangeUserPwd] Starts ---------public String spChangeUserPwd(Decimal UserId, String Pwd, String NewPwd) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spChangeUserPwd]", vCon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@UserId", UserId); cmd.Parameters.AddWithValue("@Pwd", Pwd); cmd.Parameters.AddWithValue("@NewPwd", NewPwd); vCon.Open(); Object t = cmd.ExecuteScalar(); vCon.Close(); return Convert.ToString(t); }//-----------Function [dbo].[spChangeUserPwd] Ends ---------//-----------Function [dbo].[spFetchContenderImage] Starts ---------public DataTable spFetchContenderImage(Decimal ID) {

System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spFetchContenderImage]", vCon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ID", ID); vCon.Open(); DataTable dt = new DataTable(); dt.Load(cmd.ExecuteReader()); vCon.Close(); return dt; }//-----------Function [dbo].[spFetchContenderImage] Ends ---------//-----------Function [dbo].[spFtechResultByVoteID] Starts ---------public DataTable spFtechResultByVoteID(Decimal VoteId) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spFtechResultByVoteID]", vCon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@VoteId", VoteId); vCon.Open(); DataTable dt = new DataTable(); dt.Load(cmd.ExecuteReader()); vCon.Close(); return dt; }//-----------Function [dbo].[spFtechResultByVoteID] Ends ----------

//-----------Function [dbo].[spFetchVoteListForResult] Starts ---------public DataTable spFetchVoteListForResult() { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spFetchVoteListForResult]", vCon); cmd.CommandType = CommandType.StoredProcedure; vCon.Open(); DataTable dt = new DataTable(); dt.Load(cmd.ExecuteReader()); vCon.Close(); return dt; }//-----------Function [dbo].[spFetchVoteListForResult] Ends ----------

//-----------Function [dbo].[spFetchVotingHistory] Starts ---------public DataTable spFetchVotingHistory(Decimal UserId) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spFetchVotingHistory]", vCon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@UserId", UserId); vCon.Open(); DataTable dt = new DataTable(); dt.Load(cmd.ExecuteReader()); vCon.Close(); return dt; }//-----------Function [dbo].[spFetchVotingHistory] Ends ----------

//-----------Function [dbo].[spInsertResultMaster] Starts ---------public String spInsertResultMaster(Decimal UserId, Decimal VotingId, Decimal ContenderId, String Answer) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spInsertResultMaster]", vCon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@UserId", UserId); cmd.Parameters.AddWithValue("@VotingId", VotingId);

cmd.Parameters.AddWithValue("@ContenderId", ContenderId); cmd.Parameters.AddWithValue("@Answer", Answer); vCon.Open(); Object t = cmd.ExecuteScalar(); vCon.Close(); return Convert.ToString(t); }//-----------Function [dbo].[spInsertResultMaster] Ends ----------

//-----------Function [dbo].[spApproveVotingRequest] Starts ---------public void spApproveVotingRequest(Decimal id, Boolean Status) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spApproveVotingRequest]", vCon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@id", id); cmd.Parameters.AddWithValue("@Status", Status); vCon.Open(); cmd.ExecuteNonQuery(); vCon.Close(); }//-----------Function [dbo].[spApproveVotingRequest] Ends ----------

//-----------Function [dbo].[spFetchUpcomingVoteListForAdmin] Starts ---------public DataTable spFetchUpcomingVoteListForAdmin() { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spFetchUpcomingVoteListForAdmin]", vCon); cmd.CommandType = CommandType.StoredProcedure; vCon.Open(); DataTable dt = new DataTable(); dt.Load(cmd.ExecuteReader()); vCon.Close(); return dt; }//-----------Function [dbo].[spFetchUpcomingVoteListForAdmin] Ends ----------

//-----------Function [dbo].[spFetchUser] Starts ---------public DataTable spFetchUser(Boolean IsActive) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spFetchUser]", vCon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@IsActive", IsActive); vCon.Open(); DataTable dt = new DataTable(); dt.Load(cmd.ExecuteReader()); vCon.Close(); return dt; }//-----------Function [dbo].[spFetchUser] Ends ---------//-----------Function [dbo].[spUpdateUserMaster] Starts ---------public void spUpdateUserMaster(Decimal id, Boolean IsActive) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spUpdateUserMaster]", vCon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@id", id); cmd.Parameters.AddWithValue("@IsActive", IsActive); vCon.Open();

cmd.ExecuteNonQuery(); vCon.Close(); }//-----------Function [dbo].[spUpdateUserMaster] Ends ----------

//-----------Function [dbo].[spValidateUser] Starts ---------public DataTable spValidateUser(String Email, String Pwd) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spValidateUser]", vCon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Email", Email); cmd.Parameters.AddWithValue("@Pwd", Pwd); vCon.Open(); DataTable dt = new DataTable(); dt.Load(cmd.ExecuteReader()); vCon.Close(); return dt; }//-----------Function [dbo].[spValidateUser] Ends ---------//-----------Function [dbo].[spInsertContenderMaster] Starts ---------public void spInsertContenderMaster(Decimal VoteListId, String Name, String Description, Byte[] Img) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spInsertContenderMaster]", vCon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@VoteListId", VoteListId); cmd.Parameters.AddWithValue("@Name", Name); cmd.Parameters.AddWithValue("@Description", Description); if(@Img==null) cmd.Parameters.AddWithValue("@Img", DBNull.Value); else cmd.Parameters.AddWithValue("@Img", Img); vCon.Open(); cmd.ExecuteNonQuery(); vCon.Close(); }//-----------Function [dbo].[spInsertContenderMaster] Ends ---------//-----------Function [dbo].[spFetchContenderList] Starts ---------public DataTable spFetchContenderList(Decimal id, Decimal VoteListId) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spFetchContenderList]", vCon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@id", id); cmd.Parameters.AddWithValue("@VoteListId", VoteListId); vCon.Open(); DataTable dt = new DataTable(); dt.Load(cmd.ExecuteReader()); vCon.Close(); return dt; }//-----------Function [dbo].[spFetchContenderList] Ends ---------//-----------Function [dbo].[spUpdateVotingListMaster] Starts ---------public void spUpdateVotingListMaster(Decimal id, Boolean Status) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spUpdateVotingListMaster]", vCon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@id", id); cmd.Parameters.AddWithValue("@Status", Status); vCon.Open();

cmd.ExecuteNonQuery(); vCon.Close(); }//-----------Function [dbo].[spUpdateVotingListMaster] Ends ----------

//-----------Function [dbo].[spFetchCategoriesAndListCount] Starts ---------public DataTable spFetchCategoriesAndListCount() { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spFetchCategoriesAndListCount]", vCon); cmd.CommandType = CommandType.StoredProcedure; vCon.Open(); DataTable dt = new DataTable(); dt.Load(cmd.ExecuteReader()); vCon.Close(); return dt; }//-----------Function [dbo].[spFetchCategoriesAndListCount] Ends ---------//-----------Function [dbo].[spFetchVotingListMasterForVote] Starts ---------public DataTable spFetchVotingListMasterForVote(decimal CatId,string Mode) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spFetchVotingListMasterForVote]", vCon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@CatId", CatId); cmd.Parameters.AddWithValue("@Mode", Mode); vCon.Open(); DataTable dt = new DataTable(); dt.Load(cmd.ExecuteReader()); vCon.Close(); return dt; }//-----------Function [dbo].[spFetchVotingListMasterForVote] Ends ----------

//-----------Function [dbo].[spFetchVotingListMaster] Starts ---------public DataTable spFetchVotingListMaster(Decimal id, decimal UserID, bool Status) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spFetchVotingListMaster]", vCon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@id", id); cmd.Parameters.AddWithValue("@UserID", UserID); cmd.Parameters.AddWithValue("@Status", Status); vCon.Open(); DataTable dt = new DataTable(); dt.Load(cmd.ExecuteReader()); vCon.Close(); return dt; }//-----------Function [dbo].[spFetchVotingListMaster] Ends ----------

//-----------Function [dbo].[spInsertVotingListMaster] Starts ---------public void spInsertVotingListMaster(Decimal UserId, Decimal CatId, String Title, String Detail, DateTime EndDate, DateTime StartDate) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spInsertVotingListMaster]", vCon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@UserId", UserId); cmd.Parameters.AddWithValue("@CatId", CatId); cmd.Parameters.AddWithValue("@Title", Title); cmd.Parameters.AddWithValue("@Detail", Detail); cmd.Parameters.AddWithValue("@EndDate", EndDate);

cmd.Parameters.AddWithValue("@StartDate", StartDate); vCon.Open(); cmd.ExecuteNonQuery(); vCon.Close(); }//-----------Function [dbo].[spInsertVotingListMaster] Ends ---------//-----------Function [dbo].[spFetchContender] Starts ---------public DataTable spFetchContender(Decimal VoteListId) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spFetchContender]", vCon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@VoteListId", VoteListId); vCon.Open(); DataTable dt = new DataTable(); dt.Load(cmd.ExecuteReader()); vCon.Close(); return dt; }//-----------Function [dbo].[spFetchContender] Ends ---------//-----------Function [dbo].[spFetchVotingListMasterById] Starts ---------public DataTable spFetchVotingListMasterById(Decimal id) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spFetchVotingListMasterById]", vCon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@id", id); vCon.Open(); DataTable dt = new DataTable(); dt.Load(cmd.ExecuteReader()); vCon.Close(); return dt; }//-----------Function [dbo].[spFetchVotingListMasterById] Ends ---------//-----------Function [dbo].[spInsertCategoryMaster] Starts ---------public String spInsertCategoryMaster (String CategoryName ) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spInsertCategoryMaster]", vCon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@CategoryName",CategoryName); vCon.Open(); Object t=cmd.ExecuteScalar(); vCon.Close(); return Convert.ToString(t); }//-----------Function [dbo].[spInsertCategoryMaster] Ends ---------//-----------Function [dbo].[spInsertUserMaster] Starts ---------public String spInsertUserMaster(String Name, String Email, String Contact, String Pwd, String Address) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spInsertUserMaster]", vCon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Name", Name); cmd.Parameters.AddWithValue("@Email", Email); cmd.Parameters.AddWithValue("@Contact", Contact); cmd.Parameters.AddWithValue("@Pwd", Pwd); cmd.Parameters.AddWithValue("@Address", Address); vCon.Open(); Object t = cmd.ExecuteScalar(); vCon.Close(); return Convert.ToString(t); }//-----------Function [dbo].[spInsertUserMaster] Ends ----------

//-----------Function [dbo].[spFetchCategory] Starts ---------public DataTable spFetchCategory() { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spFetchCategory]", vCon); cmd.CommandType = CommandType.StoredProcedure; vCon.Open(); DataTable dt = new DataTable(); dt.Load(cmd.ExecuteReader()); vCon.Close(); return dt; }//-----------Function [dbo].[spFetchCategory] Ends ---------//-----------Function [dbo].[spFetchCategoryById] Starts ---------public DataTable spFetchCategoryById(Decimal CatID) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spFetchCategoryById]", vCon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@CatID", CatID); vCon.Open(); DataTable dt = new DataTable(); dt.Load(cmd.ExecuteReader()); vCon.Close(); return dt; }//-----------Function [dbo].[spFetchCategoryById] Ends ---------//-----------Function [dbo].[spUpdateCategoryMaster] Starts ---------public String spUpdateCategoryMaster(Decimal id, String CategoryName, Boolean IsActive) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("[dbo].[spUpdateCategoryMaster]", vCon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@id", id); cmd.Parameters.AddWithValue("@CategoryName", CategoryName); cmd.Parameters.AddWithValue("@IsActive", IsActive); vCon.Open(); Object t = cmd.ExecuteScalar(); vCon.Close(); return Convert.ToString(t); }//-----------Function [dbo].[spUpdateCategoryMaster] Ends ----------

}

The Source code VMC - Vote My Choice



addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } jQuery(document).ready(function($) { $(".scroll").click(function(event){ event.preventDefault(); $('html,body').animate({scrollTop:$(thi s.hash).offset().top},1200); }); }); .navbar { border-radius:0px; margin-bottom:0px; border-bottom:2px solid #222222; font-weight:bold; } .label { border-radius:0px; } $(document).ready(function() { /* var defaults = { containerID: 'toTop', // fading element id containerHoverID: 'toTopHover', // fading element hover id scrollSpeed: 1200, easingType: 'linear' }; */ $().UItoTop({ easingType: 'easeOutQuart' }); });


The Code behind file

using using using using using using

System; System.Collections.Generic; System.Linq; System.Web; System.Web.UI; System.Web.UI.WebControls;

public partial class MainMasterPage : System.Web.UI.MasterPage { protected void Page_Load(object sender, EventArgs e) {

if (Session["UserID"] == null) { pnlNavGuest.Visible = true; pnlNavUser.Visible = false; } else { pnlNavGuest.Visible = false; pnlNavUser.Visible = true; } // loadNav(4); } public string navItem1, navItem3, navItem4, navItem5;

navItem2,

public void loadNav(int i ) { switch(i) { case 1: navItem1 = "active"; break; case 2: navItem2 = "active"; break; case 3: navItem3 = "active"; break; case 4: navItem4 = "active"; break; case 5: navItem5 = "active"; break; } } protected void LinkButton1_Click(object sender, EventArgs e) { Session.Clear(); Session.Abandon(); Response.Redirect("LogIn.aspx"); } }

1.2.1. ABOUT PAGE The about Page contains a message about the voting system, the motif behind its creation, aims and objectives and slogan.

US



ABOUT

VMC is an advanced multipurpose online voting platform which allows its prestigious users and clients to create their voting desires and by allowing their fans, users, friends and families to vote from the different categories available at their disposal.


VMC indeed gives users the autonomy to create different voting categories which comprises of Sports awards, Films or Movies awards, general elections, fashions awards, Oscar awards, Bollywood awards School elections, Union elections and so on and so forth.


VMC is user-friendly as it has a very simple interface with high definition backgrounds that catches the eyes and attention of its users, it is designed using the best design algorithms which makes it fasters and well optimized.




Our major goal is to make our users cheerful while voting their heart desires and to ensure that their votes and choices are safe-guarded and secured from modification or alteration by hackers or even from our end.


OUR TARGET AUDIENCE

VMC does not segregate any one or any gender. Our platform belongs to everyone and for all the people, people from different background different ethnicity different nations. We welcome you all.


OUR SLOGAN

Vote My Choice, Vote My Desires, Vote My favorites…







GOALS

1.2.2. CATEGORIES PAGE The categories page is the page which contains the lists of all created categories in which the contenders’ lists is situated in. See the code. The Design Code

.panel ,.panel-heading , .well, .panel-body { border-radius:0px; }






Active Voting Lists :
Upcoming Voting Lists :











The Code Behind file using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; public partial class Categories : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Master.loadNav(1); loadVoteListCategory(); }

database db = new database(); void loadVoteListCategory() { DataTable vDtCategory = db.spFetchCategoriesAndListCount();

RepeaterCategoryGrid.DataSource = vDtCategory; RepeaterCategoryGrid.DataBind(); } int countRow = 1; protected void RepeaterCategoryGrid_ItemDataBound(obje ct sender, RepeaterItemEventArgs e)

{ if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { DataRowView drv = e.Item.DataItem as DataRowView; if (countRow % 4 == 0) {

Panel pnlClearFix = (Panel)e.Item.FindControl("pnlClearFix" ); pnlClearFix.Visible = true; } countRow = countRow + 1; } } }

1.2.3. CHANGE PASSWORD PAGE The change password page is the page that handles all the request for changing password in case the user feels like changing the password. Here is the code. The Design Code table { width:100%; } tr , td { margin-bottom:10px; padding-bottom:10px; vertical-align:top; }




Change password of your account


Cuurent Password
New Password
Re-enter New Password


Change Password




The Code Behind file using using using using using using

System; System.Collections.Generic; System.Linq; System.Web; System.Web.UI; System.Web.UI.WebControls;

public partial class ChangePwd : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Master.loadNav(5); } database db = new database(); protected void btnChangePwd_Click(object sender, EventArgs e) { if (txtOldPwd.Text.Trim().Equals(string.Em pty)) { ScriptManager.RegisterStartupScript(thi s.Page, this.GetType(), "script", "alert('Please Enter Old Password...');", true); txtOldPwd.Focus(); } else if (txtNewPwd.Text.Trim().Equals(string.Em pty)) { ScriptManager.RegisterStartupScript(thi s.Page, this.GetType(), "script", "alert('Please Enter New Password...');", true); txtNewPwd.Focus(); } else if (txtNewPwd.Text.Trim().Length < 4) { ScriptManager.RegisterStartupScript(thi s.Page, this.GetType(), "script", "alert('Password Should Be Greater Than Or Equal To 4 Characters Long In Length...');", true);

txtNewPwd.Focus(); } else if (txtNewConfirmPwd.Text.Trim().Equals(st ring.Empty)) { ScriptManager.RegisterStartupScript(thi s.Page, this.GetType(), "script", "alert('Please Enter New Confirm Password...');", true); txtNewConfirmPwd.Focus(); } else if (!txtNewConfirmPwd.Text.Trim().Equals(t xtNewPwd.Text.Trim())) { ScriptManager.RegisterStartupScript(thi s.Page, this.GetType(), "script", "alert('Password Does Not Match...');", true); txtNewConfirmPwd.Focus(); } else { string str = db.spChangeUserPwd(Convert.ToDecimal(Se ssion["UserId"]), txtOldPwd.Text, txtNewPwd.Text); if (str.Equals("0")) { ScriptManager.RegisterStartupScript(thi s.Page, this.GetType(), "script", "alert('Invalid Password ...');", true); } else { Response.Redirect("LogIn.aspx"); } } } }

1.2.6. DEFAULT PAGE The default page is considered to be the main user page, as it contains all the options which allow the users to navigate through the various pages of the system. Here is the code.



1.2.7. LOGIN PAGE The login page serves as the entry door of the system, as it provides the users with an interface which allows them to supply their login credential in order to have full access to the system. The Design Code




User Login









The Code Behind file using using using using using using

System; System.Collections.Generic; System.Linq; System.Web; System.Web.UI; System.Web.UI.WebControls;

public partial class LogIn : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnLogin_Click(object sender, EventArgs e) { if(string.IsNullOrEmpty(txtUserId.Text. Trim())) { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Please Enter Email ID.');", true); txtUserId.Focus(); } else if (string.IsNullOrEmpty(txtPwd.Text.Trim( ))) { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Please Enter Password.');", true);

txtPwd.Focus(); } else { System.Data.DataTable dt=new database().spValidateUser(txtUserId.Tex t.Trim(),txtPwd.Text.Trim()); if (dt.Rows[0][0].ToString ().Equals("0")) { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Invalid Email Id / Password.');", true); txtPwd.Focus(); } else { Session["UserID"] = dt.Rows[0][0].ToString (); Session["UserName"] = dt.Rows[0][1].ToString (); Session["UserEmail"] = txtUserId.Text.Trim();

Response.Redirect("Default.aspx"); } } } }

1.2.8. RESULT PAGE The result page is that page which displays all the election results which were collated after the election is over. It displays both the name, picture, number of votes and the category in which the contender(s) falls. Here is the code. The Design code








Name Image Number Of Votes




The code behind file using using using using using using using

System; System.Collections.Generic; System.IO; System.Linq; System.Web; System.Web.UI; System.Web.UI.WebControls;

public partial class Result : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (Session["UserId"] == null) { Response.Redirect("Login.aspx"); } if (Request["VotingListId"] == null || string.IsNullOrEmpty(Request["VotingLis tId"])) { Response.Redirect("Categories.aspx"); } LoadData(); } public string ByteToImage(byte[] image) {

try { Stream fs = new MemoryStream(image); System.IO.BinaryReader br = new System.IO.BinaryReader(fs); Byte[] bytes = br.ReadBytes(Convert.ToInt32(fs.Length) ); string base64String = Convert.ToBase64String(bytes, 0, bytes.Length); return Convert.ToString("data:image/png;base64 ,") + base64String; } catch { return null; } } protected database db = new database(); void LoadData() { System.Data.DataTable dt System.Data.DataTable();

=

new

System.Data.DataTable vDt=db.spFtechResultByVoteID(Convert.To Decimal(Request["VotingListId"])); dt.Columns.Add("Name"); dt.Columns.Add("Img"); dt.Columns.Add("TotalVote"); for (int i = 0; i < vDt.Rows.Count; i++) { dt.Rows.Add(vDt.Rows[i]["Name"].ToStrin g(),

ByteToImage((byte[])db.spFetchContender Image(Convert.ToDecimal(vDt.Rows[i]["id "].ToString ())).Rows[0][0]), vDt.Rows[i]["TotalVote"].ToString()); } RepeaterActiveList.DataSource = dt; RepeaterActiveList.DataBind(); } }

5.2.10. SIGN UP PAGE The signup page is composed of a number of Web controls and validation controls, which are used to take values from the user in preparation for allowing access to the platform. It has textboxes like Name, email, password, address and a submit button. The Source Code




User Signup




Name

Phone

Email

Password



Confirm Password

Address









Alredy Registered ? Log In Now







The Code behind file using using using using using using

System; System.Collections.Generic; System.Linq; System.Web; System.Web.UI; System.Web.UI.WebControls;

public partial class SignUp : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } database db = new database(); protected void btnSignup_Click(object sender, EventArgs e) { if(string.IsNullOrEmpty(txtName.Text.Tr im())) { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Please Enter Name.');", true); txtName.Focus(); } else if (string.IsNullOrEmpty(txtEmail.Text.Tri m())) { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Please Enter Email.');", true); txtEmail.Focus(); }

else if (!db.isValidEmail(txtEmail.Text.Trim()) ) { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Please Enter A Valid Email.');", true); txtEmail.Focus(); } else if (string.IsNullOrEmpty(txtPhone.Text.Tri m())) { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Please Enter Phone.');", true); txtPhone.Focus(); } else if (db.ValidateContact(txtPhone.Text.Trim( )).Equals("0")) { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Please Enter A Valid 10 Digit Contact Number.');", true); txtPhone.Focus(); } else if (string.IsNullOrEmpty(txtPWD.Text.Trim( ))) { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Please Enter Password.');", true); txtPWD.Focus(); }

else if (txtPWD.Text.Trim().Length

OnClick="btnAddContender_Click"














The code behind file using using using using using using using using using using

System; System.Collections.Generic; System.Linq; System.Web; System.Web.UI; System.Web.UI.WebControls; System.Data; System.IO; System.Drawing; System.Drawing.Drawing2D;

public partial class UserNewVotelist : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Master.loadNav(3); if(!IsPostBack) { loadCategory(); loadVotingList(); CalStartDate.SelectedDate = DateTime.Now.Date;

}

} DataTable vDt = new DataTable(); void loadCategory() { drpCategory.DataSource = db.spFetchCategory(); drpCategory.DataTextField = "CategoryName"; drpCategory.DataValueField = "id"; drpCategory.DataBind(); drpCategory.Items.Insert(0, "-- Select Category --"); drpCategory.SelectedIndex = 0; } void loadVotingList() { drpVotingList.DataSource = db.spFetchVotingListMaster(0,Convert.To Decimal(Session["UserID"]),false); drpVotingList.DataTextField = "Title"; drpVotingList.DataValueField = "id"; drpVotingList.DataBind(); drpVotingList.Items.Insert(0, "-Select Voting List --");

drpVotingList.SelectedIndex = 0; } void LoadContender() { vDt.Columns.Add("Name"); vDt.Columns.Add("Description"); vDt.Columns.Add("Image"); DataTable dt = db.spFetchContenderList(0, Convert.ToDecimal(drpVotingList.Selecte dItem.Value)); for (int i = 0; i < dt.Rows.Count; i++) { vDt.Rows.Add(dt.Rows[i]["Name"].ToStrin g(), dt.Rows[i]["Description"].ToString(),By teToImage((byte[]) dt.Rows[i]["Img"])); } RepeaterContender.DataSource = vDt; RepeaterContender.DataBind(); } public byte[] imageToByteArray(System.Drawing.Image imageIn) { MemoryStream ms = new MemoryStream(); imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Gif) ; return ms.ToArray(); } public string ByteToImage(byte[] image) { try { Stream fs = new MemoryStream(image); System.IO.BinaryReader br = new System.IO.BinaryReader(fs); Byte[] bytes = br.ReadBytes(Convert.ToInt32(fs.Length) ); string base64String = Convert.ToBase64String(bytes, 0, bytes.Length); return Convert.ToString("data:image/png;base64 ,") + base64String; } catch { return null; } } public void GenerateThumbnails(double scaleFactor, Stream sourcePath, string targetPath) { using (var image = System.Drawing.Image.FromStream(sourceP ath)) {

var newWidth = (int)(image.Width * scaleFactor); var newHeight = (int)(image.Height * scaleFactor); var thumbnailImg = new Bitmap(newWidth, newHeight); var thumbGraph = Graphics.FromImage(thumbnailImg); thumbGraph.CompositingQuality = CompositingQuality.HighQuality; thumbGraph.SmoothingMode = SmoothingMode.HighQuality; thumbGraph.InterpolationMode = InterpolationMode.HighQualityBicubic; var imageRectangle = new Rectangle(0, 0, newWidth, newHeight); thumbGraph.DrawImage(image, imageRectangle); thumbnailImg.Save(targetPath, image.RawFormat); } } byte[] GenerateByte(FileUpload FileUpload1) { byte[] img; string filename = Path.GetFileName(FileUpload1.PostedFile .FileName); Random r = new Random(); string targetPath = "~/images/" + r.Next(100).ToString() + filename; Stream strm = FileUpload1.PostedFile.InputStream; var targetFile = Server.MapPath(targetPath); //Based on scalefactor image size will vary GenerateThumbnails(0.5, strm, targetFile); FileStream fs = new FileStream(Server.MapPath(targetPath), FileMode.Open); //Setting up the variable which can hold bytes from the image img = new byte[fs.Length]; //Read all the bytes from the stream and put into the variable called //img fs.Read(img, 0, Convert.ToInt32(fs.Length)); fs.Close(); File.Delete(Server.MapPath(targetPath)) ; return img; } database db = new database(); protected void btnAddContender_Click(object sender, EventArgs e) { if (drpVotingList.SelectedIndex > 0)

{ if (string.IsNullOrEmpty(txtName.Text.Trim ())) { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Please Enter Contender Name.');", true); txtName.Focus(); } else if (string.IsNullOrEmpty(txtDescription.Te xt.Trim())) { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Please Enter Contender Description.');", true); txtDescription.Focus(); } else if (!FileUpload1.HasFile) { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Please Choose Contender Image.');", true); FileUpload1.Focus(); } else { byte[] img = null; if (FileUpload1.HasFile) { img = GenerateByte(FileUpload1); } db.spInsertContenderMaster(Convert.ToDe cimal(drpVotingList.SelectedItem.Value) , txtName.Text.Trim(), txtDescription.Text.Trim(), img); txtName.Text = string.Empty; txtDescription.Text = string.Empty; LoadContender(); } } else { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Please Select A Voting List');", true); } } protected void btncreateVotingList_Click(object sender, EventArgs e) { if(drpCategory.SelectedIndex>0) { if (string.IsNullOrEmpty(txtVotingTitle.Te xt.Trim())) {

ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Please Enter Voting Title.');", true); txtVotingTitle.Focus(); } else if (string.IsNullOrEmpty(txtVotingDetail.T ext.Trim())) { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Please Enter Detail.');", true); txtVotingDetail.Focus(); } else if(CalStartDate.SelectedDate0) { LoadContender(); txtName.Focus(); } } protected void btnSubmitRequest_Click(object sender, EventArgs e) { if(drpVotingList.SelectedIndex










The code behind file using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.IO; public partial class VotingPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (Session["UserId"] == null) { Response.Redirect("Login.aspx"); } if (Request["VotingListId"] == null) { Response.Redirect("Categories.aspx");

} if (!IsPostBack) { Master.loadNav(1); loadVotingListDetails(); loadContenderOption(); } } public string ByteToImage(byte[] image) { try { Stream fs = new MemoryStream(image); System.IO.BinaryReader br = new System.IO.BinaryReader(fs); Byte[] bytes = br.ReadBytes(Convert.ToInt32(fs.Length) );

string base64String = Convert.ToBase64String(bytes, 0, bytes.Length); return Convert.ToString("data:image/png;base64 ,") + base64String; } catch { return null; } } void loadContenderOption() { DataTable vDt = db.spFetchContender(Convert.ToDecimal(R equest["VotingListId"])); DataTable dt = new DataTable(); dt.Columns.Add("id"); dt.Columns.Add("Name"); dt.Columns.Add("Description"); dt.Columns.Add("Img"); for (int i = 0; i < vDt.Rows.Count;i++ ) { dt.Rows.Add(vDt.Rows[i]["id"].ToString( ), vDt.Rows[i]["Name"].ToString(), vDt.Rows[i]["Description"].ToString(),B yteToImage((byte[]) vDt.Rows[i]["Img"])); } RepeaterContenderOption.DataSource = dt; RepeaterContenderOption.DataBind(); } database db = new database(); void loadVotingListDetails() { DataTable dt = db.spFetchVotingListMasterById(Convert. ToDecimal(Request["VotingListId"])); lblVotingPageTitle.Text = dt.Rows[0]["Title"].ToString (); lblVotingPageDetails.Text = dt.Rows[0]["Detail"].ToString(); lblStartDate.Text = dt.Rows[0]["StartDate"].ToString(); lblEndDate.Text = dt.Rows[0]["EndDate"].ToString(); //lblTotalVotes.Text = "120"; }

int countRow = 1; protected void RepeaterContenderOption_ItemDataBound(o bject sender, RepeaterItemEventArgs e) {

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { DataRowView drv = e.Item.DataItem as DataRowView; if (countRow % 3 == 0) { Panel pnlClearFix = (Panel)e.Item.FindControl("pnlClearFix" ); pnlClearFix.Visible = true; } countRow = countRow + 1; } if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { RadioButton radioButtonVoteItem = (RadioButton)e.Item.FindControl("RadioB utton1"); string script = "SetUniqueRadioButton('RepeaterContende rOption.*PollVoteItems',this)"; radioButtonVoteItem.Attributes.Add("onc lick", script); } } protected void RadioButton1_CheckedChanged(object sender, EventArgs e) {

} protected void btnSubmit_Click(object sender, EventArgs e) {

if (string.IsNullOrEmpty(txtAnswer.Text)) { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Please enter voting description.');", true); txtAnswer.Focus(); } else { decimal ContenderId = 0; for (int i = 0; i < RepeaterContenderOption.Items.Count; i++) { RadioButton radioButtonVoteItem = (RadioButton)RepeaterContenderOption.It ems[i].FindControl("RadioButton1"); if (radioButtonVoteItem.Checked) {

Label lblContenderId = (Label)RepeaterContenderOption.Items[i] .FindControl("lblContenderId"); ContenderId = Convert.ToDecimal(lblContenderId.Text); break; } } if(ContenderId==0) { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Please select a contender before voting.');", true); RepeaterContenderOption.Focus(); return; } string str = db.spInsertResultMaster(Convert.ToDecim al(Session["UserId"].ToString()), Convert.ToDecimal(Request["VotingListId

"]), ContenderId, txtAnswer.Text.Trim()); if(str.Equals("1")) { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Thanks for your voting.');", true); txtAnswer.Text = string.Empty; } else { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('You are not eligible for this vote as you have already voted.');", true); txtAnswer.Text = string.Empty; } } } }

5.2.14. VOTING RESULTS After votes has been cast, the area in which we can view the result is the voting result page. It gives a summary of the contenders and finally the winner. The source code

Following the your voting result, Please click on view Result for more details.






The code behind file using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; public partial class VotingHistory : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Master.loadNav(4);

loadVoteListGrids(); } void loadVoteListGrids() { RepeaterVotingListGrid.DataSource = new database().spFetchVoteListForResult(); RepeaterVotingListGrid.DataBind();

} }

5.2.15. STYLE SHEET The Style sheet folder contains the page’s design which includes font style, sizes, header and footer alignment, body contents, logo position, border customization, menu bar, banner settings, icons display, and so on. In addition, the CSS folder contains the bootstrap.css file, and this file is a file which is designed to enable some special features in the web page so that the page can be compatible with any kind of devices.

It does that by shrinking or reducing the pixels of the screen in order to adopt to the new environment.

The source code body a{ transition:0.5s all; -webkit-transition:0.5s all; -moz-transition:0.5s all; -o-transition:0.5s all; -ms-transition:0.5s all; } h1,h2,h3,h4,h5,h6{ padding:0 0; margin:0 0; } p{ padding:0 0; margin:0 0; } ul{ padding:0 0; margin:0 0; } body{ padding:0 0; margin:0 0; font-family:'Open Sans', sans-serif; } @font-face { font-family: 'DosisRegular'; src: url(../fonts/DosisRegular.ttf) format('truetype'); } @font-face { font-family: 'DosisMedium'; src: url(../fonts/DosisMedium.ttf) format('truetype'); } @font-face { font-family: 'DosisBold'; src: url(../fonts/DosisBold.ttf) format('truetype'); } .logo { position: absolute; left: 45%; top: -96%; z-index: 1; }

.logo h1 a { display: inline-block; color: #fff; font-family: 'DosisMedium'; font-size: 1em; text-decoration: none; background:#3598DB; border-radius: 50%; -webkit-border-radius: 50%; -moz-border-radius: 50%; -ms-border-radius: 50%; -o-border-radius: 50%; border: 8px solid #fff; padding: 52px 15px; height: 160px; width: 160px; } span.menu { display: none; } .top-header { margin: 2em 0; text-align: center; position: relative; } .top-menu ul li { display: inline-block; } .top-menu{ position: relative; } .top-menu ul li a { font-size: 1.4em; color: #000; padding: 0 2em; text-decoration: none; font-weight: 100; font-family: 'DosisMedium'; } .top-menu ul li a:hover{ color:#3598db; } .top-menu ul li:nthchild(3) { margin-right: 13em; } .aboutPage{ background: url(../images/aboutImg.j pg) no-repeat 0px 127px;

background-size: cover; min-height: 600px; } .header{ background: url(../images/aboutImg.j pg) no-repeat 0px 127px; background-size: cover; min-height: 600px; } .AboutPage{ background: url(../images/banner.jpg ) no-repeat 0px -127px; background-size: cover; min-height: 600px; } .AboutPage-info{ float:left; width:36%; margin-top:auto; text-align:justify; fontfamily:'Harrington'; margin: 3em 0 0 3em; } .banner-info { float: right; width: 46%; margin: 3em 0 0 0em; } .banner-info h2{ color:#fff; font-size:3.5em; font-family: 'DosisMedium'; } .banner-info p{ color:#fff; font-size:1em; line-height:1.8em; margin-top:2em; } .banner-info a{ color: #fff; padding: 0.6em 3em; font-size: 1.1em; display: inline-block; margin-top: 2.5em; border: 2px solid #3598db; border-radius: 5px;

-webkit-border-radius: 5px; -moz-border-radius: 5px; -ms-border-radius: 5px; -o-border-radius: 5px; background: #3598db; } .banner-info a:hover{ text-decoration:none; color:#fff; background:transparent; border:2px solid #fff; } label{ font-weight:normal; } /*--service--*/ .service{ padding:5em 0; } .icon-pic { float: left; width: 23%; } .icon { width: 100px; height: 100px; display: inline-block; border-radius: 50%; -webkit-border-radius: 50%; -moz-border-radius: 50%; -ms-border-radius: 50%; -o-border-radius: 50%; margin-bottom: 1.5em; padding: 32px 0px; background:#fff; border:2px solid #3598db; } .glyphicon-phone:before, .glyphicon-thumbsup:before, .glyphiconpicture:before,.glyphico n-user:before{ color:#9F9F9F; font-size: 35px; } .icon-info { float: left; width: 74%; margin-left: 3%; } .icon-info h4 a { color: #3E3E3E; font-size: 1.3em; text-decoration: none; display: inline-block; font-family: 'DosisMedium'; } .icon-info p { font-size: 1em; line-height: 1.8em;

color: #999; margin-top:0.7em; } .service-grids{ margin-top:3.5em; } .grids2{ margin-top:3.5em; } /*--about--*/ .about{ padding:2em 0 } .about-right h3,.service h3,.gallery h3,.blog h3,.contact h3{ color:#3598db; font-size:2.5em; font-family: 'Dosisbold'; text-align:center; } .about-right{ width:51.8%; float:left; padding:0em 4em; } .about-right h4{ font-size:1.75em; font-family: 'DosisMedium'; margin-top:1em; color:#3E3E3E; } .about-right p{ color:#999; font-size:1em; line-height:1.8em; margin-top:0.5em; } .about-left{ float: left; width: 48.2%; background: url(../images/img1.jpg) no-repeat 0px -113px; min-height: 302px; background-size: cover; } /*----*/ .gallery { margin:4em 0; } .galry-grids { padding: 2px; } .galry-grids img { width: 100%; } .gallery-info{ margin-top:2.5em; } /*----- Strip -----*/ .b-link-stripe{

position:relative; display:block; vertical-align:top; font-weight: 300; overflow:hidden; } .b-link-stripe .bwrapper{ position:absolute; width:100%; height:100%; top:0; left:0; text-align:center; overflow:hidden; } .b-link-stripe .b-line{ position:absolute; top:0; bottom:0; width:20%; background:rgba(15, 207, 140, 0.9); transition:all 0.5s linear; -moz-transition:all 0.5s linear; -ms-transition:all 0.5s linear; -o-transition:all 0.5s linear; -webkit-transition:all 0.5s linear; opacity:0; visibility:hidden; /* lt-ie9 */ } img.img-responsive.glryimg { width: 100%; } /*------Animation effects------*/ .b-animate-go{ text-decoration:none; } .b-animate{ transition: all 0.5s; -moz-transition: all 0.5s; -ms-transition: all 0.5s; -o-transition: all 0.5s; -webkit-transition: all 0.5s; visibility: hidden; } .b-animate img{ display: -webkit-inlinebox; } /* lt-ie9 */ .b-animate-go:hover .banimate{

visibility:visible; } .b-from-left{ position: absolute; top: 43%; left: -100%; } .b-animate-go:hover .bfrom-left{ left: 43%; } .b-wrapper:hover { background: rgba(185, 207, 237, 0.85); transition: 0.5s all; -webkit-transition: 0.5s all; -o-transition: 0.5s all; -moz-transition: 0.5s all; -ms-transition: 0.5s all; } .body-pic-bottom { background-color: #B9CFED; width: 100%; height: 270px; position: absolute; bottom: -93px; z-index: -12; } /*----*/ .blog{ padding-bottom:3em; } .blog-grids{ margin-top:2.5em; } .blog-grid h4 a { color: #3598db; font-size: 1.3em; text-decoration: none; display: inline-block; font-family: 'DosisMedium'; margin-top:0.7em; } .blog-grid p{ color:#999; line-height:1.8em; font-size:1em; margin-top:1em; } .blog-grid span { font-size:1em; font-family: 'DosisBold'; margin-top:6px; display: block; } a.blogs{ color: #3598db; font-size: 1em;

margin-top: 1.5em; display: inline-block; text-decoration:none; } a.blogs:hover{ color:#333; } .middleblog-grid{ width:50%; margin:3em auto 0; text-align:center; } /*--map--*/ .map iframe{ width:100%; min-height:400px; } /*--contact--*/ .contact{ padding:3em 0; } .touch-top{ margin-top:2.5em; } .touch-left form input[type="text"]:nthchild(1) { margin-right: 25px; } .touch-left form input[type="text"] { width: 48%; margin: 7px auto; color: #999; background: none; padding: 10px 10px; outline: none; border: 1px solid #999; border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; -o-border-radius: 5px; -ms-border-radius: 5px; } .touch-left form textarea { width: 100%; margin: 2em 0 0 0; color: #999; resize: none; background: none; height: 150px; padding: 15px; outline: none; border: 1px solid #999; border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; -o-border-radius: 5px; -ms-border-radius: 5px; }

.touch-left form input[type=submit] { color: #ffffff; padding: 9px 30px; font-size: 14px; cursor: pointer; font-weight: 500; margin: 27px 0 0 0px; border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; -o-border-radius: 5px; -ms-border-radius: 5px; border: 2px solid #3598db; background: #3598db; transition:0.5s all; -webkit-transition:0.5s all; -moz-transition:0.5s all; -o-transition:0.5s all; -ms-transition:0.5s all; } .touch-left form input[type=submit]:hover { border: 2px solid #3598db; background: transparent; color:#3598db; } .touch-right-top:nthchild(1) { margin-top: 0; } .touch-right-top { text-align: center; margin-top: 8px; color: #999; } .touch-right-top p a{ color:#999; } .touch-right-top span.add { background-position: 0px 0px; } .touch-right-top span.mail { background-position: 35px 0px; } .touch-right-top span.num { background-position: 70px 0px; } .touch-right-top span {

background: url(../images/contact.pn g) no-repeat; width: 35px; height: 46px; display: block; margin: 0 auto; } .touch-right-top h4 { color: #999; font-size: 12px; letter-spacing: 1px; margin: 0px; } /*----*/ .footer{ text-align:center; background:#000; padding:3em 0 1em 0; } .footer p { color: #fff; font-size: 1em; } .footer p a{ color: #fff; } .social{ margin-top:1.5em; } .social i { width: 27px; height: 27px; background: url('../images/socialicons.png') no-repeat 0px 0px; display: inline-block; margin:0 5px; } a i.facebook{ background-position:-3px -2px; } a i.twitter{ background-position: 43px -3px; } a i.dribble{ background-position: 83px -3px; } a i.google{ background-position:126px -2px } a i.youtube{ background-position:167px -3px; } a i.facebook:hover{ background-position:-3px -36px; }

a i.twitter:hover{ background-position: 43px -36px; } a i.dribble:hover{ background-position: 83px -36px; } a i.google:hover{ background-position:126px -36px } a i.youtube:hover{ background-position:167px -36px; } .arrow{ text-align:center; padding:2em 0 0.5em 0; } #toTop { display: none; text-decoration: none; position: fixed; bottom: 14px; right: 3%; overflow: hidden; width: 40px; height: 40px; border: none; text-indent: 100%; background: url("../images/totop1.png") no-repeat 0px 0px; } #toTopHover { width: 40px; height: 40px; display: block; overflow: hidden; float: right; opacity: 0; -moz-opacity: 0; filter: alpha(opacity=0); } /*--responsive--*/ @media (max-width: 1280px){ .about-left { background: url(../images/img1.jpg) no-repeat 0px -77px; min-height: 332px; background-size: cover; } } @media (max-width: 1080px){ .top-menu ul li:nthchild(3) { margin-right: 11em;

} .logo { left: 42%; } .banner-info { margin: 8em 0 0 0em; } .banner-info h2 { font-size: 3em; } .header { background: url(../images/banner.jpg ) no-repeat 0px 0; background-size: cover; min-height: 494px; } } @media (max-width: 1024px){ .top-menu ul li:nthchild(3) { margin-right: 11em; } .banner-info { margin: 8em 0 0 0em; } .banner-info h2 { font-size: 3em; } .header { min-height: 483px; } .logo { left: 43%; } .about-right h4 { font-size: 1.6em; } .about-left { background: url(../images/img1.jpg) no-repeat 0px -2px; min-height: 364px; background-size: cover; width: 52.2%; } .about-right { width: 47.8%; padding: 0em 2em; } .touch-left form input[type="text"]:nthchild(1) { margin-right: 19px; } } @media (max-width: 991px){ .top-menu ul li:nthchild(3) { margin-right: 12em; } .header {

min-height: 430px; } .banner-info h2 { font-size: 2.5em; } .banner-info { margin: 9em 0 0 0em; padding: 0 0px 0 79px; width: 58%; } .banner-info p { font-size: 0.9em; line-height: 1.6em; margin-top: 1.5em; } .banner-info a { padding: 0.7em 3em; font-size: 1em; margin-top: 1.5em; } .top-menu ul li a { padding: 0 1em; } .icon-pic { width: 25%; } .icon-info { width: 72%; } .futr-grid{ width: 50%; float: left; } .icon-info p { font-size: 0.9em; } .glyphicon-phone:before, .glyphicon-thumbsup:before, .glyphiconpicture:before, .glyphicon-user:before { font-size: 27px; } .icon { width: 80px; height: 80px; padding: 23px 0px; } .icon-info h4 a { font-size: 1.2em; } .galry-grids { padding: 4px; width: 33.3%; float: left; } .blog-grid { width: 50%; float: left; } .about-right p { font-size: 0.9em; margin-top: 0.7em; }

.about-left { min-height: 341px; } .blog-grid h4 a { font-size: 1.2em; } .blog-grid p { font-size: 0.9em; } } @media (max-width: 800px){ .logo h1 a { font-size: 0.8em; padding: 39px 12px; height: 126px; width: 126px; } } @media (max-width: 768px){ .header { background: url(../images/banner.jpg ) no-repeat 0px 0; background-size:cover; min-height: 400px; } .banner-info h2 { font-size: 2em; } .logo h1 a { font-size: 0.8em; padding: 39px 12px; height: 126px; width: 126px; } .banner-info { margin: 7em 0 0 0em; } .map iframe { width: 100%; min-height: 320px; } .about-right h3, .service h3, .gallery h3, .blog h3, .contact h3 { font-size: 2em; } .service { padding: 3em 0; } .icon-info h4 a { font-size: 1.1em; } .about-right h4 { font-size: 1.2em; } .about-right a { font-size: 0.9em; margin-top: 1em; } .gallery {

margin: 2em 0; } .blog-grid h4 a { font-size: 1.1em; } .blog-grid span { font-size: 0.9em; } .middleblog-grid{ text-align:left; } .touch-left form input[type=submit] { font-size: 13px; } .arrow { padding: 1em 0 0.5em 0; } } @media (max-width: 736px){ .top-menu ul li:nthchild(3) { margin-right: 10em; } } @media(max-width:667px){ span.menu { display: block; text-align: right; cursor: pointer; position: relative; padding: 1em 0; } .top-menu span img{ display:inline-block; } .top-menu { width: 100%; float: right; } .top-menu ul{ display:none; } .top-menu ul li { font-size: 12px; display:inline-block; width: 100%; margin:0; } .top-menu ul{ margin: 0; z-index: 999; position: absolute; width: 100%; text-align: center; left: 0%; background:#fff; } .top-menu ul li a { padding: 0.4em 0em; display: block; font-size:1.4em; }

.top-header { margin: 1em 0; } .header { min-height: 350px; } .logo { left: 42%; } .logo h1 a { font-size: 0.7em; padding: 31px 8px; border: 6px solid #fff; height: 100px; width: 100px; } .top-menu ul li:nthchild(3) { margin-right: 0; } } @media(max-width:640px){ span.menu { display: block; text-align: right; cursor: pointer; position: relative; padding: 1.5em 0; } .top-menu span img{ display:inline-block; } .top-menu { width: 100%; float: right; } .top-menu ul{ display:none; } .top-menu ul li { font-size: 12px; display:inline-block; width: 100%; margin:0; } .top-menu ul{ margin: 0; z-index: 999; position: absolute; width: 100%; text-align: center; left: 0%; background:#fff; } .top-menu ul li a { padding: 0.4em 0em; display: block; font-size:1.4em; } .top-header { margin: 0em 0; } .header { min-height: 350px;

} .logo { left: 42%; top:0; } .logo h1 a { font-size: 0.7em; padding: 31px 8px; border: 6px solid #fff; height: 100px; width: 100px; } .banner-info h2 { font-size: 1.5em; } .banner-info { margin: 6em 0 0 0em; width: 54%; padding: 0 0px 0 45px; } .banner-info a { padding: 0.6em 3em; font-size: 0.85em; margin-top: 1em; } .futr-grid { width: 100%; padding: 0; margin-bottom: 2em; } .icon-pic { width: 13%; } .icon-info { width: 84%; } .grids2 { margin-top:0em; } .service-grids { margin-top: 2em; } .about-left { background: url(../images/img1.jpg) no-repeat 0px -33px; min-height: 348px; background-size: cover; width: 100%; } .about-right { width: 100%; padding: 2em 1.5em 0 1.5em; } .service { padding:2em 0 1em 0; } .about { padding: 0em 0; } .blog-grid { width: 100%; padding: 0;

margin-bottom: 2em; } a.blogs { font-size: 0.9em; margin-top: 0.5em; } .middleblog-grid { margin: 0em auto 0; } .touch-left form input[type="text"]:nthchild(1) { margin-right: 0; } .touch-left form input[type="text"] { width: 100%; } .map iframe { min-height: 250px; } .contact { padding: 2em 0; } .touch-left { padding: 0; } .touch-top { margin-top: 1.5em; } .touch-left form textarea { margin: 1em 0 0 0; } .footer p { font-size: 0.9em; } .footer { padding: 2em 0 1em 0; } .top-menu ul li:nthchild(3) { margin-right: 0; } } @media(max-width:480px){ span.menu { padding: 0.7em 0; } .logo h1 a { font-size: 0.6em; padding: 27px 9px; border: 5px solid #fff; height: 90px; width: 90px; } .header { background: url(../images/banner.jpg ) no-repeat -75px 0px; background-size: cover; min-height: 335px; } .banner-info {

margin: 4em 0 0 0em; width: 54%; padding: 0 0px 0 9px; } .icon-pic { width: 18%; } .icon-info { width: 76%; margin-left: 4%; } .icon-info p { font-size: 0.85em; margin-top: 0.5em; } .icon-info h4 a { font-size: 1em; } .about-left { min-height: 283px; } .about-right p { font-size: 0.85em; } .about-right a { font-size: 0.85em; padding: 0.7em 1.5em; } .blog-grid p { font-size: 0.85em; line-height: 1.7em; } .touch-left form input[type=submit] { font-size: 12px; margin: 1em 0 0 0px; padding: 9px 27px; } .touch-left form input[type="text"],.touc h-left form textarea { width: 100%; font-size: 0.9em; padding:10px; } .touch-right-top h4 { letter-spacing: 0px; } } @media(max-width:414px){ .header { background: url(../images/banner.jpg ) no-repeat -124px 0px; background-size: cover; } .banner-info {

1.3.1. SERVER SIDE

width: 59%; } } @media(max-width:384px){ .header { background: url(../images/banner.jpg ) no-repeat -158px 0px; background-size: cover; min-height: 335px; } .banner-info { width: 65%; } } @media(max-width:320px){ span.menu { padding: 1.2em 0; } .logo { left: 35%; } .header { background: url(../images/banner.jpg ) no-repeat -154px 0px; background-size: cover; min-height: 276px; } .banner-info { margin: 3em 0 0 0em; width: 80%; padding: 0 0px 0 15px; } .banner-info p { font-size: 0.8em; } .banner-info a { padding: 0.55em 2.5em; font-size: 0.85em; margin-top: 1em; } .glyphicon-phone:before, .glyphicon-thumbsup:before, .glyphiconpicture:before, .glyphicon-user:before { font-size: 20px; } .icon { width: 54px; height: 55px; padding: 14px 0px; } .icon-info h4 a { font-size: 0.9em; }

.icon-info { width: 76%; margin-left: 6%; } .about-left { min-height: 204px; background: url(../images/img1.jpg) no-repeat 0px 0px; background-size:cover; } .about-right h3, .service h3, .gallery h3, .blog h3, .contact h3 { font-size: 1.5em; } .service-grids { margin-top: 1.5em; } .about-right { padding: 2em 1em 0 1em; } .about-right h4 { font-size: 1.1em; } .about-right a { font-size: 0.8em; padding: 0.7em 1.3em; } .galry-grids { padding: 0px 0 8px 0; width: 100%; } .gallery-info { margin-top: 1.5em; } .blog-grids { margin-top: 1.5em; } .blog-grid h4 a { font-size: 0.9em; } .blog-grid span { font-size: 0.83em; } .blog-grid p { margin-top: 0.5em; } .map iframe { min-height: 180px; } .touch-left form textarea { height: 120px; } }

The server side just as the client side is designed using the same technology and tools. Although, we had to isolate the Admin panel from the other modules. That helps a lot in maintaining accuracy and efficiency. The following are the modules created for the server management panel: 1.3.2. DEFAULT.ASPX This is the main admin panel where all the options are displayed. It contains the dashboard, voting list category, manage voting list, manage users, and settings. The source code

VOS - Admin Panel HOME



1.3.3. CATEGORY.ASPX This page contains an option beneath it which allows the admin to add/edit category. It also gives the option to activate or deactivate any category. (see fugure) The source code










IsActive


The code behind file using using using using using using

System; System.Collections.Generic; System.Linq; System.Web; System.Web.UI; System.Web.UI.WebControls;

public partial class admin_Category : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { loadCategory(); } } void loadCategory() { drpCategory.DataSource = db.spFetchCategory(); drpCategory.DataTextField = "CategoryName"; drpCategory.DataValueField = "id"; drpCategory.DataBind(); drpCategory.Items.Insert(0, "-- Select Category --"); drpCategory.SelectedIndex = 0; } database db = new database(); protected void btnAddCategory_Click(object sender, EventArgs e) { if(string.IsNullOrEmpty(txtCategory.Tex t.Trim())) { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Please Enter Category');", true); txtCategory.Focus(); } else {

string str = db.spInsertCategoryMaster(txtCategory.T ext.Trim()); if(str.Equals("0")) { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Category With This Name Already Exists.');", true); txtCategory.Focus(); } else { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Category Added Successfully.');", true); txtCategory.Text = string.Empty; txtCategory.Focus(); loadCategory(); } } } protected void btnEditCategory_Click(object sender, EventArgs e) { if(drpCategory.SelectedIndex0) { System.Data.DataTable dt = db.spFetchCategoryById(Convert.ToDecima l(drpCategory.SelectedItem.Value)); txtEditCategory.Text=dt.Rows[0]["Catego ryName"].ToString (); chkActive.Checked = (bool)dt.Rows[0]["IsActive"]; } } }

1.3.4. CHANGEPWD.ASPX This page allows the admin to frequently change the password in order to enhance security. It contains three textboxes, enter current password, new password and reenter new password for confirmation and verification. (See figure) The source Code

Change password of your account


Cuurent Password
New Password
Re-enter New Password


Change Password




The code behind file using using using using using using

System; System.Collections.Generic; System.Linq; System.Web; System.Web.UI; System.Web.UI.WebControls;

public partial class ChangePwd : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } database db = new database(); protected void btnChangePwd_Click(object sender, EventArgs e) { if (txtOldPwd.Text.Trim().Equals(string.Em pty)) { ScriptManager.RegisterStartupScript(thi s.Page, this.GetType(), "script", "alert('Please Enter Old Password...');", true); txtOldPwd.Focus(); } else if (txtNewPwd.Text.Trim().Equals(string.Em pty)) { ScriptManager.RegisterStartupScript(thi s.Page, this.GetType(), "script", "alert('Please Enter New Password...');", true); txtNewPwd.Focus(); } else if (txtNewPwd.Text.Trim().Length < 4) { ScriptManager.RegisterStartupScript(thi s.Page, this.GetType(), "script", "alert('Password Should Be Greater Than Or Equal To 4 Characters Long In Length...');", true);

txtNewPwd.Focus(); } else if (txtNewConfirmPwd.Text.Trim().Equals(st ring.Empty)) { ScriptManager.RegisterStartupScript(thi s.Page, this.GetType(), "script", "alert('Please Enter New Confirm Password...');", true); txtNewConfirmPwd.Focus(); } else if (!txtNewConfirmPwd.Text.Trim().Equals(t xtNewPwd.Text.Trim())) { ScriptManager.RegisterStartupScript(thi s.Page, this.GetType(), "script", "alert('Password Does Not Match...');", true); txtNewConfirmPwd.Focus(); } else { string str = db.spChangeUserPwd(Convert.ToDecimal(Se ssion["AdminId"]), txtOldPwd.Text, txtNewPwd.Text); if (str.Equals("0")) { ScriptManager.RegisterStartupScript(thi s.Page, this.GetType(), "script", "alert('Invalid Password ...');", true); } else { Response.Redirect("LogIn.aspx"); } } } }

5.3.6. LOGIN.ASPX This login aspx allows the admin to have an entry into the Admin panel by the use of Admin username and password. The source code VMC - Vote My Choice addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); }

© 2016 VMC - Vote My Choice. All Rights Reserved



The code behind file using using using using

System; System.Collections.Generic; System.Linq; System.Web;

using System.Web.UI; using System.Web.UI.WebControls;

public partial class admin_web_Login : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnLogin_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtUserId.Text.Tr im())) { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Please Enter Email ID.');", true); txtUserId.Focus(); } else if (string.IsNullOrEmpty(txtPwd.Text.Trim( ))) { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Please Enter Password.');", true); txtPwd.Focus(); } else { System.Data.DataTable dt = new database().spValidateUser(txtUserId.Tex t.Trim(), txtPwd.Text.Trim()); if (dt.Rows[0][0].ToString().Equals("0"))

{ ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Invalid Email Id / Password.');", true); txtPwd.Focus(); } else { if (txtUserId.Text.Trim().ToLower().Equals ("admin")) { Session["AdminId"] = dt.Rows[0][0].ToString(); Session["UserName"] = dt.Rows[0][1].ToString(); Session["UserEmail"] = txtUserId.Text.Trim();

Response.Redirect("Default.aspx"); } else { ScriptManager.RegisterStartupScript(thi s, this.GetType(), "", "alert('Invalid Email Id / Password.');", true); txtPwd.Focus(); } } } } }

5.3.7. MANAGEUSER.ASPX This page allows the Admin to manage all the existing users. It also allows the admin to activate or deactivate any account within the list. The source code



Inactivate

S.No. Name Email Contact Address
Inactivate





S.No. Name Email Contact Address Activate

Activate





The code behind file using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; public partial class admin_ManageUsers : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { LoadUserData(); } database db = new database(); void LoadUserData() { RepeaterActiveList.DataSource = db.spFetchUser(true); RepeaterActiveList.DataBind(); RepeaterInactiveList.DataSource = db.spFetchUser(false); RepeaterInactiveList.DataBind(); } protected void LinkButton1_Click(object sender, EventArgs e)

{ LinkButton button = (sender as LinkButton); //Get the command argument string commandArgument = button.CommandArgument; db.spUpdateUserMaster(Convert.ToDecimal (commandArgument), false); LoadUserData(); } protected void LinkButton1_Click1(object sender, EventArgs e) { LinkButton button = (sender as LinkButton); //Get the command argument string commandArgument = button.CommandArgument; db.spUpdateUserMaster(Convert.ToDecimal (commandArgument), true); LoadUserData(); } }

5.3.8. VOTINGREQUEST.ASPX Voting Request page allows the admin to approve or disapprove any voting request sent by the vendor(s). This includes the lists of contenders and their categories for voting. The source code



Approve



User ID User Name Title Detail Start Date
Approve






The code behind file using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; public partial class admin_ManageUsers : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { Loaddata(); } } database db = new database(); void Loaddata()

{ RepeaterActiveList.DataSource = db.spFetchUpcomingVoteListForAdmin(); RepeaterActiveList.DataBind(); } protected void LinkButton1_Click(object sender, EventArgs e) { LinkButton button = (sender as LinkButton); //Get the command argument string commandArgument = button.CommandArgument; db.spApproveVotingRequest(Convert.ToDec imal(commandArgument), true); Loaddata(); } }

5.4. THE BACK END IMPLEMENTATION (SQL QUERIES)

Databases are bedrock of every system whether small, medium or big. The name of our database is VMCDB. The back end which is considerered the database or repository is also composed of query structures which defined the various tables, procedures and functions. A collection of all these queries are put together under one single file that is generated from SQL server 2014. The codes are as follows: USE [VMCDB] GO /****** Object: Table [dbo].[CategoryMaster] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[CategoryMaster]( [id] [numeric](18, 0) IDENTITY(1,1) NOT NULL, [CategoryName] [varchar](1000) NULL, [IsActive] [bit] NULL CONSTRAINT [DF_CategoryMaster_IsActive] DEFAULT ((1)), CONSTRAINT [PK_CategoryMaster] PRIMARY KEY CLUSTERED ( [id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO /****** Object: Table [dbo].[ContenderMaster] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[ContenderMaster]( [id] [numeric](18, 0) IDENTITY(1,1) NOT NULL,

[VoteListId] [numeric](18, 0) NULL, [Name] [varchar](100) NULL, [Description] [varchar](1000) NULL, [Img] [image] NULL, [EntryDate] [datetime] NULL CONSTRAINT [DF_ContenderMaster_EntryDate] DEFAULT (getdate()), CONSTRAINT [PK_ContenderMaster] PRIMARY KEY CLUSTERED ( [id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO SET ANSI_PADDING OFF GO /****** Object: Table [dbo].[ResultMaster] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[ResultMaster]( [id] [numeric](18, 0) IDENTITY(1,1) NOT NULL, [UserId] [numeric](18, 0) NULL, [VotingId] [numeric](18, 0) NULL, [ContenderId] [numeric](18, 0) NULL, [Answer] [varchar](5000) NULL, [EntryDate] [datetime] NULL, CONSTRAINT [PK_ResultMaster] PRIMARY KEY CLUSTERED ( [id] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO /****** Object: Table [dbo].[UserMaster] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[UserMaster]( [id] [numeric](18, 0) IDENTITY(1,1) NOT NULL, [Name] [varchar](100) NULL, [Email] [varchar](100) NULL, [Contact] [varchar](10) NULL, [Pwd] [varchar](100) NULL, [Address] [varchar](1000) NULL, [IsActive] [bit] NULL CONSTRAINT [DF_UserMaster_IsActive] DEFAULT ((1)), [EntryDate] [datetime] NULL CONSTRAINT [DF_UserMaster_EntryDate] DEFAULT (getdate()), CONSTRAINT [PK_UserMaster] PRIMARY KEY CLUSTERED ( [id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO /****** Object: Table [dbo].[VotingListMaster] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO

CREATE TABLE [dbo].[VotingListMaster]( [id] [numeric](18, 0) IDENTITY(1,1) NOT NULL, [UserId] [numeric](18, 0) NULL, [CatId] [numeric](18, 0) NULL, [Title] [varchar](1000) NULL, [Detail] [varchar](4000) NULL, [EntryDate] [datetime] NULL CONSTRAINT [DF_VotingListMaster_EntryDate] DEFAULT (getdate()), [EndDate] [date] NULL, [StartDate] [date] NULL, [IsActive] [bit] NULL CONSTRAINT [DF_VotingListMaster_IsActive] DEFAULT ((1)), [Status] [bit] NULL CONSTRAINT [DF_VotingListMaster_Status] DEFAULT ((0)), CONSTRAINT [PK_VotingListMaster] PRIMARY KEY CLUSTERED ( [id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO ALTER TABLE [dbo].[ResultMaster] ADD CONSTRAINT [DF_ResultMaster_EntryDate] DEFAULT (getdate()) FOR [EntryDate] GO /****** Object: StoredProcedure [dbo].[spApproveVotingRequest] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO Create Procedure [dbo].[spApproveVotingRequest] ( @id numeric(18,0) ,@Status bit ) As Begin Update [dbo].[VotingListMaster] Set [Status] = @Status Where [id] = @id End

GO /****** Object: StoredProcedure [dbo].[spChangeUserPwd] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO Create proc [dbo].[spChangeUserPwd] ( @UserId numeric(18,0), @Pwd varchar(1000), @NewPwd varchar(1000) ) as if exists(select id from UserMaster where id=@UserId and pwd=@Pwd and IsActive=1) begin update UserMaster set Pwd=@NewPwd where id=@UserId select '1' end else select '0'

GO SET QUOTED_IDENTIFIER ON GO

GO /****** Object: StoredProcedure [dbo].[spFetchCategoriesAndListCount] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE proc [dbo].[spFetchCategoriesAndListCount] as select cm.id,cm.CategoryName, (select count(id) from VotingListMaster where StartDate>=cast(getdate() as date)and IsActive=1 and Status=0 and CatId=cm.id)as 'upComingList', (select count(id) from VotingListMaster where StartDate>=cast(getdate() as date)and IsActive=1 and Status=1 and CatId=cm.id)as 'activeList' from CategoryMaster cm where cm.IsActive=1

GO /****** Object: StoredProcedure [dbo].[spFetchContender] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO create proc [dbo].[spFetchContender] ( @VoteListId numeric(18,0) ) as select *from ContenderMaster where VoteListId=@VoteListId GO /****** Object: StoredProcedure [dbo].[spFetchContenderImage] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO

GO /****** Object: StoredProcedure [dbo].[spFetchCategory] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON

create proc [dbo].[spFetchCategory] as select *from CategoryMaster GO /****** Object: StoredProcedure [dbo].[spFetchCategoryById] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO create proc [dbo].[spFetchCategoryById] ( @CatID numeric(18,0) ) as select *from CategoryMaster where id=@CatID

create proc [dbo].[spFetchContenderImage]( @ID numeric(18,0) ) as

select img from ContenderMaster where id=@ID GO /****** Object: StoredProcedure [dbo].[spFetchContenderList] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO Create proc [dbo].[spFetchContenderList] ( @id numeric(18,0), @VoteListId numeric(18,0) ) as if(@id=0) begin select *From ContenderMaster where VoteListId=@VoteListId end else begin select *From ContenderMaster where id=@id and VoteListId=@VoteListId end GO /****** Object: StoredProcedure [dbo].[spFetchUpcomingVoteListForAdmin] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE proc [dbo].[spFetchUpcomingVoteListForAdmin] as select um.id,um.Name,vm.Title,vm.Detail,Convert(v archar(10),vm.StartDate,101) as StartDate,vm.EndDate,vm.id as voteId from VotingListMaster vm,UserMaster um where vm.UserId=um.id and vm.StartDate>=cast(getdate() as date) and vm.Status=0 GO /****** Object: StoredProcedure [dbo].[spFetchUser] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO

SET QUOTED_IDENTIFIER ON GO CREATE proc [dbo].[spFetchUser] ( @IsActive bit ) as if(@IsActive=0) begin select ROW_NUMBER()over (order by id ) as 'rowNumber',id,Name,Email,Contact,Address, IsActive from UserMaster where IsActive=0 end else begin select ROW_NUMBER()over (order by id ) as 'rowNumber',id,Name,Email,Contact,Address, IsActive from UserMaster where IsActive=1 end GO /****** Object: StoredProcedure [dbo].[spFetchVoteListForResult] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO create proc [dbo].[spFetchVoteListForResult] as select id,Title,Detail from VotingListMaster where StartDate=cast(getdate() as date) and Status=@Status and UserId=@UserID end else begin select *From VotingListMaster where id=@id and StartDate>=cast(getdate() as date)and Status=@Status and UserId=@UserID end GO /****** Object: StoredProcedure [dbo].[spFetchVotingListMasterById] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE proc [dbo].[spFetchVotingListMasterById] ( @id numeric(18,0) ) as select id,Title,Detail,Convert(varchar(10),StartDate,1 01)StartDate,Convert(varchar(10),EndDate,10 1)EndDate From VotingListMaster where id=@id and StartDate>=cast(getdate() as date)and Status=1 and IsActive=1 and id=@id

GO /****** Object: StoredProcedure [dbo].[spFetchVotingListMasterForVote] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE proc [dbo].[spFetchVotingListMasterForVote] ( @CatId numeric(18,0), @Mode char(1) ) as if(@Mode='1') begin select *From VotingListMaster where StartDate>=cast(getdate() as date) and Status=1 and IsActive=1 and CatId=@CatId end else begin select cm.id,cm.CategoryName, (select count(id) from VotingListMaster where StartDate>=cast(getdate() as date)and IsActive=1 and Status=0 and CatId=cm.id)as 'upComingList', (select count(id) from VotingListMaster where StartDate>=cast(getdate() as date)and IsActive=1 and Status=1 and CatId=cm.id)as 'activeList' from CategoryMaster cm where cm.IsActive=1 and cm.id=@CatId end GO /****** Object: StoredProcedure [dbo].[spFtechResultByVoteID] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE proc [dbo].[spFtechResultByVoteID] ( @VoteId numeric(18,0) )as select cm.Name,count(rm.ContenderId) TotalVote,cm.id from VotingListMaster vm,ResultMaster rm,ContenderMaster cm

where vm.id=rm.VotingId and cm.id=rm.ContenderId and vm.id=@VoteId group by cm.Name,cm.id,rm.ContenderId GO /****** Object: StoredProcedure [dbo].[spInsertCategoryMaster] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE Procedure [dbo].[spInsertCategoryMaster] ( @CategoryName varchar(1000) ) As Begin if not exists (select id from CategoryMaster where CategoryName=@CategoryName) begin INSERT INTO [dbo].[CategoryMaster] ( [CategoryName] ) VALUES ( @CategoryName ) select '1' End else select '0' End GO /****** Object: StoredProcedure [dbo].[spInsertContenderMaster] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO Create Procedure [dbo].[spInsertContenderMaster] ( @VoteListId numeric(18,0) ,@Name varchar(100) ,@Description varchar(1000) ,@Img image )

As Begin INSERT INTO [dbo].[ContenderMaster] ( [VoteListId] ,[Name] ,[Description] ,[Img] ) VALUES ( @VoteListId ,@Name ,@Description ,@Img ) End GO /****** Object: StoredProcedure [dbo].[spInsertResultMaster] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE Procedure [dbo].[spInsertResultMaster] ( @UserId numeric(18,0) ,@VotingId numeric(18,0) ,@ContenderId numeric(18,0) ,@Answer varchar(5000) ) As Begin if not exists(select id from ResultMaster where UserId=@UserId and VotingId=@VotingId) begin INSERT INTO [dbo].[ResultMaster] ( [UserId] ,[VotingId] ,[ContenderId] ,[Answer] ) VALUES ( @UserId ,@VotingId ,@ContenderId ,@Answer

) select '1' End else select '0' end GO /****** Object: StoredProcedure [dbo].[spInsertUserMaster] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE Procedure [dbo].[spInsertUserMaster] ( @Name varchar(100) ,@Email varchar(100) ,@Contact varchar(10) ,@Pwd varchar(100) ,@Address varchar(1000) ) As Begin if not exists (select id from UserMaster where Email=@Email) begin INSERT INTO [dbo].[UserMaster] ( [Name] ,[Email] ,[Contact] ,[Pwd] ,[Address] ) VALUES ( @Name ,@Email ,@Contact ,@Pwd ,@Address ) select '1' End else select '0' End GO /****** Object: StoredProcedure [dbo].[spInsertVotingListMaster] Script Date: 4/13/2016 7:04:47 PM ******/

SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO Create Procedure [dbo].[spInsertVotingListMaster] ( @UserId numeric(18,0) ,@CatId numeric(18,0) ,@Title varchar(1000) ,@Detail varchar(4000) ,@EndDate date ,@StartDate date ) As Begin INSERT INTO [dbo].[VotingListMaster] ( [UserId] ,[CatId] ,[Title] ,[Detail] ,[EndDate] ,[StartDate] ) VALUES ( @UserId ,@CatId ,@Title ,@Detail ,@EndDate ,@StartDate ) End GO /****** Object: StoredProcedure [dbo].[spUpdateCategoryMaster] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE Procedure [dbo].[spUpdateCategoryMaster] ( @id numeric(18,0) ,@CategoryName varchar(1000) ,@IsActive bit ) As Begin

if not exists (select id from CategoryMaster where CategoryName=@CategoryName and id!=@id) begin Update [dbo].[CategoryMaster] Set [CategoryName] = @CategoryName ,[IsActive] = @IsActive Where [id] = @id select '1' End else select '0' end GO /****** Object: StoredProcedure [dbo].[spUpdateUserMaster] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO Create Procedure [dbo].[spUpdateUserMaster] ( @id numeric(18,0) ,@IsActive bit ) As Begin Update [dbo].[UserMaster] Set [IsActive] = @IsActive Where [id] = @id End GO /****** Object: StoredProcedure [dbo].[spUpdateVotingListMaster] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO Create Procedure [dbo].[spUpdateVotingListMaster] ( @id numeric(18,0) ,@Status bit ) As Begin

Update [dbo].[VotingListMaster] Set [Status] = @Status Where [id] = @id End GO /****** Object: StoredProcedure [dbo].[spValidateUser] Script Date: 4/13/2016 7:04:47 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE proc [dbo].[spValidateUser] ( @Email varchar(1000), @Pwd varchar(1000) ) as if exists (select id from UserMaster where Email=@Email and Pwd=@Pwd and IsActive=1) begin select id,Name from UserMaster where Email=@Email and Pwd=@Pwd end else select '0' GO

Suggest Documents