protected void btnchangepass_Click(object sender, EventArgs e) { // DataTable StaffDT = StaffMst.Select_Current_Pass(txtcurrent.Text, Session["uname"].ToString()); DataRow StaffDr = StaffMst.GetNameandPassword(Session["uname"].ToString(), txtcurrent.Text); if (StaffDr != null) { StaffMst staffmst = new StaffMst(); staffmst.SID = Convert.ToInt32(StaffDr["SID"].ToString()); staffmst.StdName = StaffDr["StdName"].ToString(); staffmst.Qualification = StaffDr["StdName"].ToString(); staffmst.Pass = txtnewpass.Text; staffmst.Name = StaffDr["Name"].ToString(); staffmst.Mobile = StaffDr["Mobile"].ToString(); staffmst.Image = StaffDr["Image"].ToString(); staffmst.Pincode = StaffDr["PinCode"].ToString(); staffmst.Uname = StaffDr["Uname"].ToString(); staffmst.UpdateDataByKey(); lbl.Text = "Password Changed"; } else { lbl.Text = "Invalid Current Pass"; } }
protected void btnupdate_Click(object sender, EventArgs e) { try { StaffMst staff = new StaffMst(Convert.ToInt32(ViewState["sid"].ToString())); /// staff.SID = Convert.ToInt32(ViewState["sid"].ToString()); staff.StdName = txtadd.Text; staff.Email = txtemail.Text; staff.Mobile = txtmobile.Text; staff.Image = Imgprofile.ImageUrl.ToString(); staff.Pincode = txtpin.Text; staff.City = txtcity.Text; staff.UpdateDataByKey(); Response.Redirect("/Staff/Default.aspx", false); } catch (Exception ex) { lblcnt.Text = "Fail to update profile"; Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "fadeLabelOut()", true); } }
protected void btnadd_Click(object sender, EventArgs e) { try { DataTable StaffDT = StaffMst.Select_UNAME(txtuname.Text); if (string.IsNullOrEmpty(txtname.Text) || string.IsNullOrEmpty(txtemail.Text)) { lbl.Text = "Name and email can't be null !!"; Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "fadeLabelOut()", true); return; } if (string.IsNullOrEmpty(txtuname.Text) || string.IsNullOrEmpty(txtpass.Text)) { lbl.Text = "user name and and password can't be null !!"; Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "fadeLabelOut()", true); return; } else { StaffMst staff = new StaffMst(); staff.Name = txtname.Text; if (drpstd.SelectedIndex > 0) { staff.StdName = drpstd.SelectedItem.Text; staff.StdId = int.Parse(drpstd.SelectedValue); } staff.Email = txtemail.Text; staff.Mobile = txtmobile.Text; if (!string.IsNullOrEmpty(FileUpload1.FileName)) { FileUpload1.SaveAs(Server.MapPath("~/StaffImg/" + FileUpload1.FileName)); staff.Image = "~/StaffImg/" + FileUpload1.FileName; } staff.Qualification = txtqual.Text; staff.Pass = txtpass.Text; staff.Pincode = txtpin.Text; staff.Uname = txtuname.Text; staff.Add = txtadd.Text; staff.City = txtcity.Text; staff.Gender = DropDownList1.SelectedItem.Text; if (StaffId != null) { staff.SID = int.Parse(StaffId.ToString()); if (staff.UpdateDataByKey()) { lbl.Text = "Record updated Successfully"; Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "fadeLabelOut()", true); resret(); Response.Redirect("StaffReport.aspx", false); } } else { if (StaffDT != null && StaffDT.Rows.Count == 1) { lbl.Text = "UserName alredy exists !!"; Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "fadeLabelOut()", true); } staff.SID = StaffMst.GetNewSID(); staff.Insert(); lbl.Text = "Record Added Successfully"; Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "fadeLabelOut()", true); resret(); } } } catch (Exception ex) { lbl.Text = "Fail to Add record"; Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "fadeLabelOut()", true); } }