///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void EmpID_ServerValidate(Object source, ServerValidateEventArgs e) { try { if (source.Equals(cvEmpID)) { if (string.IsNullOrEmpty(txtEmpID.Text)) { General.ValidMsg(this, ref cvEmpID, false, "Employee ID is required!", "رقم الموظف مطلوب !"); e.IsValid = false; return; } else { if (ViewState["CommandName"].ToString() == "Add") { dt = DBFun.FetchData(MainQuery + " AND EmpID = '" + txtEmpID.Text + "'"); if (!DBFun.IsNullOrEmpty(dt)) { MessageFun.ValidMsg(this, ref cvEmpID, true, General.Msg("The Employee ID already exists", "رقم الموظف موجود مسبقا")); e.IsValid = false; return; } } } } } catch { e.IsValid = false; } }
/*##############################################################################################################################*/ /*##############################################################################################################################*/ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /*##############################################################################################################################*/ /*##############################################################################################################################*/ #region ButtonAction Events 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() == "Add") { SqlClass.Insert(ProClass); MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg("Employee added successfully", "تمت إضافة الموظف بنجاح")); } if (ViewState["CommandName"].ToString() == "Edit") { SqlClass.Update(ProClass); MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg("Employee updated successfully", "تم تعديل الموظف بنجاح")); } ClearItem(); Search(); } catch (Exception Ex) { MessageFun.ShowAdminMsg(this, Ex.Message); } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void IdentityNo_ServerValidate(Object source, ServerValidateEventArgs e) { //string sqlUpdate = ViewState["CommandName"].ToString() == "Update" ? " AND BlaIdentityNo != " + txtBlaIdentityNo.Text : ""; try { if (ViewState["CommandName"].ToString() == "Save") { if (source.Equals(cvBlaIdentityNo)) { if (string.IsNullOrEmpty(txtBlaIdentityNo.Text)) { MessageFun.ValidMsg(this, ref cvBlaIdentityNo, false, General.Msg("Identity No. is required", "رقم الهوية مطلوب")); e.IsValid = false; return; } else { dt = DBFun.FetchData(MainQuery + " WHERE BlaIdentityNo = '" + txtBlaIdentityNo.Text + "'"); if (!DBFun.IsNullOrEmpty(dt)) { MessageFun.ValidMsg(this, ref cvBlaIdentityNo, true, General.Msg("Identity No. already exists", "رقم الهوية موجود مسبقا")); e.IsValid = false; return; } } } } } catch { e.IsValid = false; } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 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 FillGrid() { try { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); StringBuilder query = new StringBuilder(); query.Append(" SELECT CardID,EmpID,StartDate,ExpiryDate,IsID,EmpType " + " , EmpName" + General.Lang() + " AS EmpName " + " , IsName" + General.Lang() + " AS IssueName " + " FROM CardInfoView " + " WHERE CardStatus = 1 AND IsApproved = 0 "); if (ddlEmployee.SelectedIndex > 0) { query.Append(" AND EmpID = '" + ddlEmployee.SelectedValue + "'"); } if (ddlEmpType.SelectedIndex > 0) { query.Append(" AND EmpType = '" + ddlEmpType.SelectedValue + "'"); } if (ddlIssue.SelectedIndex > 0) { query.Append(" AND IsID = '" + ddlIssue.SelectedValue + "'"); } dt = DBFun.FetchData(query.ToString()); if (!DBFun.IsNullOrEmpty(dt)) { grdData.DataSource = (DataTable)dt; grdData.DataBind(); divbtn.Visible = true; } else { FormCtrl.FillGridEmpty(ref grdData,20,"No cards for Approve","لا توجد بطاقات للموافقة عليها"); divbtn.Visible = false; } } catch (Exception Ex) { MessageFun.ShowAdminMsg(this, Ex.Message); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void UsrLoginID_ServerValidate(Object source, ServerValidateEventArgs e) { try { if (source.Equals(cvUsrLoginID)) { if (string.IsNullOrEmpty(txtUsrLoginID.Text)) { General.ValidMsg(this, ref cvUsrLoginID, false, "Login ID is required!", "اسم دخول المستخدم مطلوب !"); e.IsValid = false; return; } else { if (ViewState["CommandName"].ToString() == "Save") { dt = DBFun.FetchData(MainQuery + " WHERE UsrLoginID = '" + txtUsrLoginID.Text + "'"); if (!DBFun.IsNullOrEmpty(dt)) { MessageFun.ValidMsg(this, ref cvUsrLoginID, true, General.Msg("The Login ID already exists", "اسم الدخول موجود مسبقا")); e.IsValid = false; return; } } } } } catch { e.IsValid = false; } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 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); } }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void btnDelete_Click(object sender, EventArgs e) { if (txtUsrLoginID.Text == "admin") { MessageFun.ShowMsg(this, MessageFun.TypeMsg.Error, General.Msg("You can not delete a User : system administrator", "لا يمكن حذف المستخدم : مدير النظام")); return; } if (txtUsrLoginID.Text == FormSession.LoginID) { MessageFun.ShowMsg(this, MessageFun.TypeMsg.Error, General.Msg("You can not delete the current user of the system", "لا يمكن حذف المستخدم الحالي للنظام")); return; } string Q = " SELECT LogTransactionBy FROM TransactionLog WHERE LogTransactionBy = '" + txtUsrLoginID.Text + "' "; 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 { FillPropeties(); SqlClass.Delete(ProClass); MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg("User deleted successfully", "تم حذف المستخدم بنجاح")); ClearItem(); Search(); } }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 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) { 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; } ProClass.UsrLoginID = FormSession.LoginID; ProClass.UsrPassword = txtNewPass.Text; SqlClass.UpdatePassword(ProClass); ClearUI(); MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg("Password updated successfully", "تم تعديل كلمة المرور بنجاح")); } catch (Exception Ex) { MessageFun.ShowAdminMsg(this, Ex.Message); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void EmpID_ServerValidate(Object source, ServerValidateEventArgs e) { string sqlUpdate = ViewState["CommandName"].ToString() == "Edit" ? " AND EvrID != " + txtEvrID.Text : ""; try { if (ViewState["CommandName"].ToString() == "Add" || ViewState["CommandName"].ToString() == "Edit") { if (source.Equals(cvEmpID)) { if (!string.IsNullOrEmpty(txtEmpID.Text)) { dt = DBFun.FetchData("SELECT * FROM EmployeesInfoView WHERE EmpID = '" + txtEmpID.Text + "' "); if (!DBFun.IsNullOrEmpty(dt)) { MessageFun.ValidMsg(this, ref cvEmpID, true, General.Msg("Employee ID entered donot exists or not Active,Please enter different ID", "رقم الموظف غير موجود أو غير فعال ,من فضلك اختر رقما آخر")); e.IsValid = false; return; } } } } } catch { e.IsValid = false; } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void PopulateUI(string pID) { try { dt = DBFun.FetchData("SELECT * FROM IssueState WHERE IsID = " + pID + ""); if (DBFun.IsNullOrEmpty(dt)) { return; } DataRow dr = (DataRow)dt.Rows[0]; txtIssueNameEn.Text = dt.Rows[0]["IsNameEn"].ToString(); txtIssueNameAr.Text = dt.Rows[0]["IsNameAr"].ToString(); txtIssuedescription.Text = dt.Rows[0]["IsDescription"].ToString(); rdlIsRepeat.SelectedIndex = rdlIsRepeat.Items.IndexOf(rdlIsRepeat.Items.FindByValue(dt.Rows[0]["IsRepeat"].ToString())); rdlIsCondition.SelectedIndex = rdlIsCondition.Items.IndexOf(rdlIsCondition.Items.FindByValue(dt.Rows[0]["ISCondition"].ToString())); rdlIsCondition_SelectedIndexChanged(null, null); DataTable Condt = DBFun.FetchData("SELECT * FROM IssueConditions WHERE IsID = " + pID + ""); if (DBFun.IsNullOrEmpty(Condt)) { return; } for (int i = 0; i < Condt.Rows.Count; i++) { cblConditions.Items.Add(Condt.Rows[i]["ConditionName"].ToString()); } } catch (Exception Ex) { MessageFun.ShowAdminMsg(this, Ex.Message); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void ConfirmValidate_ServerValidate(Object source, ServerValidateEventArgs e) { try { if (source.Equals(cvConfirm)) { if (string.IsNullOrEmpty(txtConfirmpassword.Text)) { MessageFun.ValidMsg(this, ref cvConfirm, false, General.Msg("Confirm Password is required", "يجب إدخال تأكيد كلمة المرور")); e.IsValid = false; return; } else { if (txtNewpassword.Text != txtConfirmpassword.Text) { MessageFun.ValidMsg(this, ref cvConfirm, true, General.Msg("Password and Confirm Password must be same", "كلمة المرور وتأكيد كلمة المرور غير متطابقتين")); e.IsValid = false; return; } } } } catch { e.IsValid = 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); } }
public void UnRegisterMessage(MessageFun fun, string messageKey) { if (dicMessage.ContainsKey(messageKey)) { dicMessage[messageKey] -= fun; } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 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); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void CountDaysForSend_ServerValidate(Object source, ServerValidateEventArgs e) { try { if (source.Equals(cvCountDaysForSend)) { MessageFun.ValidMsg(this, ref cvCountDaysForSend, false, General.Msg("You must enter Send Email befor", "يجب إدخال عدد الأيام")); if (string.IsNullOrEmpty(txtEmlCountDaysForSend.Text)) { e.IsValid = false; } if (!string.IsNullOrEmpty(txtEmlCountDaysForSend.Text)) { MessageFun.ValidMsg(this, ref cvCountDaysForSend, true, General.Msg("The number of days must be greater than 0", "عدد الأيام بجب ان يكون أكبر من 0")); if (Convert.ToInt32(txtEmlCountDaysForSend.Text) < 1) { e.IsValid = false; } } } } catch { e.IsValid = false; } }
/*******************************************************************************************************************************/ /*******************************************************************************************************************************/ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /*******************************************************************************************************************************/ /*******************************************************************************************************************************/ #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); } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 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 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 Pass_ServerValidate(Object source, ServerValidateEventArgs e) { try { if (source.Equals(cvCurrentPass)) { if (string.IsNullOrEmpty(txtCurrentPass.Text)) { MessageFun.ValidMsg(this, ref cvCurrentPass, false, General.Msg("Current Password is required", "كلمة المرور الحالية مطلوبة")); e.IsValid = false; return; } else { dt = DBFun.FetchData("SELECT UsrPassword FROM AppUsers WHERE UsrLoginID = '" + FormSession.LoginID + "'"); if (!DBFun.IsNullOrEmpty(dt)) { if (dt.Rows[0][0].ToString() != txtCurrentPass.Text) { MessageFun.ValidMsg(this, ref cvCurrentPass, true, General.Msg("The Current password is incorrect", "كلمة المرور الحالية غير صحيحة")); e.IsValid = false; return; } } } } if (source.Equals(cvNewPass)) { if (string.IsNullOrEmpty(txtNewPass.Text)) { MessageFun.ValidMsg(this, ref cvNewPass, false, General.Msg("New Password is required", "كلمة المرور الجديدة مطلوبة")); e.IsValid = false; return; } } if (source.Equals(cvConfirmPass)) { if (string.IsNullOrEmpty(txtConfirmPass.Text)) { MessageFun.ValidMsg(this, ref cvConfirmPass, false, General.Msg("Confirm Password is required", " تأكيد كلمة المرور مطلوبة")); e.IsValid = false; return; } else { if (!string.IsNullOrEmpty(txtNewPass.Text) && txtNewPass.Text != txtConfirmPass.Text) { MessageFun.ValidMsg(this, ref cvConfirmPass, true, General.Msg("Password and Confirm Password must be same", "كلمة المرور وتأكيد كلمة المرور غير متطابقتين")); e.IsValid = false; return; } } } } catch { e.IsValid = false; } }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void btnCancelSelectCards_Click(object sender, EventArgs e) { try { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); string confirmValue = Request.Form["confirm_value"]; if (confirmValue == "Yes") { bool isEmpty = false; bool isCheck = false; foreach (GridViewRow row in grdData.Rows) { if (row.RowType == DataControlRowType.DataRow) { if (((CheckBox)(row.FindControl("chkSelect"))).Checked) { isCheck = true; if (string.IsNullOrEmpty(((TextBox)row.FindControl("txtgRejectReason")).Text)) { isEmpty = true; break; } } } } if (!isCheck) { MessageFun.ShowMsg(this, MessageFun.TypeMsg.Validation, General.Msg("Must select a card at least", "يجب اختيار بطاقة على الأقل")); return; } if (!isEmpty) { for (int i = 0; i < grdData.Rows.Count; i++) { GridViewRow gvr = grdData.Rows[i]; bool isChecked = ((CheckBox)(gvr.FindControl("chkSelect"))).Checked; if (isChecked) { string RejectReason = ((TextBox)gvr.FindControl("txtgRejectReason")).Text; if (FormSession.PermUsr.Contains("ACrd")) { SqlClass.Rejected(gvr.Cells[5].Text, FormSession.LoginUsr, DateTime.Now.ToShortDateString(), "-1",RejectReason); } } } FillDDL(); FillGrid(); MessageFun.ShowMsg(this, MessageFun.TypeMsg.Warning, General.Msg(MainNameEn + " Rejected", MainName2Ar + " مرفوضة")); } else { MessageFun.ShowMsg(this, MessageFun.TypeMsg.Validation, General.Msg("You must enter the reason for rejection", "يجب إدخال سبب الرفض")); } } } catch (Exception Ex) { 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.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) { 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 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 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); } }
public void RegisterMessage(MessageFun fun, string messageKey) { if (!dicMessage.ContainsKey(messageKey)) { dicMessage.Add(messageKey, null); dicMessage[messageKey] += fun; } else { dicMessage[messageKey] += fun; } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void Name_ServerValidate(Object source, ServerValidateEventArgs e) { string sqlUpdate = ViewState["CommandName"].ToString() == "Update" ? " AND RoleID != " + ddlRoleID.SelectedValue : ""; try { if (ViewState["CommandName"].ToString() == "Save" || ViewState["CommandName"].ToString() == "Update") { if (source.Equals(cvRoleNameAr)) { if (string.IsNullOrEmpty(txtRoleNameAr.Text)) { MessageFun.ValidMsg(this, ref cvRoleNameAr, false, General.Msg(MainNameEn + " Name (Ar) is required", "اسم " + MainName2Ar + " (ع) مطلوب")); e.IsValid = false; return; } else { dt = DBFun.FetchData(MainQuery + " WHERE RoleNameAr = '" + txtRoleNameAr.Text + "' " + sqlUpdate); if (!DBFun.IsNullOrEmpty(dt)) { MessageFun.ValidMsg(this, ref cvRoleNameAr, true, General.Msg(MainNameEn + " name (Ar) already exists", "اسم " + MainName2Ar + " (ع) موجود مسبقا")); e.IsValid = false; return; } } } if (source.Equals(cvRoleNameEn)) { if (string.IsNullOrEmpty(txtRoleNameEn.Text)) { MessageFun.ValidMsg(this, ref cvRoleNameEn, false, General.Msg(MainNameEn + " Name (En) is required", "اسم " + MainName2Ar + " (E) مطلوب")); e.IsValid = false; return; } else { dt = DBFun.FetchData(MainQuery + " WHERE RoleNameEn = '" + txtRoleNameEn.Text + "' " + sqlUpdate); if (!DBFun.IsNullOrEmpty(dt)) { MessageFun.ValidMsg(this, ref cvRoleNameEn, true, General.Msg(MainNameEn + " name (En) already exists", "اسم " + MainName2Ar + " (E) موجود مسبقا")); e.IsValid = false; return; } } } } } catch { e.IsValid = false; } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void Name_ServerValidate(Object source, ServerValidateEventArgs e) { string sqlUpdate = ViewState["CommandName"].ToString() == "Update" ? " AND BlaIdentityNo != " + ddlBlaIdentityNo.SelectedValue : ""; try { if (ViewState["CommandName"].ToString() == "Save" || ViewState["CommandName"].ToString() == "Update") { if (source.Equals(cvBlaNameAr)) { if (string.IsNullOrEmpty(txtBlaNameAr.Text)) { MessageFun.ValidMsg(this, ref cvBlaNameAr, false, General.Msg("Name (Ar) is required", "الاسم بالعربي مطلوب")); e.IsValid = false; return; } else { dt = DBFun.FetchData(MainQuery + " WHERE NatNameAr = '" + txtBlaNameAr.Text + "' " + sqlUpdate); if (!DBFun.IsNullOrEmpty(dt)) { MessageFun.ValidMsg(this, ref cvBlaNameAr, true, General.Msg("Name (Ar) already exists", "الاسم بالعربي موجود مسبقا")); e.IsValid = false; return; } } } if (source.Equals(cvBlaNameEn)) { if (string.IsNullOrEmpty(txtBlaNameEn.Text)) { MessageFun.ValidMsg(this, ref cvBlaNameEn, false, General.Msg("Name (En) is required", "الاسم بالانجليزي مطلوب")); e.IsValid = false; return; } else { dt = DBFun.FetchData(MainQuery + " WHERE NatNameEn = '" + txtBlaNameEn.Text + "' " + sqlUpdate); if (!DBFun.IsNullOrEmpty(dt)) { MessageFun.ValidMsg(this, ref cvBlaNameEn, true, General.Msg("Name (En) already exists", "الاسم بالانجليزي موجود مسبقا")); e.IsValid = false; return; } } } } } catch { e.IsValid = false; } }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void ddlIssue_SelectedIndexChanged(object sender, EventArgs e) { try { if (btnSave.Enabled) { FillCondition(); } //FillLost(); } catch (Exception Ex) { MessageFun.ShowAdminMsg(this, Ex.Message); } }