protected void Page_Load(object sender, EventArgs e) { if (Request.Cookies["UserCookie"] != null) { var Cookie = Request.Cookies["UserCookie"]; if (Cookie.Values["UserInfo"] != null) { txtcurrent.Text = DateTime.Now.ToString("yyyy-MM-ddTH:mm"); CompareDuedate.ValueToCompare = Convert.ToString(txtcurrent.Text); string userString = ClassHashing.basicDecryption(Cookie.Values["UserInfo"].ToString()); User user = ExpressPrintingSystem.Model.Entities.User.toUserObject(userString); txtcustomerID.Text = user.ID; string d = txtDueDate.Text; ViewState["UserID"] = ClassHashing.basicEncryption(user.ID); string detail = "Information" + "<br/>"; detail += "----------------------" + "<br />"; detail += "Non-Color" + "<br/>"; detail += "-----------" + "<br/>"; detail += "P1001 -" + "RM2.50 for Binding, Plastic cover and RM0.10 for non-color page" + "<br/>"; detail += "Color Page" + "<br/>"; detail += "-----------" + "<br/>"; detail += "P1002 -" + "RM2.50 for binding, Plastic cover and RM0.30 for color page" + "<br/>"; Label11.Text = detail; } } }
protected void gvStaffList_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Edit")) { //get selected index row int index = Convert.ToInt32(e.CommandArgument); GridViewRow selectedRow = gvStaffList.Rows[index]; string staffID = selectedRow.Cells[0].Text; Response.Redirect("editStaff.aspx?staffID=" + HttpUtility.UrlEncode(ClassHashing.basicEncryption(staffID))); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.Cookies["UserCookie"] != null) { var Cookie = Request.Cookies["UserCookie"]; if (Cookie.Values["UserInfo"] != null) { string userString = ClassHashing.basicDecryption(Cookie.Values["UserInfo"].ToString()); User user = ExpressPrintingSystem.Model.Entities.User.toUserObject(userString); ViewState["UserID"] = ClassHashing.basicEncryption(user.ID); SqlConnection conTaxi; string connStr = ConfigurationManager.ConnectionStrings["printDBServer"].ConnectionString; conTaxi = new SqlConnection(connStr); conTaxi.Open(); string strCheck; SqlCommand cmdCheck; strCheck = "Select CustomerName, CustomerEmail, CustomerDOB, CustomerPhoneNo, CustomerContactMethod from Customer Where CustomerID=@CustomerID"; cmdCheck = new SqlCommand(strCheck, conTaxi); cmdCheck.Parameters.AddWithValue("@CustomerID", user.ID); SqlDataReader dtr; dtr = cmdCheck.ExecuteReader(); if (dtr.Read()) { string CustomerName = dtr["CustomerName"].ToString(); string customeremail = dtr["CustomerEmail"].ToString(); DateTime customerdob = Convert.ToDateTime(dtr["CustomerDOB"]); string customerphoneno = dtr["CustomerPhoneNo"].ToString(); string customercontmethod = dtr["CustomerContactMethod"].ToString(); txtName.Text = CustomerName; txtEmail.Text = customeremail; customerDOB.Text = Convert.ToString(customerdob); txtPhoNo.Text = customerphoneno; rbtContMet.SelectedValue = customercontmethod; } conTaxi.Close(); } } } }
private void rememberMe() { if (CheckBox1.Checked) { var rememberUser = new HttpCookie("me"); rememberUser.Value = ClassHashing.basicEncryption(txtname.Text.Trim()); Response.Cookies.Add(rememberUser); } else { if (Request.Cookies["me"] != null) { Request.Cookies["me"].Expires = DateTime.Now.AddDays(-1); } } }
protected void Page_Load(object sender, EventArgs e) { if (Request.Cookies["UserCookie"] != null) { var Cookie = Request.Cookies["UserCookie"]; if (Cookie.Values["UserInfo"] != null) { string userString = ClassHashing.basicDecryption(Cookie.Values["UserInfo"].ToString()); User user = ExpressPrintingSystem.Model.Entities.User.toUserObject(userString); ViewState["UserID"] = ClassHashing.basicEncryption(user.ID); bindData(); } } }
private string getReportUrl() { string url = null; switch (ddlReportName.SelectedValue) { case SALES_REPORT: DateTime startingDate = new DateTime(), endingDate = new DateTime(); switch (rblPeriod.SelectedValue) { case "Daily": string[] dailyString = txtDaily.Text.Split('-'); startingDate = new DateTime(Convert.ToInt32(dailyString[0]), Convert.ToInt32(dailyString[1]), Convert.ToInt32(dailyString[2])); endingDate = new DateTime(Convert.ToInt32(dailyString[0]), Convert.ToInt32(dailyString[1]), Convert.ToInt32(dailyString[2])); break; case "Monthly": string[] monthlyString = txtMonthly.Text.Split('-'); startingDate = new DateTime(Convert.ToInt32(monthlyString[0]), Convert.ToInt32(monthlyString[1]), 1); endingDate = new DateTime(Convert.ToInt32(monthlyString[0]), Convert.ToInt32(monthlyString[1]), DateTime.DaysInMonth(Convert.ToInt32(monthlyString[0]), Convert.ToInt32(monthlyString[1])), 23, 59, 59); break; case "Yearly": string[] yearlyString = txtYearly.Text.Split('-'); startingDate = new DateTime(Convert.ToInt32(yearlyString[0]), 1, 1); endingDate = new DateTime(Convert.ToInt32(yearlyString[0]), 12, 31, 23, 59, 59); break; case "Custom": string[] dateFromString = txtDateFrom.Text.Split('-'); string[] dateToString = txtDateTo.Text.Split('-'); startingDate = new DateTime(Convert.ToInt32(dateFromString[0]), Convert.ToInt32(dateFromString[1]), Convert.ToInt32(dateFromString[2])); endingDate = new DateTime(Convert.ToInt32(dateToString[0]), Convert.ToInt32(dateToString[1]), Convert.ToInt32(dateToString[2])); break; } url = SaleReportUrl + "?StartDate=" + HttpUtility.UrlEncode(ClassHashing.basicEncryption(startingDate.ToString("dd/MM/yyyy"))) + "&EndDate=" + HttpUtility.UrlEncode(ClassHashing.basicEncryption(endingDate.ToString("dd/MM/yyyy"))) + "&ReportType=" + HttpUtility.UrlEncode(ClassHashing.basicEncryption(rblPeriod.SelectedValue)); break; case STOCK_REMAIN_REPORT: url = StockReportUrl + "?QuantityUnder=" + HttpUtility.UrlEncode(ClassHashing.basicEncryption(txtStock.Text)); break; } return(url); }
public string getDocumentViewerUrl(object requestlistID, object documentID) { return(String.Format("ViewDocument.aspx?documentID={0}&requestlistid={1}", HttpUtility.UrlEncode(ClassHashing.basicEncryption((string)documentID)), HttpUtility.UrlEncode(ClassHashing.basicEncryption((string)requestlistID)))); }
protected void btnSubmit_Click(object sender, EventArgs e) { string roles; string username = txtname.Text.Trim(); string password = txtPassword.Text.Trim(); string toggleOption = toggleBtn_optionSelected(); var myCookie = new HttpCookie("UserCookie"); //instantiate an new cookie and give it a name myCookie.Values.Add("SignInType", ClassHashing.basicEncryption(toggleOption)); //populate it with key, value pairs myCookie.Expires = DateTime.Now.AddMinutes(481); try { if (UserVerification.verifyUser(username, password, toggleOption)) { //These session values are just for demo purpose to show the user details on master page roles = UserVerification.GetUserRoles(username, toggleOption); User user = UserVerification.getUserBasicInfo(username, toggleOption); myCookie.Values.Add("UserInfo", ClassHashing.basicEncryption(ExpressPrintingSystem.Model.Entities.User.toCompactString(user))); Response.Cookies.Add(myCookie); setCompanyCookie(toggleOption, user.ID); //Let us now set the authentication cookie so that we can use that later. FormsAuthentication.SetAuthCookie(username, false); //Login successful lets put him to requested page string returnUrl = Request.QueryString["ReturnUrl"] as string; rememberMe(); if (returnUrl != null) { Response.Redirect(returnUrl); } else { if (toggleOption.Equals("Staff")) { Response.Redirect("~/Staff/Printing/viewPrintingRequest.aspx"); } else { Response.Redirect("~/masterPageTest.aspx"); } } } else if (UserVerification.isActivatedUser(username, toggleOption)) { Response.Write("<script LANGUAGE='JavaScript' >alert('Your account is not activated, please check your social media for account activation link.')</script>"); Response.Cookies.Add(myCookie); } else { Response.Write("<script LANGUAGE='JavaScript' >alert('Login Failed')</script>"); Response.Cookies.Add(myCookie); } } catch (Exception ex) { Response.Write("<script LANGUAGE='JavaScript' >alert('Your username or password is invalid.')</script>"); Response.Cookies.Add(myCookie); } }
public static string getEditPackageUrl(string packageID) { return(String.Format("EditPackage.aspx?PackageID={0}", HttpUtility.UrlEncode(ClassHashing.basicEncryption(packageID)))); }