private List <Structure> loadTreeStructure() { List <Structure> ListStructure = new List <Structure>(); Structure getStructure; Structure oneStructure; Employee_Structure oneEmployeeStructure; using (ECMSEntities dbEcms = new ECMSEntities()) { try { oneEmployeeStructure = new Employee_Structure(); oneEmployeeStructure = dbEcms.Employee_Structure.FirstOrDefault(x => x.Employee_Structure_Id == currentStructureUserId && x.Structure.Is_Job_Title == true && x.Structure.Is_Manager == true); if (oneEmployeeStructure != null) { int structureIdCurrent = (int)oneEmployeeStructure.Structure_Id; getStructure = new Structure(); getStructure = dbEcms.Structures.FirstOrDefault(x => x.Structure_Id == structureIdCurrent); if (getStructure != null) { int getIdStructure = (int)getStructure.Structure_Parent; oneStructure = new Structure(); oneStructure = dbEcms.Structures.FirstOrDefault(x => x.Structure_Id == getIdStructure); if (oneStructure != null) { int getParentStructure = (int)oneStructure.Structure_Parent; ListStructure = dbEcms.Structures.Where(x => x.Is_Job_Title == false && (x.Structure_Parent == getIdStructure || x.Structure_Parent == getParentStructure || x.Structure_Id == getParentStructure)).ToList <Structure>(); } } } } catch (Exception eees) { } } return(ListStructure); }
private List <Treatment_Master> getTreatmentMaster() { List <Treatment_Master> treatmentMaster = new List <Treatment_Master>(); using (ECMSEntities db = new ECMSEntities()) { try { treatmentMaster = db.Treatment_Master.Where(x => x.From_Employee_Structure_Id == EmpStructureID && x.Treatment_Status_Id == 1).OrderByDescending(x => x.Treatment_Id).ToList <Treatment_Master>(); List <Treatment_Master> treatmentMasterDelegation; int delgEmpStrId = 0; if (!isDelegation) { for (int i = 0; i < ListDelegationEmpStru.Count; i++) { delgEmpStrId = ListDelegationEmpStru[i].Employee_Structure_Id; treatmentMasterDelegation = new List <Treatment_Master>(); treatmentMasterDelegation = db.Treatment_Master.Where(x => x.From_Employee_Structure_Id == delgEmpStrId && x.Treatment_Status_Id == 1).OrderByDescending(x => x.Treatment_Id).ToList <Treatment_Master>(); treatmentMaster.AddRange(treatmentMasterDelegation); } } } catch (Exception eexs) { } } return(treatmentMaster.OrderByDescending(x => x.Treatment_Id).ToList <Treatment_Master>()); }
public void logfile(int controlId, string logName, string logDescription, String noteData) { try { using (var dbLog = new ECMSEntities()) { Log_File logFileInsert = dbLog.Log_File.Create(); logFileInsert.Log_Date = DateTime.Now; if (controlId != 0) { if (SessionWrapper.LoggedUser != null) { logFileInsert.Login_Id = SessionWrapper.LoggedUser.Employee_Id; } else { logFileInsert.Login_Id = 1; } logFileInsert.Form_Id = currentPage(); } logFileInsert.Log_Name = logName; logFileInsert.Log_Description = logDescription; logFileInsert.Log_Note = noteData; dbLog.Log_File.Add(logFileInsert); dbLog.SaveChanges(); } }catch (Exception er) { } }
public static string DeleteEmplooye(int Employee_Id) { string returnDeleteEmp = "0"; LogFileModule logFileModule = new LogFileModule(); String LogData = ""; try { ECMSEntities db = new ECMSEntities(); var widgets = db.Employee_Structure.Where(x => x.Employee_Id == Employee_Id).ToList(); if (widgets.Count > 0) { foreach (Employee_Structure widget in widgets) { db.Employee_Structure.Remove(widget); } } var DelEmp = db.Employees.First(x => x.Employee_Id == Employee_Id); db.Employees.Remove(DelEmp); db.SaveChanges(); returnDeleteEmp = "1"; /* Add it to log file */ LogData = "data:" + JsonConvert.SerializeObject(DelEmp, logFileModule.settings); logFileModule.logfile(10, "حذف الموظف", "Delete Employee", LogData); } catch (Exception e) { } return(JsonConvert.SerializeObject(returnDeleteEmp)); }
private List <Treatment_Detial> getTreatmentDetailComplete() { List <Treatment_Detial> treatmentDetial = new List <Treatment_Detial>(); using (ECMSEntities db = new ECMSEntities()) { try { treatmentDetial = db.Treatment_Detial.Where(x => x.To_Employee_Structure_Id == currentStructureUserId && x.Assignment_Status_Id == 3).OrderByDescending(x => x.Treatment_Detial_Id).ToList <Treatment_Detial>(); List <Treatment_Detial> treatmentDetialDelegation; int delgEmpStrId = 0; if (!isDelegation) { for (int i = 0; i < ListDelegationEmpStru.Count; i++) { delgEmpStrId = ListDelegationEmpStru[i].Employee_Structure_Id; treatmentDetialDelegation = new List <Treatment_Detial>(); treatmentDetialDelegation = db.Treatment_Detial.Where(x => x.To_Employee_Structure_Id == delgEmpStrId && x.Assignment_Status_Id == 3).OrderByDescending(x => x.Treatment_Detial_Id).ToList <Treatment_Detial>(); treatmentDetial.AddRange(treatmentDetialDelegation); } } } catch (Exception eexs) { } } return(treatmentDetial.OrderByDescending(x => x.Treatment_Detial_Id).ToList <Treatment_Detial>()); }
public static void dropDDLBox <T>(ListBox ddlst, string selectID, string selectName, List <T> Entitylst) { using (ECMSEntities db = new ECMSEntities()) { ddlst.Items.Clear(); ddlst.DataValueField = selectID; ddlst.DataTextField = selectName; ddlst.DataSource = Entitylst; ddlst.DataBind(); } }
public static void dropDDL <T>(DropDownList ddlst, string selectID, string selectName, List <T> Entitylst, string selectword) { using (ECMSEntities db = new ECMSEntities()) { ddlst.Items.Clear(); ddlst.DataValueField = selectID; ddlst.DataTextField = selectName; ddlst.DataSource = Entitylst; ddlst.DataBind(); ddlst.Items.Insert(0, new ListItem(selectword, "0")); ddlst.SelectedIndex = 0; } }
protected void Page_Load(object sender, EventArgs e) { db = new ECMSEntities(); Session["IsECMS"] = true; //ListPermissions = db.Permissions.ToList(); if (SessionWrapper.LoggedUser != null) { if (SessionWrapper.IsLocked) { Response.Redirect("~/Pages/Setting/admin/LockScreen.aspx"); } } else { Response.Redirect("~/Pages/Setting/Auth/Login.aspx"); } string path_and_query = HttpContext.Current.Request.Url.PathAndQuery; path_and_query = HttpUtility.UrlEncode(path_and_query); txtlockscreen.Text = "<a href='../../../../Pages/Setting/Auth/LockScreen.aspx?URL=" + path_and_query + "'>" + "<i class='feather icon-lock'></i> " + FieldNames.getFieldName("Master-LockScreen", "Lock Screen") + "</a>"; //Change Layout to RTL if (SessionWrapper.LoggedUser.Language_id != null) { if (SessionWrapper.LoggedUser.Language_id == 1) { Style.Text = FieldNames.getSTyleRTL(); Script.Text = FieldNames.getJavaScriptRTL(); //this.html.Attributes.Add("dir", "ltr"); //Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "RTL_Layout();", true); } } ListPermissions = SessionWrapper.Permssions; Employee_Name(); LoadBreadcrumb(ListPermissions); LoadMenu(ListPermissions); currentUserId = SessionWrapper.LoggedUser.Employee_Id; currentStructureUserId = SessionWrapper.EmpStructure; delegationId = getDelegationId(); loadNotification(); LoadStructure(); // ViewData(60); }
private string getTreatmentNumber() { string treatmentNumber = ""; using (var db1 = new ECMSEntities()) { try { Int64 dc = db.Treatment_Master.ToList().Max(e => Convert.ToInt64(e.Treatment_Id)); treatmentNumber = DateTime.Now.Year + "" + (dc + 1).ToString("D5"); } catch (Exception ree) { treatmentNumber = DateTime.Now.Year + "" + 1.ToString("D5"); } return(treatmentNumber); } }
private void fillDropDownListBox() { using (ECMSEntities dbEmp = new ECMSEntities()) { List <Employee> ListEmployee = new List <Employee>(); ListEmployee = dbEmp.Employees.ToList <Employee>(); ddlFiller.dropDDL(employeeTo, "Employee_Id", "Employee_Name_En", ListEmployee, "Select Employee To"); List <Employee_Structure> ListEmployeeStructure = new List <Employee_Structure>(); ListEmployeeStructure = dbEmp.Employee_Structure.Where(x => x.Status_Structure == true && x.Type_Delegation == false).ToList <Employee_Structure>(); var dc = from c in ListEmployeeStructure select new { ddlKey = c.Employee_Structure_Id, ddlValue = c.Employee.Employee_Name_En + " '" + c.Structure.Structure_Name_En + "'", }; ddlFiller.dropDDL(employeeSturctureFrom, "ddlKey", "ddlValue", dc.ToList(), "Select Employee Structure From"); } }
private bool insertNotification(int treatmentIdNotf) { try { using (ECMSEntities dbEcms = new ECMSEntities()) { Treatment_Master treatmentMasterNotf = new Treatment_Master(); treatmentMasterNotf = dbEcms.Treatment_Master.FirstOrDefault(x => x.Treatment_Id == treatmentIdNotf && x.Required_Reply == true); if (treatmentMasterNotf != null) { List <Treatment_Detial> listTreatmentDetialNotf = new List <Treatment_Detial>(); listTreatmentDetialNotf = treatmentMasterNotf.Treatment_Detial.Where(x => x.Treatment_Copy_To == false).ToList <Treatment_Detial>(); string linkNotif = ""; for (int i = 0; i < listTreatmentDetialNotf.Count; i++) { linkNotif = "../../../../Pages/Treatment/ShowTreatment.aspx?getTreatmentId=" + treatmentIdNotf + "&getTabId=4&getTreatmentDetialId=" + 0 + "&getNotificationId="; Notification_Master notificationMaster = new Notification_Master(); notificationMaster = dbEcms.Notification_Master.Create(); notificationMaster.Notification_Date = DateTime.Now; notificationMaster.Is_Read = false; notificationMaster.From_Employee_Structure_Id = listTreatmentDetialNotf[i].To_Employee_Structure_Id; notificationMaster.To_Employee_Structure_Id = currentStructureUserId; notificationMaster.Master_Id = treatmentIdNotf; notificationMaster.Notification_Description_Ar = "لم يتم الرد علي المعاملة"; notificationMaster.Notification_Description_En = "The transaction was not answered"; notificationMaster.Notification_Link = linkNotif; notificationMaster.Is_Show_Reply = true; notificationMaster.Date_Show_Reply = treatmentMasterNotf.Required_Reply_Date; notificationMaster.Notification_Show_Id = 4; dbEcms.Notification_Master.Add(notificationMaster); dbEcms.SaveChanges(); } } } return(true); } catch { return(false); } }
private void xrPictureBox4_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) { if (SessionWrapper.LoggedUser.Employee_Signature != null && SessionWrapper.LoggedUser.Employee_Signature != "") { ECMSEntities db = new ECMSEntities(); string PathURL = "~/media/Signature/" + SessionWrapper.LoggedUser.Employee_Signature; string Path = System.Web.Hosting.HostingEnvironment.MapPath(PathURL); using (Image image = Image.FromFile(Path)) { using (MemoryStream m = new MemoryStream()) { image.Save(m, image.RawFormat); byte[] imageBytes = m.ToArray(); // Convert byte[] to Base64 String string base64String = Convert.ToBase64String(imageBytes); Image img = ByteArrayToImage(Convert.FromBase64String(base64String)); xrPictureBox4.Image = img; } } } }
public static string ViewUserCard(int Employee_Id) { using (var dbcont = new ECMSEntities()) { var Emplo = dbcont.Employees.Where(d => d.Employee_Id == Employee_Id).Select(x => new EmployeDTO { Employee_Name_Ar = x.Employee_Name_Ar, Employee_Name_En = x.Employee_Name_En, Employee_Id = x.Employee_Id, Employee_Active = x.Employee_Active, Employee_Email = x.Employee_Email, Employee_Password = x.Employee_Password, Employee_Phone = x.Employee_Phone, Employee_Profile = x.Employee_Profile, Employee_Signature = x.Employee_Signature, Language_id = x.Language_id, Calendar_id = x.Calendar_id, Group_Id = x.Group_Id, Structures = x.Employee_Structure.Where(f => f.Status_Structure == true && f.Type_Delegation == false).Select(c => c.Structure_Id) }).FirstOrDefault(); JavaScriptSerializer js = new JavaScriptSerializer(); return(JsonConvert.SerializeObject(Emplo)); } }
private List <Employee_Structure> loadSendEmployeeStructure() { List <Employee_Structure> ListEmployeeStructure = new List <Employee_Structure>(); Employee_Structure addEmployeeStructure; Employee_Structure oneEmployeeStructure; using (ECMSEntities dbEcms = new ECMSEntities()) { try { oneEmployeeStructure = new Employee_Structure(); oneEmployeeStructure = dbEcms.Employee_Structure.FirstOrDefault(x => x.Employee_Structure_Id == currentStructureUserId && x.Structure.Is_Job_Title == true); if (oneEmployeeStructure != null) { bool flayIsManager = false; int parentCurrentJobTitle = (int)oneEmployeeStructure.Structure.Structure_Parent; int structureIdCurrent = (int)oneEmployeeStructure.Structure.Structure_Id; flayIsManager = (bool)oneEmployeeStructure.Structure.Is_Manager; int strurId = 0; bool flayAdd = false; int parentCurrent = -1; if ((bool)oneEmployeeStructure.Structure.Is_Manager) { Structure oneStructure = dbEcms.Structures.FirstOrDefault(x => x.Structure_Id == parentCurrentJobTitle); if (oneStructure != null) { parentCurrent = (int)oneStructure.Structure_Parent; } } List <Structure> ListGetSameLevel = dbEcms.Structures.Where(x => (x.Structure_Id == parentCurrent) || (((x.Structure_Parent == parentCurrent && x.Is_Job_Title == false) || x.Structure_Parent == parentCurrentJobTitle) && x.Structure_Id != structureIdCurrent)).ToList <Structure>(); for (int i = 0; i < ListGetSameLevel.Count; i++) { strurId = ListGetSameLevel[i].Structure_Id; oneEmployeeStructure = new Employee_Structure(); addEmployeeStructure = new Employee_Structure(); oneEmployeeStructure = dbEcms.Employee_Structure.FirstOrDefault(x => x.Structure.Structure_Parent == strurId && x.Structure.Is_Job_Title == true && x.Structure.Is_Manager == true); if (oneEmployeeStructure != null && flayIsManager) { flayAdd = true; } else { oneEmployeeStructure = new Employee_Structure(); oneEmployeeStructure = dbEcms.Employee_Structure.FirstOrDefault(x => x.Structure.Structure_Id == strurId && x.Structure.Is_Job_Title == true); if (oneEmployeeStructure != null) { flayAdd = true; } } if (flayAdd) { if (oneEmployeeStructure.Structure_Id != structureIdCurrent) { addEmployeeStructure.Structure = oneEmployeeStructure.Structure; addEmployeeStructure.Employee = oneEmployeeStructure.Employee; addEmployeeStructure.Employee_Structure_Id = oneEmployeeStructure.Employee_Structure_Id; addEmployeeStructure.Employee_Id = oneEmployeeStructure.Employee_Id; addEmployeeStructure.Structure_Id = oneEmployeeStructure.Structure_Id; ListEmployeeStructure.Add(addEmployeeStructure); } } flayAdd = false; } } } catch (Exception eees) { } } return(ListEmployeeStructure); }
private bool loadListViewCompleteTreatment() { using (ECMSEntities db = new ECMSEntities()) { try { string yourHTMLstring = "<table id='issue-list-table1' class='table dt-responsive' style='width: 100%;border-collapse: collapse !important'>" + "<thead class='text-left' style='display: none;'>" + "<tr>" + "<th>Expand</th>" + "<th>Actions</th>" + "<th>Status</th>" + "<th>English Name</th>" + "<th>Arabic Name</th>" + "</tr>" + "</thead>" + "<tbody class='text-left'>"; completeTreatment.Controls.Add(new LiteralControl(yourHTMLstring)); List <Treatment_Detial> treatmentDetial = new List <Treatment_Detial>(); //treatmentDetial = db.Treatment_Detial.Where(x => x.To_Employee_Structure_Id == currentStructureUserId && (x.Assignment_Status_Id == 1 || x.Assignment_Status_Id == 2)).OrderByDescending(x => x.Treatment_Detial_Id).ToList<Treatment_Detial>(); treatmentDetial = getTreatmentDetailComplete(); Treatment_Master oneTreatmentMaster; int motherTreatmentId = 0; int oneTreatmentDetailId = 0; string langTreatmentPriorityName = "", langEmployeeName = "", langTreatmentConfidentialityName = ""; for (int i = 0; i < treatmentDetial.Count; i++) { oneTreatmentDetailId = treatmentDetial[i].Treatment_Detial_Id; treatmentDetial[i] = db.Treatment_Detial.FirstOrDefault(x => x.Treatment_Detial_Id == oneTreatmentDetailId); if (treatmentDetial[i] != null) { oneTreatmentMaster = new Treatment_Master(); motherTreatmentId = (int)treatmentDetial[i].Treatment_Master.Treatment_Mother; if (motherTreatmentId == 0) { oneTreatmentMaster = treatmentDetial[i].Treatment_Master; } else { oneTreatmentMaster = db.Treatment_Master.First(x => x.Treatment_Id == motherTreatmentId); } if (SessionWrapper.LoggedUser.Language_id == 1) { langTreatmentPriorityName = treatmentDetial[i].Treatment_Master.Treatment_Priority.Treatment_Priority_Name_Ar; langEmployeeName = getSubString(treatmentDetial[i].Treatment_Master.Employee_Structure.Employee.Employee_Name_Ar, 20); langTreatmentConfidentialityName = treatmentDetial[i].Treatment_Master.Treatment_Confidentiality.Treatment_Confidentiality_Name_Ar; } else { langTreatmentPriorityName = treatmentDetial[i].Treatment_Master.Treatment_Priority.Treatment_Priority_Name_En; langEmployeeName = getSubString(treatmentDetial[i].Treatment_Master.Employee_Structure.Employee.Employee_Name_En, 20); langTreatmentConfidentialityName = treatmentDetial[i].Treatment_Master.Treatment_Confidentiality.Treatment_Confidentiality_Name_En; } yourHTMLstring = "<tr class='unread'>" + "<td style='width: 4%;'>" + "<div class='check-star'>" + "<a href='#!' data-toggle='tooltip' data-placement='top' data-trigger='hover' title='" + langTreatmentPriorityName + "'>" + "<i class='" + treatmentDetial[i].Treatment_Master.Treatment_Priority.Css_Class + "' style='font-size: 150%;'></i>" + "</a>" + "</div>" + "</td>" + "<td style='width: 20%;'><a href='ShowTreatment.aspx?getTreatmentId=" + oneTreatmentMaster.Treatment_Id + "&getTabId=3&getTreatmentDetialId=" + treatmentDetial[i].Treatment_Detial_Id + "' class='email-name'>" + langEmployeeName + "</a></td>" + "<td style='width: 60%;'><a href='ShowTreatment.aspx?getTreatmentId=" + oneTreatmentMaster.Treatment_Id + "&getTabId=3&getTreatmentDetialId=" + treatmentDetial[i].Treatment_Detial_Id + "' class='email-name'>" + getSubString(treatmentDetial[i].Treatment_Master.Treatment_Subject, 90) + "</a></td>" + "<td style='width: 7%;' class='email-tag'><a href='ShowTreatment.aspx?getTreatmentId=" + oneTreatmentMaster.Treatment_Id + "&getTabId=3&getTreatmentDetialId=" + treatmentDetial[i].Treatment_Detial_Id + "'><label class='" + treatmentDetial[i].Treatment_Master.Treatment_Confidentiality.Css_Class + "'>" + langTreatmentConfidentialityName + "</label></a></td>" + "<td style='width: 9%;' class='email-time'>" + Date_Different((DateTime)treatmentDetial[i].Treatment_Master.Create_Date) + "</td>" + "</tr>"; completeTreatment.Controls.Add(new LiteralControl(yourHTMLstring)); } } yourHTMLstring = "</tbody></table>"; completeTreatment.Controls.Add(new LiteralControl(yourHTMLstring)); return(true); } catch (Exception eee) { return(false); } } }