//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void FillObject() { try { ProClass.DateType = FormSession.DateType; ProClass.EmpID = txtEmpid.Text; ProClass.RegVehicle = txtRegVehicle.Text; ProClass.Owner = txtOwner.Text; ProClass.CarType = txtCarType.Text; ProClass.Model = txtModel.Text; ProClass.Color = txtColor.Text; ProClass.StartDate = calStartdate.getDate(); ProClass.ExpiryDate = calEnddate.getDate(); ProClass.TransactionBy = FormSession.LoginUsr; ProClass.TransactionDate = DateTime.Now.ToShortDateString(); if (ddlCompID.SelectedIndex > 0) { ProClass.CompID = Convert.ToInt32(ddlCompID.SelectedItem.Value); } if (ddlTemplate.SelectedIndex > 0) { ProClass.TemplateID = Convert.ToInt32(ddlTemplate.SelectedItem.Value); } } catch (Exception EX) { DBFun.InsertError(FormSession.PageName, "FillObject()"); MessageFun.ShowAdminMsg(this, EX.Message); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void Page_Load(object sender, EventArgs e) { try { // --------------------Common Code ----------------------------------------------------------------- // FormSession.FillSession("Employees", pageDiv); // --------------------Common Code ----------------------------------------------------------------- // if (!IsPostBack) { if (!FormSession.getPerm("FPVerify")) { Response.Redirect(@"~/Login.aspx"); } MainMasterPage.ShowTitel(General.Msg("Fingerprint verification", "التحقق بالبصمة")); hfdConnStr.Value = ConfigurationManager.ConnectionStrings["constring"].ConnectionString.Replace("\\", "...."); hfdLoginUser.Value = FormSession.LoginUsr.Replace("\\", "...."); hfdLang.Value = FormSession.Language; string ID = hfdConnStr.Value + "," + hfdLoginUser.Value + "," + hfdLang.Value; ClientScript.RegisterStartupScript(this.GetType(), "key", "javascript:Connect('" + ID + "');", true); } } catch (Exception e1) { DBFun.InsertError(FormSession.PageName, "PageLoad"); } }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void FillPropetiesObject() { try { ProClass.DateType = FormSession.DateType; ProClass.IsID = Convert.ToInt16(ddlIssue.SelectedValue); ProClass.CardStatus = ddlCardstatus.SelectedValue; ProClass.InActiveStatus = "0"; ProClass.IsApproved = 0; ProClass.isPrinted = false; ProClass.CardCount = FindCount(txtEmpID.Text) + 1; ProClass.Description = txtDescription.Text; ProClass.StartDate = calStartDate.getDate(); ProClass.ExpiryDate = calEndDate.getDate(); ProClass.TransactionBy = FormSession.LoginUsr; ProClass.TransactionDate = DateTime.Now.ToShortDateString(); if (!string.IsNullOrEmpty(txtEmpID.Text)) { ProClass.EmpID = txtEmpID.Text.Trim(); } if (ddlTemplate.SelectedIndex > 0) { ProClass.TmpID = Convert.ToInt16(ddlTemplate.SelectedValue); } } catch (Exception Ex) { DBFun.InsertError(FormSession.PageName, "FillPropetiesObject()"); MessageFun.ShowAdminMsg(this, Ex.Message); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void btnSave_Click(object sender, EventArgs e) { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); if (!Page.IsValid) { ValidatorCollection ValidatorColl = Page.Validators; for (int k = 0; k < ValidatorColl.Count; k++) { if (!ValidatorColl[k].IsValid && !String.IsNullOrEmpty(ValidatorColl[k].ErrorMessage)) { vsSave.ShowSummary = true; return; } vsSave.ShowSummary = false; } return; } try { FillPropeties(); SqlClass.InsertUpdate(ProClass); MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg("institution Setting saved successfully", "تم حفظ إعدادات المنشأة")); ClearUI(); } catch (Exception Ex) { DBFun.InsertError(FormSession.PageName, "btnSave"); MessageFun.ShowAdminMsg(this, Ex.Message); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public string FindCount(string pID) { try { string count = "0"; DataTable CountDT = DBFun.FetchData("SELECT COUNT(VisCardID) count FROM VisitorsCard WHERE isPrinted = 'True' AND VisIdentityNo = '" + pID + "'"); if (DBFun.IsNullOrEmpty(CountDT)) { } else { if (Convert.ToInt32(CountDT.Rows[0]["count"]) > 0) { count = CountDT.Rows[0]["count"].ToString(); } } return(count); } catch (Exception e1) { DBFun.InsertError(FormSession.PageName, "FindCount"); return("0"); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public bool FindActiveCard(string pID) { try { bool isActive = false; DataTable DT = DBFun.FetchData("SELECT COUNT(VisCardID) count FROM VisitorsCard WHERE CardStatus = 2 AND ExpiryDate > GETDATE() AND VisIdentityNo = '" + pID + "'"); if (DBFun.IsNullOrEmpty(DT)) { } else { if (Convert.ToInt32(DT.Rows[0]["count"]) > 0) { isActive = true; } } return(isActive); } catch (Exception e1) { DBFun.InsertError(FormSession.PageName, "FindActiveCard"); return(false); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void PopulateUI(string pID) { try { if ((btnSave.Text == "Update") || (btnSave.Text == "تعديل")) { DataTable myTableDT = DBFun.FetchData("SELECT * FROM EmployeeMaster WHERE EmpID = '" + pID + "' AND EmpType = '" + ddlEmpType.SelectedValue + "' "); if (DBFun.IsNullOrEmpty(myTableDT)) { ButtonAction("00", true); MessageFun.ShowMsg(this, vsSearch, cvShowMsg, MessageFun.TypeMsg.Warning, "vgSearch", General.Msg("This employee No part of " + GetNameType(Request.QueryString["ac"].ToString()), "الموظف غير موجود ضمن " + GetNameType(Request.QueryString["ac"].ToString()))); return; } FillFromDT(myTableDT); } txtEmpIdentity.Text = txtIDSearch.Text; ButtonAction("11", false); DataItemEnabled(true); } catch (Exception Ex) { DBFun.InsertError(FormSession.PageName, "PopulateUI"); MessageFun.ShowAdminMsg(this, Ex.Message); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void btnUpdate_Click(object sender, EventArgs e) { try { if (!Page.IsValid) { ValidatorCollection ValidatorColl = Page.Validators; for (int k = 0; k < ValidatorColl.Count; k++) { if (!ValidatorColl[k].IsValid && !String.IsNullOrEmpty(ValidatorColl[k].ErrorMessage)) { vsSave.ShowSummary = true; return; } vsSave.ShowSummary = false; } return; } AppPro.UsrLoginID = FormSession.LoginUsr; AppPro.UsrPassword = CryptorEngine.Encrypt(txtNewpassword.Text, true); AppPro.TransactionBy = FormSession.LoginUsr; AppSql.UpdatePassword(AppPro); ClearUI(); MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg("Password updated successfully", "تم تعديل كلمة المرور بنجاح")); } catch (Exception Ex) { DBFun.InsertError(FormSession.PageName, "btnSave"); MessageFun.ShowAdminMsg(this, Ex.Message); } }
/*******************************************************************************************************************************/ /*******************************************************************************************************************************/ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /*******************************************************************************************************************************/ /*******************************************************************************************************************************/ #region ButtonAction Events protected void btnSave_Click(object sender, EventArgs e) { try { if (!Page.IsValid) { ValidatorCollection ValidatorColl = Page.Validators; for (int k = 0; k < ValidatorColl.Count; k++) { if (!ValidatorColl[k].IsValid && !String.IsNullOrEmpty(ValidatorColl[k].ErrorMessage)) { vsSave.ShowSummary = true; return; } vsSave.ShowSummary = false; } return; } string Action = ViewState["CommandName"].ToString(); FillPropeties(); SqlCs.InsertUpdate(ProCs); ClearItem(); PopulateUI(); ViewState["CommandName"] = "NOT"; MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg("Save Data successfully", "تم الحفظ البيانات بنجاح")); } catch (Exception Ex) { DBFun.InsertError(FormSession.PageName, "btnSave"); MessageFun.ShowAdminMsg(this, Ex.Message); } }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void PopulateImage(string ID) { try { dt = (DataTable)DBFun.FetchData("SELECT * FROM TempImage WHERE Type = '" + Type + "' AND EmpID='" + ID + "'"); if (DBFun.IsNullOrEmpty(dt)) { if (imgPhoto.ImageUrl != EmptyImage()) { string ImagePath = FindTempImagePath() + ID + ".jpeg"; imgPhoto.ImageUrl = ImagePath; if (!File.Exists(ImagePath)) { setImage(ID); } return; } else { imgPhoto.ImageUrl = EmptyImage(); return; } } imgPhoto.ImageUrl = "~/Images/Pages/ReadImage.aspx?Type=" + Type + "Tmp&ID=" + ID + ""; } catch (Exception e1) { DBFun.InsertError("Image", "PopulateImage()"); } }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void Page_Load(object sender, EventArgs e) { try { // --------------------Common Code ----------------------------------------------------------------- // FormSession.FillSession("Employees", pageDiv); // --------------------Common Code ----------------------------------------------------------------- // if (!IsPostBack) { txtEmpIDSearch.Enabled = FormSession.getPerm("VFPEmp"); btnSearchDetails.Enabled = FormSession.getPerm("VFPEmp"); MainMasterPage.ShowTitel(General.Msg("Employees FingerPrint", "بصمات الموظفين")); if (FormSession.getPerm("VFPEmp")) { hfdConnStr.Value = ConfigurationManager.ConnectionStrings["constring"].ConnectionString.Replace("\\", "...."); hfdLoginUser.Value = FormSession.LoginUsr.Replace("\\", "...."); hfdLang.Value = FormSession.Language; string ID = hfdConnStr.Value + "," + hfdLoginUser.Value + "," + hfdLang.Value; ClientScript.RegisterStartupScript(this.GetType(), "key", "javascript:Connect('" + ID + "');", true); } } } catch (Exception e1) { DBFun.InsertError(FormSession.PageName, "PageLoad"); } }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void PopulateUpdate(string EmpID) { try { string selectQ = " SELECT CardID,EmpID,EmpNameEn,EmpNameAr,IsID,IsNameEn,IsNameAr,StartDate,ExpiryDate,Description " + ",CreatedBy,CreatedDate,CardStatus,TmpID,CardCount " + " FROM CardInfoView " + " WHERE CardStatus = 0 AND EmpID = '" + EmpID + "' ORDER BY CardID DESC"; DataTable Empdt = DBFun.FetchData(selectQ); if (DBFun.IsNullOrEmpty(Empdt)) { return; } txtEmpID.Text = EmpID; txtEmpNameEn.Text = Empdt.Rows[0]["EmpNameEn"].ToString(); txtEmpNameAr.Text = Empdt.Rows[0]["EmpNameAr"].ToString(); ddlIssue.SelectedIndex = ddlIssue.Items.IndexOf(ddlIssue.Items.FindByValue(Empdt.Rows[0]["IsID"].ToString())); txtCardCount.Text = Empdt.Rows[0]["CardCount"].ToString(); DataTable Condt = DBFun.FetchData("SELECT * FROM CardCondition WHERE ConditionType = 'Card' AND CardID = " + Empdt.Rows[0]["CardID"].ToString() + ""); if (!DBFun.IsNullOrEmpty(Condt)) { divCondition1.Visible = true; divCondition2.Visible = true; for (int i = 0; i < Condt.Rows.Count; i++) { ListItem li = new ListItem(Condt.Rows[i]["ConditionName"].ToString(), Condt.Rows[i]["ConditionID"].ToString()); cblConditions.Items.Add(li); cblConditions.Items[i].Selected = Convert.ToBoolean(Condt.Rows[i]["ConditionStatus"]); } } else { divCondition1.Visible = false; divCondition2.Visible = false; } ddlTemplate.SelectedIndex = ddlTemplate.Items.IndexOf(ddlTemplate.Items.FindByValue(Empdt.Rows[0]["TmpID"].ToString())); ddlCardstatus.SelectedIndex = ddlCardstatus.Items.IndexOf(ddlCardstatus.Items.FindByValue(Empdt.Rows[0]["CardStatus"].ToString())); if (Empdt.Rows[0]["StartDate"] != DBNull.Value) { calStartDate.setDBDate(Empdt.Rows[0]["StartDate"], "S"); } if (Empdt.Rows[0]["ExpiryDate"] != DBNull.Value) { calEndDate.setDBDate(Empdt.Rows[0]["ExpiryDate"], "S"); } txtDescription.Text = Empdt.Rows[0]["Description"].ToString(); } catch (Exception Ex) { DBFun.InsertError(FormSession.PageName, "PopulateUI"); MessageFun.ShowAdminMsg(this, Ex.Message); } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void btnSave_Click(object sender, EventArgs e) { if (!Page.IsValid) { ValidatorCollection ValidatorColl = Page.Validators; for (int k = 0; k < ValidatorColl.Count; k++) { if (!ValidatorColl[k].IsValid && !String.IsNullOrEmpty(ValidatorColl[k].ErrorMessage)) { vsSave.ShowSummary = true; return; } vsSave.ShowSummary = false; } return; } try { FillPropeties(); if (ViewState["CommandName"].ToString() == "Save") { SqlCs.Insert(ProCs); MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg("Save Data successfully", "تم الحفظ بنجاح")); } if (ViewState["CommandName"].ToString() == "Update") { SqlCs.Update(ProCs); MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg("Save Data successfully", "تم الحفظ بنجاح")); } if (ViewState["CommandName"].ToString() == "Delete") { //string Q = " SELECT NatID FROM EmployeeMaster WHERE NatID = " + ddlPkID.SelectedValue + " " // + " UNION " // + " SELECT NatID FROM BlackList WHERE NatID = " + ddlPkID.SelectedValue + " "; //dt = DBFun.FetchData(Q); //if (!DBFun.IsNullOrEmpty(dt)) //{ // MessageFun.ShowMsg(this, MessageFun.TypeMsg.Error, General.Msg("Deletion can not because of the presence of related records", "لا يمكن الحذف بسبب وجود سجلات مرتبطة")); //} //else //{ SqlCs.Delete(ProCs); MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg("deleted Data successfully", "تم الحذف بنجاح")); //} } } catch (Exception Ex) { DBFun.InsertError(FormSession.PageName, "btnSave"); MessageFun.ShowAdminMsg(this, Ex.Message); } ClearUI(); Fillddl(); FillGrid(); }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void Page_Load(object sender, EventArgs e) { try { // --------------------Common Code ----------------------------------------------------------------- // FormSession.FillSession("Config", pageDiv); FillGrid(); // --------------------Common Code ----------------------------------------------------------------- // if (!IsPostBack) { if (Request.QueryString["ac"] != null) { if (Request.QueryString["ac"].ToString() == "i") { if (!FormSession.PermUsr.Contains("I" + MainPer)) { Response.Redirect(@"~/Login.aspx"); } btnSave.Enabled = FormSession.PermUsr.Contains("I" + MainPer); ViewState["CommandName"] = "Save"; btnSave.Text = General.Msg("Save", "حفظ"); MainMasterPage.ShowTitel(General.Msg("Add " + MainNameEn, "إضافة " + MainName1Ar)); divUpdDel.Visible = false; } if (Request.QueryString["ac"].ToString() == "u") { if (!FormSession.PermUsr.Contains("U" + MainPer)) { Response.Redirect(@"~/Login.aspx"); } btnSave.Enabled = FormSession.PermUsr.Contains("U" + MainPer); ViewState["CommandName"] = "Update"; btnSave.Text = General.Msg("Update", "تعديل"); MainMasterPage.ShowTitel(General.Msg("Update " + MainNameEn, "تعديل " + MainName1Ar)); divUpdDel.Visible = true; Fillddl(); } if (Request.QueryString["ac"].ToString() == "d") { if (!FormSession.PermUsr.Contains("D" + MainPer)) { Response.Redirect(@"~/Login.aspx"); } btnSave.Enabled = FormSession.PermUsr.Contains("D" + MainPer); ViewState["CommandName"] = "Delete"; btnSave.Text = General.Msg("Delete", "حذف"); MainMasterPage.ShowTitel(General.Msg("Delete " + MainNameEn, "حذف " + MainName1Ar)); divUpdDel.Visible = true; Fillddl(); } } } } catch (Exception EX) { DBFun.InsertError(FormSession.PageName, "PageLoad"); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void Page_Load(object sender, EventArgs e) { try { //---Common Code ----------------------------------------------------------------- // FormSession.FillSession("Visitors", pageDiv); //---Common Code ----------------------------------------------------------------- // if (!IsPostBack) { pnlMain.Attributes.Add("onkeypress", "javascript:return DefaultButton(event,'" + btnIDSearch.ClientID + "');"); if (Request.QueryString["ID"] == null) { Response.Redirect(@"~/Login.aspx"); } ViewState["VisIdentityNo"] = ""; ViewState["Action"] = ""; ButtonAction("00", true); //ddlTmpID.Enabled = false; //VisImage.EnabledImage(false); if (Request.QueryString["ID"].ToString() == "i") { MainMasterPage.ShowTitel(General.Msg("Add " + MainNameEn + " Card", "إضافة بطاقة " + MainName1Ar)); if (!FormSession.PermUsr.Contains("IVis")) { Response.Redirect(@"~/Login.aspx"); } ViewState["Action"] = "A"; btnSave.Enabled = btnCancel.Enabled = false; Fillddl(); } if (Request.QueryString["ID"].ToString() == "u") { MainMasterPage.ShowTitel(General.Msg("Update " + MainNameEn + " Card", "تعديل بطاقة " + MainName1Ar)); if (!FormSession.PermUsr.Contains("UVis")) { Response.Redirect(@"~/Login.aspx"); } ViewState["Action"] = "U"; btnSave.Enabled = btnCancel.Enabled = false; Fillddl(); } ddlTmpID.Enabled = false; } if (IsPostBack) { VisImage.PopulateImage(txtVisIdentityNo.Text); } } catch (Exception ex) { DBFun.InsertError(FormSession.PageName, "PageLoad"); } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void btnSave_Click(object sender, EventArgs e) { if (!Page.IsValid) { ValidatorCollection ValidatorColl = Page.Validators; for (int k = 0; k < ValidatorColl.Count; k++) { if (!ValidatorColl[k].IsValid && !String.IsNullOrEmpty(ValidatorColl[k].ErrorMessage)) { vsSave.ShowSummary = true; return; } vsSave.ShowSummary = false; } return; } try { FillPropeties(); if (ViewState["CommandName"].ToString() == "Save") { SqlClass.RoleInsert(ProClass); MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg(MainNameEn + " added successfully", "تمت إضافة " + MainName2Ar + " بنجاح")); } if (ViewState["CommandName"].ToString() == "Update") { SqlClass.RoleUpdate(ProClass); MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg(MainNameEn + " updated successfully", "تم تعديل " + MainName2Ar + " بنجاح")); } if (ViewState["CommandName"].ToString() == "Delete") { //dt = DBFun.FetchData("SELECT BrcID FROM CollegesFaculty WHERE BrcID = " + ddlPkID.SelectedValue); //if (!DBFun.IsNullOrEmpty(dt)) if (txtRoleNameEn.Text == "admin" || txtRoleNameAr.Text == "مدير النظام") { MessageFun.ShowMsg(this, MessageFun.TypeMsg.Error, General.Msg("You can not delete a Role the system administrator", "لا يمكن حذف مجموعة صلاحيات مدير النظام")); //MessageFun.ShowMsg(this, MessageFun.TypeMsg.Error, General.Msg("Deletion can not because of the presence of related records", "لا يمكن الحذف بسبب وجود سجلات مرتبطة")); } else { SqlClass.RoleDelete(ProClass); MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg(MainNameEn + " deleted successfully", "تم حذف " + MainName2Ar + " بنجاح")); } } ClearUI(); Fillddl(); } catch (Exception Ex) { DBFun.InsertError(FormSession.PageName, "btnSaveDelete"); MessageFun.ShowAdminMsg(this, Ex.Message); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void btnSave_Click(object sender, EventArgs e) { if (!Page.IsValid) { ValidatorCollection ValidatorColl = Page.Validators; for (int k = 0; k < ValidatorColl.Count; k++) { if (!ValidatorColl[k].IsValid && !String.IsNullOrEmpty(ValidatorColl[k].ErrorMessage)) { vsSave.ShowSummary = true; return; } vsSave.ShowSummary = false; } return; } try { FillPropeties(); if (ViewState["CommandName"].ToString() == "Save") { SqlClass.Insert(ProClass); MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg(MainNameEn + " added successfully", "تمت إضافة " + MainName2Ar + " بنجاح")); } if (ViewState["CommandName"].ToString() == "Update") { SqlClass.Update(ProClass); MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg(MainNameEn + " updated successfully", "تم تعديل " + MainName2Ar + " بنجاح")); } if (ViewState["CommandName"].ToString() == "Delete") { dt = DBFun.FetchData("SELECT CompID FROM EmployeeMaster WHERE CompID = " + ddlPkID.SelectedValue); if (!DBFun.IsNullOrEmpty(dt)) { MessageFun.ShowMsg(this, MessageFun.TypeMsg.Error, General.Msg("Deletion can not because of the presence of related records", "لا يمكن الحذف بسبب وجود سجلات مرتبطة")); } else { SqlClass.Delete(ProClass); MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg(MainNameEn + " deleted successfully", "تم حذف " + MainName2Ar + " بنجاح")); } } ClearUI(); Fillddl(); FillGrid(); } catch (Exception Ex) { DBFun.InsertError(FormSession.PageName, "btnSave"); MessageFun.ShowAdminMsg(this, Ex.Message); } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void btnSave_Click(object sender, EventArgs e) { try { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); if (!Page.IsValid) { ValidatorCollection ValidatorColl = Page.Validators; for (int k = 0; k < ValidatorColl.Count; k++) { if (!ValidatorColl[k].IsValid && !String.IsNullOrEmpty(ValidatorColl[k].ErrorMessage)) { vsSave.ShowSummary = true; return; } vsSave.ShowSummary = false; } return; } if ((btnSave.Text == "Save") || (btnSave.Text == "حفظ")) { ProClass.Printed = false; ProClass.Status = 1; FillObject(); SqlClass.Insert(ProClass); MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg("Sticker details added successfully", "تم اضافة بيانات الملصق بنجاح")); } //if ((btnSave.Text == "Update") || (btnSave.Text == "تعديل")) //{ // ProClass.StickerID = ; // ProClass.ModifiedBy = userName; // ProClass.ModifiedDate = DateTime.Now.ToShortDateString(); // ProClass.Printed = false; // ProClass.Status = true; // ProClass.ExceptionReq = Convert.ToBoolean(ViewState["checkStick"]); // FillObject(); // SqlClass.Update(ProClass); // MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg("Sticker details updated successfully", "تم تعديل بيانات الملصق بنجاح")); // ViewState["checkStick"] = "False"; //} FillGrid(txtIDSearch.Text.Trim()); ClearUI(); } catch (Exception EX) { DBFun.InsertError(FormSession.PageName, "btnSave"); MessageFun.ShowAdminMsg(this, EX.Message); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void Page_Load(object sender, EventArgs e) { try { //---Common Code ----------------------------------------------------------------- // FormSession.FillSession("Employees", pageDiv); //---Common Code ----------------------------------------------------------------- // if (!IsPostBack) { pnlMain.Attributes.Add("onkeypress", "javascript:return DefaultButton(event,'" + btnIDSearch.ClientID + "');"); if (!FormSession.getPerm(new string[] { "IMng", "UMng", "IEmp", "UEmp", "ICon", "UCon" })) { Response.Redirect(@"~/Login.aspx"); } if (Request.QueryString["ac"] != null) { string ac = Request.QueryString["ac"].ToString(); ViewState["ac"] = ac; if (ac == "View") { //if (!FormSession.getPerm("UMng")) { btnSave.Enabled = false; btnIDSearch.Enabled = false; } string iEmpID = Request.QueryString["EmpID"].ToString(); divContract.Visible = true; divSection.Visible = true; DataItemEnabled(false); Fillddl(); btnIDSearch.Enabled = btnUploadDoc.Enabled = false; if (Request.QueryString["EmpID"] != null) { DataTable EmpDT = DBFun.FetchData("SELECT * FROM EmployeeMaster WHERE EmpID = '" + iEmpID + "' "); FillGrdDocs(EmpDT.Rows[0]["EmpNationalID"].ToString()); if (!DBFun.IsNullOrEmpty(EmpDT)) { ddlEmpType.SelectedIndex = ddlEmpType.Items.IndexOf(ddlEmpType.Items.FindByValue(EmpDT.Rows[0]["EmpType"].ToString())); FillFromDT(EmpDT); } } } } } if (IsPostBack) { EmpImage.PopulateImage(txtEmpNationalID.Text); } } catch (Exception e1) { DBFun.InsertError(FormSession.PageName, "PageLoad"); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void grdDocs_RowCommand(object sender, GridViewCommandEventArgs e) { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); try { switch (e.CommandName) { case ("Doc_Download"): { string DocPath = e.CommandArgument.ToString(); string filePath = Server.MapPath(@"../Import/EmployeesFiles/") + DocPath; string[] fileNameArr = DocPath.Split('\\'); string fileName = fileNameArr[fileNameArr.Length - 1]; HttpResponse res = HttpContext.Current.Response; res.Clear(); res.AppendHeader("content-disposition", "attachment; filename=" + fileName); res.ContentType = "application/octet-stream"; res.WriteFile(filePath); res.Flush(); res.End(); break; } case ("Doc_Delete"): { string[] Arg = e.CommandArgument.ToString().Split(';'); string DocID = Arg[0]; string DocPath = Arg[1]; ProClass.DocID = DocID; ProClass.TransactionBy = FormSession.LoginUsr; SqlClass.Docs_Delete(ProClass); string Path = Server.MapPath(@"../Import/EmployeesFiles/") + DocPath; if (File.Exists(Path)) { File.Delete(Path); } FillGrdDocs(txtEmpNationalID.Text); break; } } } catch (Exception Ex) { DBFun.InsertError(FormSession.PageName, "grdDocs_RowCommand"); MessageFun.ShowAdminMsg(this, Ex.Message); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void UserLogin() { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); string loginDate = DateTime.Now.ToString("dd/MM/yyyy"); Session["Permissions"] = null; StringBuilder Q = new StringBuilder(); Q.Append("SELECT * FROM AppUsers WHERE UsrStatus = '1' AND UsrLoginID = @P1 "); if (txtLoginID.Text != "admin") { Q.Append(" AND GETDATE() BETWEEN UsrStartDate AND UsrExpireDate "); } DataTable dt = DBFun.FetchData(Q.ToString(), new string[] { txtLoginID.Text }); if (!DBFun.IsNullOrEmpty(dt)) { if (dt.Rows[0]["UsrPassword"].ToString() == txtPassword.Text) //CryptorEngine.Decrypt("", true) { try { Session["UserName"] = txtLoginID.Text; Session["Permissions"] = CryptorEngine.Decrypt(dt.Rows[0]["UsrPermission"].ToString(), true); //Session["Permissions"] = dt.Rows[0]["UsrPermission"].ToString(); Session["PreferedCulture"] = "en-US"; Session["Language"] = dt.Rows[0]["UsrLanguage"].ToString(); Session["Role"] = "User"; Session["MyTheme"] = "Theme" + Session["Language"].ToString(); string url = InfoTab.FindFirstTab(); //@"~/pages/SettingMachine.aspx"; //MachinePing.aspx"; //InfoTab.FindFirstTab(); //@"~/pages/MachinePing.aspx";// if (!string.IsNullOrEmpty(url)) { Response.Redirect(url, false); } else { MessageFun.ShowMsg(this, MessageFun.TypeMsg.Error, General.Msg("You do not have access,Please contact the Administrator", "لا يمكنك الدخول,الرجاء مراجعة مدير النظام")); } return; } catch (Exception e1) { DBFun.InsertError("Login.aspx", "UserLogin"); } } } MessageFun.ShowMsg(this, MessageFun.TypeMsg.Error, General.Msg("You do not have access,Please contact the Administrator", "لا يمكنك الدخول,الرجاء مراجعة مدير النظام")); }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void PopulateUI() { try { txtEmployeeID.Text = ViewState["EmpID"].ToString(); txtEmpName.Text = ViewState["EmpName"].ToString(); ButtonAction("11", false); } catch (Exception Ex) { DBFun.InsertError(FormSession.PageName, "PopulateUI"); MessageFun.ShowAdminMsg(this, Ex.Message); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /*#############################################################################################################################*/ /*#############################################################################################################################*/ #region grdDocs Events protected void btnUploadDoc_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtEmpNationalID.Text)) { MessageFun.ShowMsg(this, MessageFun.TypeMsg.Validation, General.Msg("Please enter the National ID", "يجب إدخال رقم الهوية")); return; } if (string.IsNullOrEmpty(txtDocName.Text)) { MessageFun.ShowMsg(this, MessageFun.TypeMsg.Validation, General.Msg("Please enter the Document Name", "يجب إدخال اسم المستند")); return; } if (fuDocs.PostedFile != null && fuDocs.PostedFile.FileName != "") { string dateFile = String.Format("{0:ddMMYyyyyHHmmss}", DateTime.Now); string FileName = System.IO.Path.GetFileName(fuDocs.PostedFile.FileName); string[] nameArr = FileName.Split('.'); string name = nameArr[0]; string type = nameArr[1]; string NewFileName = txtEmpNationalID.Text + "-Doc" + dateFile + "." + type; fuDocs.PostedFile.SaveAs(Server.MapPath(@"../Import/EmployeesFiles/") + NewFileName); ProClass.EmpID = txtEmpNationalID.Text; ProClass.DocName = txtDocName.Text; ProClass.DocPath = NewFileName; ProClass.TransactionBy = FormSession.LoginUsr; SqlClass.Docs_Insert(ProClass); } else { MessageFun.ShowMsg(this, MessageFun.TypeMsg.Validation, General.Msg("You must choose a file", "يجب اختيار ملف")); return; } FillGrdDocs(txtEmpNationalID.Text); } catch (Exception Ex) { DBFun.InsertError(FormSession.PageName, "btnUploadDoc"); MessageFun.ShowAdminMsg(this, Ex.Message); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void PopulateUI(string pID) { try { DataTable myTableDT = DBFun.FetchData("SELECT * FROM EmployeeMaster WHERE EmpID = '" + pID + "' AND EmpType = '" + ddlEmpType.SelectedValue + "' "); FillFromDT(myTableDT); txtEmpIdentity.Text = txtIDSearch.Text; DataItemEnabled(true); } catch (Exception Ex) { DBFun.InsertError(FormSession.PageName, "PopulateUI"); MessageFun.ShowAdminMsg(this, Ex.Message); } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void PopulateUI(string searchPar) { try { dt = DBFun.FetchData("SELECT * FROM StickerInfoView where RegVehicle = '" + searchPar + "' and Status = 1 "); if (DBFun.IsNullOrEmpty(dt)) { txtRegVehicle.Text = searchPar.ToString(); return; } DataRow dr = (DataRow)dt.Rows[0]; txtRegVehicle.Text = searchPar.ToString(); txtEmpid.Text = dr["EmpID"].ToString(); txtOwner.Text = dr["Owner"].ToString(); txtCarType.Text = dr["CarType"].ToString(); txtModel.Text = dr["Model"].ToString(); txtColor.Text = dr["Color"].ToString(); //ddlTemplate.SelectedIndex = ddlTemplate.Items.IndexOf(ddlTemplate.Items.FindByValue(dr["EmpType"].ToString())); //if (ViewState["CommandName"].ToString() == "Update") //{ // calEnddate.setDBDate(dr["ExpiryDate"], "S"); // calStartdate.setDBDate(dr["StartDate"], "S"); // if (dr["ReturnBackDate"] != DBNull.Value) // { // divLicRtnDate1.Visible = true; // divLicRtnDate2.Visible = true; // calReturnDate.setDBDate(dr["ReturnBackDate"], "S"); // } // else { divLicRtnDate1.Visible = false; divLicRtnDate2.Visible = false; } // if (Convert.ToString(dr["Category"]) == "Contractor Car") { divLicRtnDate1.Visible = true; divLicRtnDate2.Visible = true; } // if (dr["Printed"].ToString() == "1") { btnSave.Enabled = false; } // else { btnSave.Enabled = true; } //} } catch (Exception Ex) { DBFun.InsertError(FormSession.PageName, "PopulateUI"); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void FillPropeties() { try { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); ProClass.DateType = FormSession.DateType; ProClass.EmpID = txtEmployeeID.Text; ProClass.EmpType = ddlProcessType.SelectedValue; ProClass.TransactionBy = FormSession.LoginUsr; ProClass.TransactionDate = DateTime.Now.ToShortDateString(); } catch (Exception Ex) { DBFun.InsertError(FormSession.PageName, "FillPropeties"); MessageFun.ShowAdminMsg(this, Ex.Message); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void btnSave_Click(object sender, EventArgs e) { try { if (!Page.IsValid) { ValidatorCollection ValidatorColl = Page.Validators; for (int k = 0; k < ValidatorColl.Count; k++) { if (!ValidatorColl[k].IsValid && !String.IsNullOrEmpty(ValidatorColl[k].ErrorMessage)) { vsSave.ShowSummary = true; return; } vsSave.ShowSummary = false; } return; } FillPropeties(); if (ViewState["Action"].ToString() == "A") { SqlClass.Insert(ProClass); MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg(MainNameEn + " data added successfully", "تمت إضافة بيانات " + MainName2Ar + " بنجاح")); } if (ViewState["Action"].ToString() == "U") { SqlClass.Update(ProClass); MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg(MainNameEn + " data updated successfully", "تم تعديل بيانات " + MainName2Ar + " بنجاح")); } ClearUI(); ButtonAction("00", true); //VisImage.EnabledImage(false); } catch (Exception ex) { DBFun.InsertError(FormSession.PageName, "btnSave"); VisImage.PopulateImage(txtVisIdentityNo.Text); MessageFun.ShowAdminMsg(this, ex.Message); } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void grdData_RowCreated(object sender, GridViewRowEventArgs e) { try { switch (e.Row.RowType) { case DataControlRowType.DataRow: { e.Row.Attributes.Add("onmouseover", "mouseout('alt_row_highlight',this);"); e.Row.Attributes.Add("onmouseout", "mouseover('alt_row_nohighlight',this);"); e.Row.Attributes.Add("onmousemove", "mousemove('alt_row_nohighlight',this);"); break; } } } catch (Exception e1) { DBFun.InsertError(FormSession.PageName, "grdCardprint_RowCreated"); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public bool FindBlackList(string pID) { try { DataTable DT = DBFun.FetchData("SELECT BlaID FROM BlackList WHERE BlaIdentityNo = '" + pID + "'"); if (!DBFun.IsNullOrEmpty(DT)) { return(true); } else { return(false); } } catch (Exception e1) { DBFun.InsertError(FormSession.PageName, "FindBlackList"); return(false); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public string FindTmp() { try { string tmp = "0"; DataTable TmpDT = DBFun.FetchData("SELECT * FROM CardTemplate WHERE TmpType = 'VCard'"); if (!DBFun.IsNullOrEmpty(TmpDT)) { tmp = TmpDT.Rows[0]["TmpID"].ToString(); } return(tmp); } catch (Exception e1) { DBFun.InsertError(FormSession.PageName, "PopulateUI"); return("0"); } }