private bool saveChangeEmployee() { if (validationForm()) { try { //////////////////////// add New Employee Structure ///////////////////////////////// db.Configuration.LazyLoadingEnabled = false; var ChangeEmployeeStructure = db.Employee_Structure.Create(); int employeeSturctureFormId = int.Parse(employeeSturctureFrom.SelectedValue); var currentEmployeeStructure = db.Employee_Structure.First(x => x.Employee_Structure_Id == employeeSturctureFormId); ChangeEmployeeStructure.Structure_Id = currentEmployeeStructure.Structure_Id; ChangeEmployeeStructure.Employee_Id = int.Parse(employeeTo.SelectedValue); ChangeEmployeeStructure.Status_Structure = true; ChangeEmployeeStructure.Default_Structure = false; ChangeEmployeeStructure.Type_Delegation = false; db.Employee_Structure.Add(ChangeEmployeeStructure); db.SaveChanges(); LogData = "data:" + JsonConvert.SerializeObject(ChangeEmployeeStructure, logFileModule.settings); logFileModule.logfile(1009, "تغيير المسمي الموظيفي", "Change Job Title", LogData); //////////////////////// Change Currnet Structure to New Employee ///////////////////////////////// int newEmployeeSturctureId = ChangeEmployeeStructure.Employee_Structure_Id; currentEmployeeStructure.Employee_Delegation = newEmployeeSturctureId; currentEmployeeStructure.Status_Structure = false; db.Entry(currentEmployeeStructure).State = EntityState.Modified; db.SaveChanges(); LogData = "data:" + JsonConvert.SerializeObject(currentEmployeeStructure, logFileModule.settings); logFileModule.logfile(1009, "تغيير المسمي الموظيفي", "Change Job Title", LogData); //////////////////////// Change Old Structure To New Employee ///////////////////////////////// var changelistEmpStur = db.Employee_Structure.Where(x => x.Employee_Delegation == employeeSturctureFormId).ToList(); foreach (Employee_Structure oneEmployeeSturcture in changelistEmpStur) { oneEmployeeSturcture.Employee_Delegation = newEmployeeSturctureId; db.Entry(oneEmployeeSturcture).State = EntityState.Modified; } db.SaveChanges(); var changelistEmpStur1 = db.Employee_Structure.Where(x => x.Employee_Delegation == newEmployeeSturctureId).ToList(); LogData = "data:" + JsonConvert.SerializeObject(changelistEmpStur1, logFileModule.settings); logFileModule.logfile(1009, "تغيير المسمي الموظيفي", "Change Job Title", LogData); } catch (Exception exceptionLog) { string exceptionStackTrace = exceptionLog.StackTrace; string exceptionGetType = exceptionLog.GetType().ToString(); string exceptionMessage = exceptionLog.Message; string exceptionData = "data:{\"StackTrace\":\"" + exceptionStackTrace + "\",\"GetType\":\"" + exceptionGetType + "\",\"Message\":\"" + exceptionMessage + "\"}"; logFileModule.logfile(1025, "حدث خطأ في حفظ تغيير المسمي الوظيفي", "An error occurred in saving the Job Title", exceptionData); messageForm = "Erorr to save data in system"; return(false); } return(true); } else { return(false); } }
private bool saveEmployeeDelegation() { if (validationForm()) { try { db.Configuration.LazyLoadingEnabled = false; var delegationEmployeeStructure = db.Employee_Structure.Create(); var currentEmployeeStructure = db.Employee_Structure.First(x => x.Employee_Structure_Id == currentStructureUserId); delegationEmployeeStructure.Structure_Id = currentEmployeeStructure.Structure_Id; delegationEmployeeStructure.Employee_Id = int.Parse(employeeDelegation.SelectedValue); delegationEmployeeStructure.Status_Structure = true; delegationEmployeeStructure.Default_Structure = false; delegationEmployeeStructure.Type_Delegation = true; delegationEmployeeStructure.Date_Delegation = DateTime.Now; delegationEmployeeStructure.Employee_Delegation = currentStructureUserId; db.Employee_Structure.Add(delegationEmployeeStructure); db.SaveChanges(); LogData = "data:" + JsonConvert.SerializeObject(delegationEmployeeStructure, logFileModule.settings); logFileModule.logfile(1009, "تفويض معاملات", "Delegation transaction", LogData); currentEmployeeStructure.Employee_Delegation = delegationEmployeeStructure.Employee_Structure_Id; currentEmployeeStructure.Type_Delegation = false; currentEmployeeStructure.Date_Delegation = DateTime.Now; db.Entry(currentEmployeeStructure).State = EntityState.Modified; db.SaveChanges(); LogData = "data:" + JsonConvert.SerializeObject(currentEmployeeStructure, logFileModule.settings); logFileModule.logfile(1009, "تفويض معاملات", "Delegation transaction", LogData); } catch (Exception exceptionLog) { string exceptionStackTrace = exceptionLog.StackTrace; string exceptionGetType = exceptionLog.GetType().ToString(); string exceptionMessage = exceptionLog.Message; string exceptionData = "data:{\"StackTrace\":\"" + exceptionStackTrace + "\",\"GetType\":\"" + exceptionGetType + "\",\"Message\":\"" + exceptionMessage + "\"}"; logFileModule.logfile(1025, "حدث خطأ في حفظ التفويض", "An error occurred in saving the Delegation", exceptionData); if (SessionWrapper.LoggedUser.Language_id == 1) { messageForm = "حدث خطأ في حفظ البيانات في النظام"; } else { messageForm = "Erorr to save data in system"; } return(false); } return(true); } else { return(false); } }
public bool AU_Emplooyees(int EmployeeID, string Email, string Phone, int lang, int calander) { try { db.Configuration.LazyLoadingEnabled = false; Employee Emp = db.Employees.First(x => x.Employee_Id == EmployeeID); Emp.Employee_Email = Email; Emp.Employee_Phone = Phone; Emp.Language_id = lang; Emp.Calendar_id = calander; string ImagepathProfile = UploadFile(1); string ImagepathSignature = UploadFile(2); if (ImagepathProfile != "") { Emp.Employee_Profile = ImagepathProfile; } if (ImagepathSignature != "") { Emp.Employee_Signature = ImagepathSignature; } //----------------------------Employee Structure------------------------------------------- var Emp_Stru = db.Employee_Structure.Where(x => x.Employee_Id == EmployeeID).ToList(); for (int i = 0; i < Emp_Stru.Count; i++) { int E_S = 0; int.TryParse(Emp_Stru[i].Structure_Id.ToString(), out E_S); Employee_Structure stu = db.Employee_Structure.First(x => x.Employee_Id == EmployeeID && x.Structure_Id == E_S); if (E_S.ToString() == DefaultStructure.SelectedValue) { stu.Default_Structure = true; } else { stu.Default_Structure = false; } Emp.Employee_Structure.Add(stu); } //----------------------------End Employee Structure------------------------------------------- db.Entry(Emp).State = System.Data.EntityState.Modified; db.SaveChanges(); /* Add it to log file */ LogData = "data:" + JsonConvert.SerializeObject(Emp, logFileModule.settings); logFileModule.logfile(10, "تعديل بيانات الموظف", "Update Employee Info", LogData); SessionWrapper.LoggedUser = Emp; SessionWrapper.Language = db.Lanuage_Detials.Where(x => x.Language_Master_ID == lang).ToList(); } catch { return(false); } return(true); }
public bool UpdateTopic(int Topic_id) { LogFileModule logFileModule = new LogFileModule(); String LogData = ""; db.Configuration.LazyLoadingEnabled = false; try { var Topic = db.M_Topic.First(x => x.Topic_Id == Topic_id); if (Topic.Topic_Status == 1) { Topic.Topic_Status = 2; } else if (Topic.Topic_Status == 2) { Topic.Topic_Status = 1; } db.Entry(Topic).State = System.Data.EntityState.Modified; db.SaveChanges(); /* Add it to log file */ LogData = "data:" + JsonConvert.SerializeObject(Topic, logFileModule.settings); logFileModule.logfile(10, "تعديل حالة الموضوع", "Update Topic stats", LogData); } catch (Exception e) { return(false); } return(true); }
private void UpdateLocation() { try { M_Board_Location locations = db.M_Board_Location.FirstOrDefault(x => x.Board_Location_Id == Location_id); locations.Board_Location_Name_Ar = txtArabicName.Text; locations.Board_Location_Name_En = txtEnglishName.Text; locations.Board_Location_Description_Ar = txtArabicDescription.Text; locations.Board_Location_Description_En = txtEnglishDescription.Text; locations.Board_Location_OnMap = txtMapLocation.Text; locations.Board_Location_URLVideo = txtVideoURL.Text; db.Entry(locations).State = System.Data.EntityState.Modified; db.SaveChanges(); string messages = "Location Updated successfully.."; if (SessionWrapper.LoggedUser.Language_id == 1) { messages = "تم تحديث بيانات الموقع بنجاح"; } LtrMessage.Text = "<div class='alert alert-success' role='alert'>" + messages + "</div>"; LoadLocations(); } catch { string messages = "System Error..."; if (SessionWrapper.LoggedUser.Language_id == 1) { messages = "حدث خطاء في النظام..."; } LtrMessage.Text = "<div class='alert alert-danger' role='alert'>" + messages + "</div>"; } }
public bool UpdateBoardStatus(int board_id, int type_process) { try { db.Configuration.LazyLoadingEnabled = false; M_Board board = db.M_Board.Find(board_id); if (board == null) { return(false); } board.Board_Status_Id = type_process; db.Entry(board).State = System.Data.EntityState.Modified; db.SaveChanges(); return(true); /*Add it to log file */ LogData = "data:" + JsonConvert.SerializeObject(board, logFileModule.settings); logFileModule.logfile(10, "تغير حالة المجلس/اللجنة", "Update the board", LogData); }catch (Exception er) { /*Add it to log file */ LogData = "data:" + JsonConvert.SerializeObject(er, logFileModule.settings); logFileModule.logfile(10, "حدث خطاء في النظام", "An Exception has occurred", LogData); return(false); } }
public bool UpateMetting(int Meeting_id) { LogFileModule logFileModule = new LogFileModule(); String LogData = ""; db.Configuration.LazyLoadingEnabled = false; try { var Meeting = db.M_Meeting.First(x => x.Meeting_Id == Meeting_id); if (Meeting.Meeting_Status == 1) { Meeting.Meeting_Status = 2; } else if (Meeting.Meeting_Status == 2) { Meeting.Meeting_Status = 3; } else if (Meeting.Meeting_Status == 3) { Meeting.Meeting_Status = 1; } db.Entry(Meeting).State = System.Data.EntityState.Modified; db.SaveChanges(); /* Add it to log file */ LogData = "data:" + JsonConvert.SerializeObject(Meeting, logFileModule.settings); logFileModule.logfile(10, "تعيل حالة الإجتماع", "Update Meeting Stats", LogData); } catch (Exception e) { return(false); } return(true); }
protected void Save_Click(object sender, EventArgs e) { try { string message = ""; int board_id = int.Parse(Request["BoardId"]); int EmployeeId = int.Parse(txtEmployees.SelectedValue); // check if member exist M_Board_Member IsMemberExisted = db.M_Board_Member.FirstOrDefault(x => x.Board_Id == board_id && x.Employee_Id == EmployeeId); if (IsMemberExisted == null) { // Create new member M_Board_Member member = db.M_Board_Member.Create(); member.Board_Id = board_id; member.Employee_Id = EmployeeId; member.Member_Type_Id = int.Parse(txtType.SelectedValue); db.M_Board_Member.Add(member); message = "Member Added successfully.."; if (SessionWrapper.LoggedUser.Language_id == 1) { message = "تم اضافة عضو بنجاح"; } } else { // Update exist member M_Board_Member member = db.M_Board_Member.Find(IsMemberExisted.Board_Member_Id); member.Board_Id = board_id; member.Employee_Id = EmployeeId; member.Member_Type_Id = int.Parse(txtType.SelectedValue); member.Board_Member_Id = IsMemberExisted.Board_Member_Id; db.Entry(member).State = System.Data.EntityState.Modified; message = "Member updated successfully.."; if (SessionWrapper.LoggedUser.Language_id == 1) { message = "تم تحديث صلاحية عضو بنجاح"; } } db.SaveChanges(); LtrMessage.Text = "<div class='alert alert-success' role='alert'>" + message + "</div>"; // Reload data List <M_Board_Member> ListMember = db.M_Board_Member.Where(x => x.Board_Id == board_id).ToList(); fillDropDown(); LoadMember(ListMember, board_id); } catch { string messages = "System Error..."; if (SessionWrapper.LoggedUser.Language_id == 1) { messages = "حدث خطاء في النظام..."; } LtrMessage.Text = "<div class='alert alert-danger' role='alert'>" + messages + "</div>"; } }
public bool SaveMeeting(int Meeting_Id, int Board_Id, string Meeting_Name_Ar, string Meeting_Name_En, DateTime Meeting_Date, DateTime Meeting_Time, int Meeting_Status_Id, string Meeting_Minutes, int Board_Location_Id, FileUpload M_Attachments) { try { db.Configuration.LazyLoadingEnabled = false; M_Meeting Meeting = db.M_Meeting.Create(); if (Meeting_Id != 0) { Meeting = db.M_Meeting.First(x => x.Meeting_Id == Meeting_Id); } Meeting.Board_Id = Board_Id; Meeting.Meeting_Name_Ar = Meeting_Name_Ar; Meeting.Meeting_Name_En = Meeting_Name_En; Meeting.Meeting_Date = Meeting_Date; Meeting.Meeting_Time = Meeting_Time.TimeOfDay; Meeting.Meeting_Status = Meeting_Status_Id; Meeting.Meeting_Minutes = Meeting_Minutes; Meeting.Board_Location_Id = Board_Location_Id; if (Meeting_Id != 0) { db.Entry(Meeting).State = System.Data.EntityState.Modified; } else { Meeting.Create_Date = DateTime.Parse(CDate.Text); db.M_Meeting.Add(Meeting); } db.SaveChanges(); if (Meeting_Id != 0) { MeetingID = Meeting_Id; } else { MeetingID = Meeting.Meeting_Id; } AttachmentFile(MeetingID, M_Attachments, @"~\Pages\Eminutes\media\M_Attachments\"); /* Add it to log file */ LogData = "data:" + JsonConvert.SerializeObject(Meeting, logFileModule.settings); if (Meeting_Id != 0) { logFileModule.logfile(10, "تعديل بيانات إجتماع", "update Meeting", LogData); } else { logFileModule.logfile(10, "إضافة إجتماع", "Add Meeting", LogData); } } catch { return(false); } return(true); }
public bool SaveTopic(int Topic_Id, int Meeting_Id, string Topic_Name_Ar, string Topic_Name_En, int Topic_Status_Id, int Structure_Id, string Arabic_Description, string English_Description, string Arabic_Recommendation, string English_Recommendation, string Arabic_RecommendationDoc, string English_RecommendationDoc) { try { db.Configuration.LazyLoadingEnabled = false; M_Topic Topic = db.M_Topic.Create(); if (Topic_Id != 0) { Topic = db.M_Topic.First(x => x.Topic_Id == Topic_Id); } Topic.Meeting_Id = Meeting_Id; Topic.Topic_Status = Topic_Status_Id; if (Structure_Id > 0) { Topic.Structure_Id = Structure_Id; } else { Topic.Structure_Id = null; } Topic.Topic_Name_Ar = Topic_Name_Ar; Topic.Topic_Name_En = Topic_Name_En; Topic.Topic_Description_Ar = Arabic_Description; Topic.Topic_Description_En = English_Description; Topic.Topic_Recommendation_Ar = Arabic_Recommendation; Topic.Topic_Recommendation_En = English_Recommendation; Topic.Topic_Recommendation_Doc_Ar = Arabic_RecommendationDoc; Topic.Topic_Recommendation_Doc_En = English_RecommendationDoc; if (Topic_Id != 0) { db.Entry(Topic).State = System.Data.EntityState.Modified; } else { Topic.Create_Date = DateTime.Now.Date; db.M_Topic.Add(Topic); } db.SaveChanges(); /* Add it to log file */ LogData = "data:" + JsonConvert.SerializeObject(Topic, logFileModule.settings); if (Meeting_Id != 0) { logFileModule.logfile(10, "تعديل بيانات موضوع", "update Topic", LogData); } else { logFileModule.logfile(10, "إضافة موضوع", "Add Topic", LogData); } } catch { return(false); } return(true); }
public void ProcessRequest(HttpContext context) { if (context.Request["BoardId"] == null || context.Request["EmpId"] == null || context.Request["MemberTableId"] == null) { context.Response.Redirect("~/Pages/Eminutes/Home.aspx"); } int board_id = int.Parse(context.Request["BoardId"].ToString()); int emp_id = int.Parse(context.Request["EmpId"].ToString()); int member_id = int.Parse(context.Request["MemberTableId"].ToString()); try { var member = new M_Board_Member { Board_Member_Id = member_id }; db.Entry(member).State = System.Data.EntityState.Deleted; db.SaveChanges(); } catch { } context.Response.Redirect("~/Pages/Eminutes/BoardManagment/BoardMember.aspx?BoardId=" + board_id); }
public bool AU_Emplooyees(int EmployeeID, string ArabicName, string EnglishName, string Email, string Phone, bool Active, int GroupID, int lang, int calander) { try { db.Configuration.LazyLoadingEnabled = false; Employee Emp = db.Employees.Create(); if (EmployeeID != 0) { Emp = db.Employees.First(x => x.Employee_Id == EmployeeID); } Emp.Employee_Name_Ar = ArabicName; Emp.Employee_Name_En = EnglishName; Emp.Employee_Email = Email; Employee_Structure Emp_Stu = new Employee_Structure();; if (EmployeeID == 0) { string New_Password = StringCipher.RandomString(7); string Encrypted_Password = StringCipher.Encrypt(New_Password, "Password"); // emp.Employee_Password.ToString(); Emp.Employee_Password = Encrypted_Password; string sever_name = Request.Url.Authority.ToString(); /* SendEmail send = new SendEmail(); * bool EmailResult = send.ResetEmail(Email, New_Password, sever_name); * if (EmailResult) * { * Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "show_model_sucess();", true); * }*/ } Emp.Employee_Phone = Phone; Emp.Employee_Active = Active; Emp.Group_Id = GroupID; Emp.Language_id = lang; Emp.Calendar_id = calander; string ImagepathProfile = UploadFile(1); string ImagepathSignature = UploadFile(2); if (ImagepathProfile != "") { Emp.Employee_Profile = ImagepathProfile; } else if (EmployeeID == 0) { ImagepathProfile = "Profile.JPG"; } if (ImagepathSignature != "") { Emp.Employee_Signature = ImagepathSignature; } else if (EmployeeID == 0) { ImagepathSignature = "Signature.JPG"; } /////////////////////////////////////// Employee_Structure ///////////////////////////////////// Boolean DefaultStructure = false; for (int i = 0; i < Emp_Structure.Items.Count; i++) { int id = 0; Boolean IsFound = false; int.TryParse(Emp_Structure.Items[i].Value, out id); var Emp_Stru_found = db.Employee_Structure.Where(x => x.Employee_Id == EmployeeID && x.Structure_Id == id).ToList(); if (Emp_Stru_found.Count > 0) { IsFound = true; } if (Emp_Structure.Items[i].Selected) { if (!IsFound) { Emp_Stu = new Employee_Structure(); Emp_Stu.Structure_Id = int.Parse(Emp_Structure.Items[i].Value); Emp_Stu.Status_Structure = true; Emp_Stu.Type_Delegation = false; if (!DefaultStructure) { Emp_Stu.Default_Structure = true; DefaultStructure = true; } else { Emp_Stu.Default_Structure = false; } Emp.Employee_Structure.Add(Emp_Stu); } else { Emp_Stu = db.Employee_Structure.First(x => x.Employee_Id == EmployeeID && x.Structure_Id == id); Emp_Stu.Status_Structure = true; Emp_Stu.Type_Delegation = false; if (!DefaultStructure) { Emp_Stu.Default_Structure = true; DefaultStructure = true; } else { Emp_Stu.Default_Structure = false; } Emp.Employee_Structure.Add(Emp_Stu); } } else if (IsFound) { Emp_Stu = db.Employee_Structure.First(x => x.Employee_Id == EmployeeID && x.Structure_Id == id); Emp_Stu.Status_Structure = false; Emp_Stu.Type_Delegation = false; Emp_Stu.Default_Structure = false; Emp.Employee_Structure.Add(Emp_Stu); } } /////////////////////////////////////// Employee_Structure ///////////////////////////////////// if (EmployeeID != 0) { db.Entry(Emp).State = System.Data.EntityState.Modified; } else { db.Employees.Add(Emp); } db.SaveChanges(); /* Add it to log file */ LogData = "data:" + JsonConvert.SerializeObject(Emp, logFileModule.settings); if (EmployeeID != 0) { logFileModule.logfile(10, "تعديل بيانات موظف", "update Employee", LogData); } else { logFileModule.logfile(10, "إضافة موظف", "Add Employee", LogData); } LogData = "data:" + JsonConvert.SerializeObject(Emp_Stu, logFileModule.settings); logFileModule.logfile(10, "هيكلة موظف", "Employee Structure", LogData); } catch { return(false); } return(true); }
private bool update() { int board_id = int.Parse(Request["BoardId"].ToString()); string str = string.Empty; try { // Create Board info M_Board board = db.M_Board.Find(board_id); board.Board_Name_Ar = txtArabicName.Text; board.Board_Name_En = txtEnglishName.Text; board.Board_Description_Ar = txtArabicDescription.Text; board.Board_Description_En = txtEnglishDescription.Text; board.Board_Type_Id = int.Parse(txtTypeofBoard.SelectedValue.ToString()); board.Board_Status_Id = int.Parse(txtStatusofBoard.SelectedValue.ToString()); board.Board_Classification_Id = int.Parse(txtClassification.SelectedValue.ToString()); board.Parent = int.Parse(txtParent.SelectedValue.ToString()); board.Create_Date = DateTime.Now; if (txtTypeofBoard.SelectedValue == "1" || txtTypeofBoard.SelectedValue == "2") { board.Start_Date = null; board.End_Date = null; } else if ((txtStartDate.Value.ToString() == "" || txtEndDate.Value.ToString() == "")) { string messages = "Please Select start date & end date..."; if (SessionWrapper.LoggedUser.Language_id == 1) { messages = "الرجاء اختيار تاريخ البداية والنهاية"; } LtrMessage.Text = "<div class='alert alert-warning' role='alert'>" + messages + "</div>"; return(false); } else { board.Start_Date = DateTime.Parse(txtStartDate.Value.ToString()); board.End_Date = DateTime.Parse(txtEndDate.Value.ToString()); } AttachmentFile(board.Board_Id, addAttachments, @"~\Pages\Eminutes\media\M_Attachments\"); db.Entry(board).State = System.Data.EntityState.Modified; db.SaveChanges(); } catch { string messages = "System Error..."; if (SessionWrapper.LoggedUser.Language_id == 1) { messages = "حدث خطاء ..."; } LtrMessage.Text = "<div class='alert alert-danger' role='alert'>" + messages + "</div>"; return(false); } string message = "Board update successfully.."; if (SessionWrapper.LoggedUser.Language_id == 1) { message = "تم تحديث المجلس/اللجنة بنجاح"; } LtrMessage.Text = "<div class='alert alert-success' role='alert'>" + message + "</div>"; return(true); }