/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 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 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 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 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); } }
/*##############################################################################################################################*/ /*##############################################################################################################################*/ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /*##############################################################################################################################*/ /*##############################################################################################################################*/ #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 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 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 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); } }
/*******************************************************************************************************************************/ /*******************************************************************************************************************************/ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /*******************************************************************************************************************************/ /*******************************************************************************************************************************/ #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 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 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 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); } }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void ddlIssue_SelectedIndexChanged(object sender, EventArgs e) { try { if (btnSave.Enabled) { FillCondition(); } //FillLost(); } catch (Exception Ex) { MessageFun.ShowAdminMsg(this, Ex.Message); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 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); } }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void grdData_RowCommand(object sender, GridViewCommandEventArgs e) { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); try { string CardID = e.CommandArgument.ToString(); GridViewRow gvr = (GridViewRow)(((Control)e.CommandSource).NamingContainer); int rowIndex = gvr.RowIndex; GridViewRow GDR = grdData.Rows[rowIndex]; string EmpID = ((LinkButton)GDR.FindControl("btnViewEmp")).Text; switch (e.CommandName) { case ("Approve"): if (FormSession.PermUsr.Contains("ACrd")) { SqlClass.Approved(CardID, FormSession.LoginUsr, DateTime.Now.ToShortDateString(), "1"); } MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg(MainNameEn + " Approved", MainName2Ar + " مقبولة")); SE.SendMailToEmp(EmpID, CardID, "W", "Approve"); break; case ("Reject"): string RejectReason = ((TextBox)GDR.FindControl("txtgRejectReason")).Text; if (!string.IsNullOrEmpty(RejectReason)) { string confirmValue = Request.Form["confirm_value"]; if (confirmValue == "Yes") { if (FormSession.PermUsr.Contains("ACrd")) { SqlClass.Rejected(CardID, FormSession.LoginUsr, DateTime.Now.ToShortDateString(), "-1",RejectReason); } MessageFun.ShowMsg(this, MessageFun.TypeMsg.Warning, General.Msg(MainNameEn + " Rejected", MainName2Ar + " مرفوضة")); SE.SendMailToEmp(EmpID, CardID, "W", "Reject"); } } else { MessageFun.ShowMsg(this, MessageFun.TypeMsg.Validation, General.Msg("You must enter the reason for rejection", "يجب إدخال سبب الرفض")); } break; } FillDDL(); FillGrid(); } catch (Exception Ex) { 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 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 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 { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (ddlProcessType.SelectedValue == ViewState["EmpType"].ToString()) { MessageFun.ShowMsg(this, MessageFun.TypeMsg.Warning, General.Msg("Employee is already part of " + GetNameType(ViewState["EmpType"].ToString()), "الموظف موجود فعلياً ضمن قائمة " + GetNameType(ViewState["EmpType"].ToString()))); return; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// FillPropeties(); SqlClass.UpdateType(ProClass); ClearUI(); txtIDSearch.Text = ""; MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg(MainNameEn + " Update Employee type successfully", "تم تعديل نوع " + MainName2Ar + " بنجاح")); ButtonAction("00", true); } catch (Exception Ex) { DBFun.InsertError(FormSession.PageName, "btnSave"); MessageFun.ShowAdminMsg(this, Ex.Message); } }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void btnApproveSelectCards_Click(object sender, EventArgs e) { try { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); bool isCheck = false; foreach (GridViewRow row in grdData.Rows) { if (row.RowType == DataControlRowType.DataRow) { if (((CheckBox)(row.FindControl("chkSelect"))).Checked) { isCheck = true; break; } } } if (!isCheck) { MessageFun.ShowMsg(this, MessageFun.TypeMsg.Validation, General.Msg("Must select a card at least", "يجب اختيار بطاقة على الأقل")); return; } for (int i = 0; i < grdData.Rows.Count; i++) { GridViewRow gvr = grdData.Rows[i]; bool isChecked = ((CheckBox)(gvr.FindControl("chkSelect"))).Checked; if (isChecked) { if (FormSession.PermUsr.Contains("ACrd")) { SqlClass.Approved(gvr.Cells[4].Text, FormSession.LoginUsr, DateTime.Now.ToShortDateString(), "1"); } } } FillDDL(); FillGrid(); MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg(MainNameEn + " Approved", MainName2Ar + " مقبولة")); } catch (Exception Ex) { MessageFun.ShowAdminMsg(this, Ex.Message); } }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void Page_Load(object sender, EventArgs e) { try { // --------------------Common Code ----------------------------------------------------------------- // FormSession.FillSession("Card", pageDiv); FormCtrl.RefreshGridEmpty(ref grdData, 20, "No cards for Approve", "لا توجد بطاقات للموافقة عليها"); hfdLang.Value = FormSession.Language; // --------------------Common Code ----------------------------------------------------------------- // if (!IsPostBack) { MainMasterPage.ShowTitel(General.Msg("Approve Card", "الموافقة على البطاقات")); if (!FormSession.PermUsr.Contains("ACrd")) { Response.Redirect(@"~/Login.aspx"); } FillDDL(); FillGrid(); } } catch (Exception Ex) { MessageFun.ShowAdminMsg(this, Ex.Message); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void btnImport_Click(object sender, ImageClickEventArgs e) { try { if (fudFilePath.HasFile) { string OldName = fudFilePath.FileName; string[] nameArr = OldName.Split('.'); string FName = nameArr[0]; string FType = nameArr[1]; string EmpType = "Visitors"; string FileName = FormSession.LoginUsr + "-" + EmpType + "." + FType; fudFilePath.SaveAs(Server.MapPath(@"../" + EmpType + "/") + FileName); string Path = Server.MapPath(@"../" + EmpType + "/") + FileName; string ExcelConnectionString = getExcelConnectionString(Path); if (!string.IsNullOrEmpty(ExcelConnectionString)) { string SheetName = GetExcelSheetNames(ExcelConnectionString); FillExcelDataSet(ExcelConnectionString, SheetName); FillDB(); if (File.Exists(Path)) { File.Delete(Path); } MessageFun.ShowMsg(this, MessageFun.TypeMsg.Success, General.Msg("succsss Import", "تمت عملية الاستيراد")); } } } catch (Exception ex) { MessageFun.ShowAdminMsg(this, ex.ToString()); } }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public int FindCount(string pID) { int CardCount = 0; try { DataTable CountDT = DBFun.FetchData("SELECT COUNT(CardID) count FROM CardMaster WHERE isPrinted = 'True' AND EmpID = '" + pID + "'"); if (DBFun.IsNullOrEmpty(CountDT)) { } else { CardCount = Convert.ToInt32(CountDT.Rows[0]["count"]); } } catch (Exception Ex) { DBFun.InsertError(FormSession.PageName, "FindCount"); MessageFun.ShowAdminMsg(this, Ex.Message); } return(CardCount); }