public ActionResult Edit(string field, string recordData, int index) { List <string> fields = new List <string> { "country", "state", "city", "region" }; int startIndex = fields.IndexOf(field); JsonObject data = JSON.Deserialize <JsonObject>(recordData); ModelProxy record = X.GetCmp <Store>("Store1").GetAt(index); for (int i = startIndex + 1; i < 4; i++) { switch (fields[i]) { case "state": record.Set(fields[i], data["country"] + "_S1"); data["state"] = data["country"] + "_S1"; break; case "city": record.Set(fields[i], data["state"] + "_C1"); data["city"] = data["state"] + "_C1"; break; case "region": record.Set(fields[i], data["city"] + "_R1"); break; } } return(this.Direct()); }
public bool ToggleStatus(int[] taskIds, bool?status, int categoryID, string filter) { try { var ctx = this.DBContext; List <Task> tasks = (from t in ctx.Tasks where taskIds.Contains(t.ID) select t).ToList(); foreach (Task task in tasks) { task.Completed = status != null ? status.Value : !task.Completed; task.CompletedDate = DateTime.Now; } ctx.SubmitChanges(); if (filter != "all") { this.BindTasks(categoryID, filter); } else { this.Store.Primary.SuspendEvents(false); foreach (Task task in tasks) { ModelProxy r = this.store.GetById((object)task.ID); r.Set("Completed", task.Completed); r.Set("CompletedDate", new JRawValue(DateTimeUtils.DateNetToJs(task.CompletedDate.Value))); } this.Store.Primary.ResumeEvents(); this.Store.Primary.FireEvent("refresh", new JRawValue(this.Store.Primary.ClientID)); } return(true); } catch (Exception e) { Ext.Net.X.Msg.Show(new MessageBoxConfig { Title = "Toggle status error", Message = e.Message, Icon = MessageBox.Icon.ERROR, Buttons = MessageBox.Button.OK }); return(false); } }
protected void AutomarkCalls_Clicked(object sender, DirectEventArgs e) { List <PhoneCall> userSessionPhoneCalls; Dictionary <string, PhoneBookContact> userSessionAddressbook; PhoneBookContact addressBookEntry; int numberOfRemainingUnmarked; //Get the unmarked calls from the user session phonecalls container CurrentSession.FetchSessionPhonecallsAndAddressbookData(out userSessionPhoneCalls, out userSessionAddressbook); numberOfRemainingUnmarked = userSessionPhoneCalls.Where(phoneCall => string.IsNullOrEmpty(phoneCall.UiCallType)).ToList().Count; //If the user has no addressbook contacts, skip the auto marking process if (userSessionAddressbook.Keys.Count > 0) { foreach (var phoneCall in userSessionPhoneCalls.Where(phoneCall => string.IsNullOrEmpty(phoneCall.UiCallType))) { if (userSessionAddressbook.Keys.Contains(phoneCall.DestinationNumberUri)) { addressBookEntry = (PhoneBookContact)userSessionAddressbook[phoneCall.DestinationNumberUri]; if (!string.IsNullOrEmpty(addressBookEntry.Type)) { phoneCall.UiCallType = addressBookEntry.Type; phoneCall.UiUpdatedByUser = sipAccount; phoneCall.UiMarkedOn = DateTime.Now; Global.DATABASE.PhoneCalls.Update(phoneCall, phoneCall.PhoneCallsTableName); ModelProxy model = MyPhoneCallsGrid.GetStore().Find("SessionIdTime", phoneCall.SessionIdTime.ToString()); model.Set(phoneCall); model.Commit(); } } } } MyPhoneCallsGrid.GetSelectionModel().DeselectAll(); MyPhoneCallsGrid.GetStore().LoadPage(1); CurrentSession.AssignSessionPhonecallsAndAddressbookData(userSessionPhoneCalls, userSessionAddressbook); }
protected void SaveNewRecord(object sender, DirectEventArgs e) { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string id = e.ExtraParams["id"]; string obj = e.ExtraParams["values"]; DayType b = JsonConvert.DeserializeObject <DayType>(obj); b.recordId = id; // Define the object to add or edit as null if (string.IsNullOrEmpty(id)) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <DayType> request = new PostRequest <DayType>(); request.entity = b; PostResponse <DayType> r = _timeAttendanceService.ChildAddOrUpdate <DayType>(request); b.recordId = r.recordId; //check if the insert failed if (!r.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, r.Summary).Show(); return; } else { //Add this record to the store this.Store1.Insert(0, b); //Display successful notification Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); this.EditRecordWindow.Close(); RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel; sm.DeselectAll(); sm.Select(b.recordId.ToString()); } } catch (Exception ex) { //Error exception displaying a messsage box X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show(); } } else { //Update Mode try { int index = Convert.ToInt32(id);//getting the id of the record PostRequest <DayType> request = new PostRequest <DayType>(); request.entity = b; PostResponse <DayType> r = _timeAttendanceService.ChildAddOrUpdate <DayType>(request); //Step 1 Selecting the object or building up the object for update purpose //Step 2 : saving to store //Step 3 : Check if request fails if (!r.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); return; } else { ModelProxy record = this.Store1.GetById(index); record.Set("isWorkingDay", b.isWorkingDay); BasicInfoTab.UpdateRecord(record); record.Commit(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); this.EditRecordWindow.Close(); } } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } } }
protected void SaveNewRecord(object sender, DirectEventArgs e) { string ExpiryDateString = e.ExtraParams["rwExpiryDate"]; string IssueDateDateString = e.ExtraParams["rwIssueDate"]; DateTime ExpiryDate = new DateTime(); DateTime IssueDate = new DateTime(); if (!string.IsNullOrEmpty(ExpiryDateString)) { ExpiryDate = DateTime.Parse(e.ExtraParams["rwExpiryDate"]); } if (!string.IsNullOrEmpty(IssueDateDateString)) { IssueDate = DateTime.Parse(e.ExtraParams["rwIssueDate"]); } //Getting the id to check if it is an Add or an edit as they are managed within the same form. string obj = e.ExtraParams["values"]; JsonSerializerSettings settings = new JsonSerializerSettings(); settings.NullValueHandling = NullValueHandling.Ignore; CompanyRightToWork b = JsonConvert.DeserializeObject <CompanyRightToWork>(obj, settings); string id = e.ExtraParams["id"]; string url = e.ExtraParams["url"]; // Define the object to add or edit as null if (dtId.SelectedItem != null) { b.dtName = dtId.SelectedItem.Text; } if (branchId.SelectedItem != null) { b.branchName = branchId.SelectedItem.Text; } bool hijriSupported = _systemService.SessionHelper.GetHijriSupport(); try { CultureInfo c = new CultureInfo("en"); string format = ""; if (hijriSupported) { if (hijriSelected.Text == "true") { b.hijriCal = true; c = new CultureInfo("ar"); format = "yyyy/MM/dd"; b.issueDate = DateTime.ParseExact(rwIssueDateMulti.Text, format, c); b.expiryDate = DateTime.ParseExact(rwExpiryDateMulti.Text, format, c); } //else //{ // c = new CultureInfo("en"); // if (_systemService.SessionHelper.CheckIfArabicSession()) // { // format = "dd/MM/yyyy"; // } // else // { // format = "MM/dd/yyyy"; // } //} else { b.issueDate = IssueDate; b.expiryDate = ExpiryDate; } } } catch (Exception exp) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, GetLocalResourceObject("DateFormatError")).Show(); return; } //b.remarks = if (b.issueDate != null && (b.issueDate > b.expiryDate)) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, GetLocalResourceObject("DateRangeError")).Show(); return; } if (string.IsNullOrEmpty(id)) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <CompanyRightToWork> request = new PostRequest <CompanyRightToWork>(); request.entity = b; byte[] fileData = null; if (rwFile.PostedFile != null && rwFile.PostedFile.ContentLength > 0) { //using (var binaryReader = new BinaryReader(picturePath.PostedFile.InputStream)) //{ // fileData = binaryReader.ReadBytes(picturePath.PostedFile.ContentLength); //} fileData = new byte[rwFile.PostedFile.ContentLength]; fileData = rwFile.FileBytes; } PostResponse <CompanyRightToWork> r = _systemService.ChildAddOrUpdate <CompanyRightToWork>(request); b.recordId = r.recordId; //check if the insert failed if (!r.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { if (fileData != null) { SystemAttachmentsPostRequest req = new SystemAttachmentsPostRequest(); req.entity = new Model.System.Attachement() { date = DateTime.Now, classId = ClassId.SYRW, recordId = Convert.ToInt32(b.recordId), fileName = rwFile.PostedFile.FileName, seqNo = 0 }; req.FileNames.Add(rwFile.PostedFile.FileName); req.FilesData.Add(fileData); PostResponse <Attachement> resp = _systemService.UploadMultipleAttachments(req); if (!resp.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } } b.recordId = r.recordId; //Add this record to the store CompanyRightToWork m = GetRWById(r.recordId); Store1.Insert(0, m); //Display successful notification Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); this.EditRecordWindow.Close(); RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel; sm.DeselectAll(); sm.Select(b.recordId.ToString()); } } catch (Exception ex) { //Error exception displaying a messsage box X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show(); } } else { //Update Mode try { //getting the id of the record int index = Convert.ToInt32(id);//getting the id of the record PostRequest <CompanyRightToWork> request = new PostRequest <CompanyRightToWork>(); b.recordId = index.ToString();; request.entity = b; byte[] fileData = null; if (rwFile.PostedFile != null && rwFile.PostedFile.ContentLength > 0) { fileData = new byte[rwFile.PostedFile.ContentLength]; fileData = rwFile.FileBytes; } PostResponse <CompanyRightToWork> r = _systemService.ChildAddOrUpdate <CompanyRightToWork>(request); //Step 1 Selecting the object or building up the object for update purpose //Step 2 : saving to store //Step 3 : Check if request fails if (!r.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { if (fileData != null) { SystemAttachmentsPostRequest req = new SystemAttachmentsPostRequest(); req.entity = new Model.System.Attachement() { date = DateTime.Now, classId = ClassId.SYRW, recordId = Convert.ToInt32(b.recordId), fileName = rwFile.PostedFile.FileName, seqNo = 0 }; req.FileNames.Add(rwFile.PostedFile.FileName); req.FilesData.Add(fileData); PostResponse <Attachement> resp = _systemService.UploadMultipleAttachments(req); if (!resp.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } } CompanyRightToWork m = GetRWById(id); ModelProxy record = this.Store1.GetById(id); BasicInfoTab.UpdateRecord(record); record.Set("dtName", b.dtName); record.Set("branchName", b.branchName); record.Set("fileUrl", m.fileUrl); record.Set("issueDateFormatted", m.issueDateFormatted); record.Set("expireDateFormatted", m.expireDateFormatted); record.Commit(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); this.EditRecordWindow.Close(); } } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } } }
protected void SaveNewRecord(object sender, DirectEventArgs e) { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string id = e.ExtraParams["id"]; string obj = e.ExtraParams["values"]; string addr = e.ExtraParams["address"]; Branch b = JsonConvert.DeserializeObject <Branch>(obj); b.managerId = managerId.Value.ToString(); b.isInactive = isInactive.Checked; b.activeStatus = isInactive.Checked ? Convert.ToInt16(ActiveStatus.INACTIVE) : Convert.ToInt16(ActiveStatus.ACTIVE); b.recordId = id; // Define the object to add or edit as null CustomResolver res = new CustomResolver(); res.AddRule("naId", "countryId"); res.AddRule("stId", "stateId"); JsonSerializerSettings settings = new JsonSerializerSettings(); settings.ContractResolver = res; b.caName = caId.SelectedItem.Text; AddressBook add = JsonConvert.DeserializeObject <AddressBook>(addr, settings); if (string.IsNullOrEmpty(add.city) && string.IsNullOrEmpty(add.countryId) && string.IsNullOrEmpty(add.street1) && string.IsNullOrEmpty(add.stateId) && string.IsNullOrEmpty(add.phone)) { b.address = null; } else { if (string.IsNullOrEmpty(add.city) || string.IsNullOrEmpty(add.countryId) || string.IsNullOrEmpty(add.street1) || string.IsNullOrEmpty(add.stateId) || string.IsNullOrEmpty(add.phone)) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, GetLocalResourceObject("ErrorAddressMissing")).Show(); return; } b.address = JsonConvert.DeserializeObject <AddressBook>(addr, settings); b.address.recordId = address.Text; } if (string.IsNullOrEmpty(branchId.Text)) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <Branch> request = new PostRequest <Branch>(); request.entity = b; PostResponse <Branch> r = _branchService.ChildAddOrUpdate <Branch>(request); b.recordId = r.recordId; //check if the insert failed if (!r.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", r.ErrorCode) != null ? GetGlobalResourceObject("Errors", r.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + r.LogId :r.Summary).Show(); return; } else { if (!string.IsNullOrEmpty(branchId.Text)) { //this.Store1.Insert(0, b); this.EditRecordWindow.Close(); //RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel; //sm.DeselectAll(); //sm.Select(b.recordId.ToString()); } Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); //Add this record to the store managerId.Disabled = false; //Display successful notification branchId.Text = b.recordId; Store1.Reload(); } } catch (Exception ex) { //Error exception displaying a messsage box X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show(); } } else { //Update Mode try { int index = Convert.ToInt32(branchId.Text);//getting the id of the record PostRequest <Branch> request = new PostRequest <Branch>(); b.recordId = branchId.Text; request.entity = b; PostResponse <Branch> r = _branchService.ChildAddOrUpdate <Branch>(request); //Step 1 Selecting the object or building up the object for update purpose //Step 2 : saving to store //Step 3 : Check if request fails if (!r.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { ModelProxy record = this.Store1.GetById(index); record.Set("caName", b.caName); BasicInfoTab.UpdateRecord(record); record.Commit(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); // this.EditRecordWindow.Close(); } } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } } }
protected void SaveNewRecord(object sender, DirectEventArgs e) { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string obj = e.ExtraParams["values"]; Case b = JsonConvert.DeserializeObject <Case>(obj); string id = e.ExtraParams["id"]; // Define the object to add or edit as null //b.employeeName = new EmployeeName(); if (employeeId.SelectedItem != null) { b.employeeName = employeeId.SelectedItem.Text; } if (closedDate.ReadOnly) { b.closedDate = null; } if (string.IsNullOrEmpty(id)) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <Case> request = new PostRequest <Case>(); request.entity = b; PostResponse <Case> r = _caseService.AddOrUpdate <Case>(request); //check if the insert failed if (!r.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", r.ErrorCode) != null ? GetGlobalResourceObject("Errors", r.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + r.LogId : r.Summary).Show(); return; } else { b.recordId = r.recordId; //Add this record to the store this.Store1.Insert(0, b); //Display successful notification Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); recordId.Text = b.recordId; SetTabPanelEnable(true); currentCase.Text = b.recordId; RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel; sm.DeselectAll(); sm.Select(b.recordId.ToString()); } } catch (Exception ex) { //Error exception displaying a messsage box X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show(); } } else { //Update Mode try { //getting the id of the record PostRequest <Case> request = new PostRequest <Case>(); request.entity = b; PostResponse <Case> r = _caseService.AddOrUpdate <Case>(request); //Step 1 Selecting the object or building up the object for update purpose //Step 2 : saving to store //Step 3 : Check if request fails if (!r.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", r.ErrorCode) != null ? GetGlobalResourceObject("Errors", r.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + r.LogId : r.Summary).Show(); return; } else { ModelProxy record = this.Store1.GetById(id); BasicInfoTab.UpdateRecord(record); if (closedDate.ReadOnly) { record.Set("closedDate", null); } record.Set("employeeName", b.employeeName); record.Commit(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); this.EditRecordWindow.Close(); } } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } } }
protected void SaveDocument(object sender, DirectEventArgs e) { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string id = e.ExtraParams["id"]; string obj = e.ExtraParams["values"]; EmployeeCertificate b = JsonConvert.DeserializeObject <EmployeeCertificate>(obj); b.employeeId = Convert.ToInt32(CurrentEmployee.Text); b.recordId = id; // Define the object to add or edit as null b.clName = clId.SelectedItem.Text; if (b.dateFrom != null) { DateTime Date = (DateTime)b.dateFrom; b.dateFrom = new DateTime(Date.Year, Date.Month, Date.Day, 14, 0, 0); } if (b.dateTo != null) { DateTime Date = (DateTime)b.dateTo; b.dateTo = new DateTime(Date.Year, Date.Month, Date.Day, 14, 0, 0); } if (string.IsNullOrEmpty(id)) { try { //New Mode PostRequest <EmployeeCertificate> request = new PostRequest <EmployeeCertificate>(); request.entity = b; PostResponse <EmployeeCertificate> r = _employeeService.ChildAddOrUpdate <EmployeeCertificate>(request); b.recordId = r.recordId; //check if the insert failed if (!r.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { //Add this record to the store this.skillStore.Insert(0, b); //Display successful notification Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); this.EditSkillWindow.Close(); RowSelectionModel sm = this.skillsGrid.GetSelectionModel() as RowSelectionModel; sm.DeselectAll(); sm.Select(b.recordId.ToString()); } } catch (Exception ex) { //Error exception displaying a messsage box X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show(); } } else { //Update Mode try { int index = Convert.ToInt32(id);//getting the id of the record PostRequest <EmployeeCertificate> request = new PostRequest <EmployeeCertificate>(); request.entity = b; PostResponse <EmployeeCertificate> r = _employeeService.ChildAddOrUpdate <EmployeeCertificate>(request); //Step 3 : Check if request fails if (!r.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { ModelProxy record = this.skillStore.GetById(index); SkillsForm.UpdateRecord(record); record.Set("clName", b.clName); record.Commit(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); this.EditSkillWindow.Close(); } } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } } }
protected void SaveNewRecord(object sender, DirectEventArgs e) { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string obj = e.ExtraParams["values"]; LeavePayment b = JsonConvert.DeserializeObject <LeavePayment>(obj); string id = e.ExtraParams["id"]; // Define the object to add or edit as null // b.employeeName = new EmployeeName(); //if (ldMethodCom.SelectedItem != null) // b.ldMethod = ldMethodCom.SelectedItem.Value; if (employeeId.SelectedItem != null) { b.employeeName = employeeId.SelectedItem.Text; } if (date.ReadOnly) { b.date = DateTime.Now; } //b.effectiveDate = new DateTime(b.effectiveDate.Year, b.effectiveDate.Month, b.effectiveDate.Day, 14, 0, 0); if (string.IsNullOrEmpty(id)) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <LeavePayment> request = new PostRequest <LeavePayment>(); request.entity = b; PostResponse <LeavePayment> r = _payrollService.ChildAddOrUpdate <LeavePayment>(request); //check if the insert failed if (!r.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { b.recordId = r.recordId; //Add this record to the store //this.Store1.Insert(0, b); //Display successful notification Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); recordId.Text = b.recordId; currentCase.Text = b.recordId; //RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel; //sm.DeselectAll(); //sm.Select(b.recordId.ToString()); Store1.Reload(); this.EditRecordWindow.Close(); } } catch (Exception ex) { //Error exception displaying a messsage box X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show(); } } else { //Update Mode try { //getting the id of the record PostRequest <LeavePayment> request = new PostRequest <LeavePayment>(); request.entity = b; PostResponse <LeavePayment> r = _payrollService.ChildAddOrUpdate <LeavePayment>(request); //Step 1 Selecting the object or building up the object for update purpose //Step 2 : saving to store //Step 3 : Check if request fails if (!r.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { ModelProxy record = this.Store1.GetById(id); BasicInfoTab.UpdateRecord(record); if (date.ReadOnly) { record.Set("date", null); } record.Set("employeeName", b.employeeName); record.Commit(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); this.EditRecordWindow.Close(); } } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } } }
protected void SaveJI(object sender, DirectEventArgs e) { try { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string id = e.ExtraParams["id"]; string obj = e.ExtraParams["values"]; JobInfo b = JsonConvert.DeserializeObject <JobInfo>(obj); b.employeeId = Convert.ToInt32(CurrentEmployee.Text); b.recordId = id; b.date = new DateTime(b.date.Year, b.date.Month, b.date.Day, 14, 0, 0); if (branchId.SelectedItem != null) { b.branchName = branchId.SelectedItem.Text; } if (departmentId.SelectedItem != null) { b.departmentName = departmentId.SelectedItem.Text; } if (positionId.SelectedItem != null) { b.positionName = positionId.SelectedItem.Text; } if (divisionId.SelectedItem != null) { b.divisionName = divisionId.SelectedItem.Text; } // b.reportToName = new EmployeeName(); if (reportToId.SelectedItem != null) { b.reportToName = reportToId.SelectedItem.Text; } // Define the object to add or edit as null if (b.reportToId == 0) { b.reportToId = null; } if (string.IsNullOrEmpty(id)) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <JobInfo> request = new PostRequest <JobInfo>(); request.entity = b; PostResponse <JobInfo> r = _employeeService.ChildAddOrUpdate <JobInfo>(request); b.recordId = r.recordId; //check if the insert failed if (!r.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r);; return; } else { //Add this record to the store JIStore.Reload(); //Display successful notification Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); this.EditJobInfoWindow.Close(); RowSelectionModel sm = this.JobInfoGrid.GetSelectionModel() as RowSelectionModel; sm.DeselectAll(); sm.Select(b.recordId.ToString()); } } catch (Exception ex) { //Error exception displaying a messsage box X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show(); } } else { //Update Mode try { int index = Convert.ToInt32(id);//getting the id of the record PostRequest <JobInfo> request = new PostRequest <JobInfo>(); request.entity = b; PostResponse <JobInfo> r = _employeeService.ChildAddOrUpdate <JobInfo>(request); //Step 1 Selecting the object or building up the object for update purpose //Step 2 : saving to store //Step 3 : Check if request fails if (!r.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r);; return; } else { ModelProxy record = this.JIStore.GetById(index); EditJobInfoTab.UpdateRecord(record); record.Set("departmentName", b.departmentName); record.Set("branchName", b.branchName); record.Set("positionName", b.positionName); record.Set("divisionName", b.divisionName); record.Set("reportToName", b.reportToName); record.Commit(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); JIStore.Reload(); this.EditJobInfoWindow.Close(); } } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } } X.Call("parent.refreshQV"); X.Call("parent.SetJobInfo", b.departmentId, b.branchId, b.positionId, b.divisionId, b.reportToId); } catch (Exception exp) { X.Msg.Alert(Resources.Common.Error, exp.Message).Show(); } }
protected void SaveEH(object sender, DirectEventArgs e) { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string id = e.ExtraParams["id"]; string obj = e.ExtraParams["values"]; EmploymentHistory b = JsonConvert.DeserializeObject <EmploymentHistory>(obj); b.employeeId = Convert.ToInt32(CurrentEmployee.Text); b.recordId = id; // Define the object to add or edit as null b.statusName = statusId.SelectedItem.Text; b.date = new DateTime(b.date.Year, b.date.Month, b.date.Day, 14, 0, 0); if (string.IsNullOrEmpty(id)) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <EmploymentHistory> request = new PostRequest <EmploymentHistory>(); request.entity = b; PostResponse <EmploymentHistory> r = _employeeService.ChildAddOrUpdate <EmploymentHistory>(request); b.recordId = r.recordId; //check if the insert failed if (!r.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { //Add this record to the store this.employeementHistoryStore.Insert(0, b); //Display successful notification Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); this.EditEHwindow.Close(); RowSelectionModel sm = this.employeementHistoryGrid.GetSelectionModel() as RowSelectionModel; sm.DeselectAll(); sm.Select(b.recordId.ToString()); EHCount.Text = (Convert.ToInt32(EHCount.Text) + 1).ToString(); } } catch (Exception ex) { //Error exception displaying a messsage box X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show(); } } else { //Update Mode try { int index = Convert.ToInt32(id);//getting the id of the record PostRequest <EmploymentHistory> request = new PostRequest <EmploymentHistory>(); request.entity = b; PostResponse <EmploymentHistory> r = _employeeService.ChildAddOrUpdate <EmploymentHistory>(request); //Step 1 Selecting the object or building up the object for update purpose //Step 2 : saving to store //Step 3 : Check if request fails if (!r.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { ModelProxy record = this.employeementHistoryStore.GetById(index); record.Set("date", b.date.ToShortDateString()); record.Set("statusName", b.statusName); EditEHForm.UpdateRecord(record); record.Commit(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); this.EditEHwindow.Close(); } } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } } X.Call("parent.refreshQV"); }
protected void SaveNewRecord(object sender, DirectEventArgs e) { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string id = e.ExtraParams["id"]; string obj = e.ExtraParams["values"]; Employee b = JsonConvert.DeserializeObject <Employee>(obj); b.name = new EmployeeName() { firstName = firstName.Text, lastName = lastName.Text, familyName = familyName.Text, middleName = middleName.Text }; b.isInactive = isInactive.Checked; b.recordId = id; // Define the object to add or edit as null if (branchId.SelectedItem != null) { b.branchName = branchId.SelectedItem.Text; } if (departmentId.SelectedItem != null) { b.departmentName = departmentId.SelectedItem.Text; } if (positionId.SelectedItem != null) { b.positionName = positionId.SelectedItem.Text; } b.name.fullName = b.name.firstName + " " + b.name.middleName + " " + b.name.lastName + " "; if (string.IsNullOrEmpty(id)) { try { //New Mode //Step 1 : Fill The object and insert in the store EmployeeAddOrUpdateRequest request = new EmployeeAddOrUpdateRequest(); byte[] fileData = null; if (picturePath.PostedFile != null && picturePath.PostedFile.ContentLength > 0) { using (var binaryReader = new BinaryReader(picturePath.PostedFile.InputStream)) { fileData = binaryReader.ReadBytes(picturePath.PostedFile.ContentLength); } request.fileName = picturePath.PostedFile.FileName; request.imageData = fileData; } else { request.imageData = fileData; request.fileName = ""; } request.empData = b; PostResponse <Employee> r = _employeeService.AddOrUpdateEmployeeWithPhoto(request); b.recordId = r.recordId; //check if the insert failed if (!r.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, r.Summary).Show(); return; } else { //Add this record to the store this.Store1.Insert(0, b); //Display successful notification Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); this.EditRecordWindow.Close(); RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel; sm.DeselectAll(); sm.Select(b.recordId.ToString()); } } catch (Exception ex) { //Error exception displaying a messsage box X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show(); } } else { //Update Mode try { int index = Convert.ToInt32(id);//getting the id of the record EmployeeAddOrUpdateRequest request = new EmployeeAddOrUpdateRequest(); byte[] fileData = null; if (picturePath.HasFile && picturePath.PostedFile.ContentLength > 0) { //using (var binaryReader = new BinaryReader(picturePath.PostedFile.InputStream)) // { // fileData = binaryReader.ReadBytes(picturePath.PostedFile.ContentLength); // } fileData = new byte[picturePath.PostedFile.ContentLength]; fileData = picturePath.FileBytes; request.fileName = picturePath.PostedFile.FileName; request.imageData = fileData; } else { request.imageData = fileData; request.fileName = ""; } request.empData = b; PostResponse <Employee> r = _employeeService.AddOrUpdateEmployeeWithPhoto(request); //Step 2 : saving to store //Step 3 : Check if request fails if (!r.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); return; } else { ModelProxy record = this.Store1.GetById(index); //BasicInfoTab.UpdateRecord(record); record.Set("branchName", b.branchName); record.Set("departmentName", b.departmentName); record.Set("positionName", b.positionName); record.Set("name", b.name); record.Set("reference", b.reference); record.Set("hireDate", b.hireDate.Value.ToShortDateString()); record.Commit(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); this.EditRecordWindow.Close(); } } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } } }
protected void SaveNewRecord(object sender, DirectEventArgs e) { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string obj = e.ExtraParams["values"]; MediaItem b = JsonConvert.DeserializeObject <MediaItem>(obj); string id = e.ExtraParams["id"]; string url = e.ExtraParams["url"]; // Define the object to add or edit as null if (mcId.SelectedItem != null) { b.mcName = mcId.SelectedItem.Text; } if (departmentId.SelectedItem != null) { b.departmentName = departmentId.SelectedItem.Text; } if (string.IsNullOrEmpty(id)) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <MediaItem> request = new PostRequest <MediaItem>(); request.entity = b; byte[] fileData = null; if (rwFile.PostedFile != null && rwFile.PostedFile.ContentLength > 0) { //using (var binaryReader = new BinaryReader(picturePath.PostedFile.InputStream)) //{ // fileData = binaryReader.ReadBytes(picturePath.PostedFile.ContentLength); //} fileData = new byte[rwFile.PostedFile.ContentLength]; fileData = rwFile.FileBytes; } PostResponse <MediaItem> r = _mediaGalleryService.ChildAddOrUpdate <MediaItem>(request); b.recordId = r.recordId; //check if the insert failed if (!r.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", r.ErrorCode) != null ? GetGlobalResourceObject("Errors", r.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + r.LogId : r.Summary).Show(); return; } else { if (fileData != null) { SystemAttachmentsPostRequest req = new SystemAttachmentsPostRequest(); req.entity = new Model.System.Attachement() { date = DateTime.Now, classId = ClassId.MGME, recordId = Convert.ToInt32(b.recordId), fileName = rwFile.PostedFile.FileName, seqNo = null }; req.FileNames.Add(rwFile.PostedFile.FileName); req.FilesData.Add(fileData); PostResponse <Attachement> resp = _systemService.UploadMultipleAttachments(req); if (!resp.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", r.ErrorCode) != null ? GetGlobalResourceObject("Errors", r.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + r.LogId : r.Summary).Show(); return; } } b.recordId = r.recordId; //Add this record to the store MediaItem m = GetMEById(r.recordId); Store1.Insert(0, m); //Display successful notification Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); this.EditRecordWindow.Close(); RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel; sm.DeselectAll(); sm.Select(b.recordId.ToString()); } } catch (Exception ex) { //Error exception displaying a messsage box X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show(); } } else { //Update Mode try { //getting the id of the record int index = Convert.ToInt32(id);//getting the id of the record PostRequest <MediaItem> request = new PostRequest <MediaItem>(); request.entity = b; byte[] fileData = null; if (rwFile.PostedFile != null && rwFile.PostedFile.ContentLength > 0) { fileData = new byte[rwFile.PostedFile.ContentLength]; fileData = rwFile.FileBytes; } PostResponse <MediaItem> r = _mediaGalleryService.ChildAddOrUpdate <MediaItem>(request); //Step 1 Selecting the object or building up the object for update purpose //Step 2 : saving to store //Step 3 : Check if request fails if (!r.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", r.ErrorCode) != null ? GetGlobalResourceObject("Errors", r.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + r.LogId : r.Summary).Show(); return; } else { if (fileData != null) { SystemAttachmentsPostRequest req = new SystemAttachmentsPostRequest(); req.entity = new Model.System.Attachement() { date = DateTime.Now, classId = ClassId.MGME, recordId = Convert.ToInt32(b.recordId), fileName = rwFile.PostedFile.FileName, seqNo = 0 }; req.FileNames.Add(rwFile.PostedFile.FileName); req.FilesData.Add(fileData); PostResponse <Attachement> resp = _systemService.UploadMultipleAttachments(req); if (!resp.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", r.ErrorCode) != null ? GetGlobalResourceObject("Errors", r.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + r.LogId : r.Summary).Show(); return; } } MediaItem m = GetMEById(id); ModelProxy record = this.Store1.GetById(id); BasicInfoTab.UpdateRecord(record); record.Set("mcName", b.mcName); record.Set("departmentName", b.departmentName); recordId.Set("pictureUrl", m.pictureUrl); record.Commit(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); this.EditRecordWindow.Close(); } } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } } }
protected void SaveBC(object sender, DirectEventArgs e) { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string id = e.ExtraParams["id"]; string obj = e.ExtraParams["values"]; string bcFileURl = e.ExtraParams["BcFile"]; EmployeeBackgroundCheck b = JsonConvert.DeserializeObject <EmployeeBackgroundCheck>(obj); b.fileUrl = bcFileURl; if (!string.IsNullOrEmpty(b.fileUrl)) { b.fileUrl = Regex.Replace(b.fileUrl, @"[^0-9a-zA-Z.]+", ""); } b.employeeId = Convert.ToInt32(CurrentEmployee.Text); b.recordId = id; b.date = new DateTime(b.date.Year, b.date.Month, b.date.Day, 14, 0, 0); b.expiryDate = new DateTime(b.expiryDate.Year, b.expiryDate.Month, b.expiryDate.Day, 14, 0, 0); if (ctId.SelectedItem != null) { b.ctName = ctId.SelectedItem.Text; } if (string.IsNullOrEmpty(id)) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <EmployeeBackgroundCheck> request = new PostRequest <EmployeeBackgroundCheck>(); request.entity = b; byte[] fileData = null; if (bcFile.PostedFile != null && bcFile.PostedFile.ContentLength > 0) { //using (var binaryReader = new BinaryReader(picturePath.PostedFile.InputStream)) //{ // fileData = binaryReader.ReadBytes(picturePath.PostedFile.ContentLength); //} fileData = new byte[bcFile.PostedFile.ContentLength]; fileData = bcFile.FileBytes; } else { fileData = null; } PostResponse <EmployeeBackgroundCheck> r = _employeeService.ChildAddOrUpdate <EmployeeBackgroundCheck>(request); b.recordId = r.recordId; //check if the insert failed if (!r.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { //Add this record to the store if (fileData != null) { SystemAttachmentsPostRequest req = new SystemAttachmentsPostRequest(); req.entity = new Model.System.Attachement() { date = DateTime.Now, classId = ClassId.EPBC, recordId = Convert.ToInt32(b.recordId), fileName = bcFile.PostedFile.FileName, seqNo = 0 }; req.FileNames.Add(bcFile.PostedFile.FileName); req.FilesData.Add(fileData); PostResponse <Attachement> resp = _systemService.UploadMultipleAttachments(req); if (!resp.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } } EmployeeBackgroundCheck bc = GetBCById(r.recordId); this.BCStore.Insert(0, bc); //Display successful notification Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); this.EditBCWindow.Close(); RowSelectionModel sm = this.BackgroundCheckGrid.GetSelectionModel() as RowSelectionModel; sm.DeselectAll(); sm.Select(b.recordId.ToString()); } } catch (Exception ex) { //Error exception displaying a messsage box X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show(); } } else { //Update Mode try { int index = Convert.ToInt32(id);//getting the id of the record PostRequest <EmployeeBackgroundCheck> request = new PostRequest <EmployeeBackgroundCheck>(); request.entity = b; byte[] fileData = null; if (bcFile.PostedFile != null && bcFile.PostedFile.ContentLength > 0) { //using (var binaryReader = new BinaryReader(picturePath.PostedFile.InputStream)) //{ // fileData = binaryReader.ReadBytes(picturePath.PostedFile.ContentLength); //} fileData = new byte[bcFile.PostedFile.ContentLength]; fileData = bcFile.FileBytes; } PostResponse <EmployeeBackgroundCheck> r = _employeeService.ChildAddOrUpdate <EmployeeBackgroundCheck>(request); //Step 1 Selecting the object or building up the object for update purpose //Step 2 : saving to store //Step 3 : Check if request fails if (!r.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { if (fileData != null) { SystemAttachmentsPostRequest req = new SystemAttachmentsPostRequest(); req.entity = new Model.System.Attachement() { date = DateTime.Now, classId = ClassId.EPBC, recordId = Convert.ToInt32(b.recordId), fileName = bcFile.PostedFile.FileName, seqNo = 0 }; req.FileNames.Add(Regex.Replace(bcFile.PostedFile.FileName, @"[^0-9a-zA-Z.]+", "")); req.FilesData.Add(fileData); PostResponse <Attachement> resp = _systemService.UploadMultipleAttachments(req); if (!resp.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } } EmployeeBackgroundCheck BC = GetBCById(b.recordId); ModelProxy record = this.BCStore.GetById(id); record.Set("expiryDate", BC.expiryDate); record.Set("fileUrl", BC.fileUrl); record.Set("ctId", BC.ctId); record.Set("ctName", BC.ctName); record.Set("remarks", BC.remarks); record.Commit(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); this.EditBCWindow.Close(); } } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } } //if (b.Date.Date == DateTime.Today) //{ // X.Call("parent.FillLeftPanel", b.departmentName + "<br/>", b.branchName + "<br/>", b.positionName + "<br/>"); // X.Call("parent.SelectJICombos", b.departmentId, b.branchId, b.positionId, b.divisionId); //} }
protected void SaveDayBreaks(object sender, DirectEventArgs e) { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string dayJ = e.ExtraParams["day"]; string breaksJ = e.ExtraParams["breaks"]; AttendanceScheduleDay day = JsonConvert.DeserializeObject <AttendanceScheduleDay>(dayJ); bool workingDay = IsWorkingDay.Text == "True"; List <AttendanceBreak> breaks = null; if (workingDay) { breaks = JsonConvert.DeserializeObject <List <AttendanceBreak> >(breaksJ); } else { day.firstIn = "00:00"; day.lastOut = "00:00"; } day.scId = Convert.ToInt32(e.ExtraParams["scId"]); day.dow = Convert.ToInt16(CurrentDow.Text); // Define the object to add or edit as null try { //getting the id of the record PostRequest <AttendanceScheduleDay> modifyHeaderRequest = new PostRequest <AttendanceScheduleDay>(); modifyHeaderRequest.entity = day; PostResponse <AttendanceScheduleDay> r = _branchService.ChildAddOrUpdate <AttendanceScheduleDay>(modifyHeaderRequest); //Step 1 Selecting the object or building up the object for update purpose if (!r.Success) //it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, r.Summary).Show(); return; } if (workingDay) { PostResponse <AttendanceBreak> deleteResponse = _branchService.DeleteDayBreaks(day.scId, day.dow); if (!deleteResponse.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, deleteResponse.Summary).Show(); return; } try { AddBreaksList(day.scId.ToString(), day.dow, breaks); } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, r.Summary).Show(); return; } } ModelProxy record = this.scheduleStore.GetById(day.dow); dayBreaksForm.UpdateRecord(record); if (!workingDay) { record.Set("firstIn", "00:00"); record.Set("lastOut", "00:00"); } record.Commit(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); this.EditDayBreaks.Close(); } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } }
protected void SaveFolder(object sender, DirectEventArgs e) { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string id = e.ExtraParams["id"]; string obj = e.ExtraParams["values"]; Attachement b = JsonConvert.DeserializeObject <Attachement>(obj); b.recordId = 0; b.seqNo = Convert.ToInt16(id); b.classId = ClassId.DMDO; b.fileName = fileName.Text; // Define the object to add or edit as null b.folderName = folderId.SelectedItem.Text; try { //New Mode PostRequest <Attachement> req = new PostRequest <Attachement>(); req.entity = b; PostResponse <Attachement> r = _systemService.ChildAddOrUpdate <Attachement>(req); //check if the insert failed if (!r.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { ModelProxy record = this.Store1.GetById(id); EditDocumentForm.UpdateRecord(record); record.Set("folderName", b.folderName); record.Commit(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); this.EditDocumentWindow.Close(); } } catch (Exception ex) { //Error exception displaying a messsage box X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show(); } }
protected void SaveNewRecord(object sender, DirectEventArgs e) { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string obj = e.ExtraParams["values"]; JsonSerializerSettings s = new JsonSerializerSettings(); s.NullValueHandling = NullValueHandling.Ignore; Geofence b = JsonConvert.DeserializeObject <Geofence>(obj, s); if (branchId.SelectedItem != null) { b.branchName = branchId.SelectedItem.Text; } string id = e.ExtraParams["id"]; b.shape = (short)(e.ExtraParams["isCircle"] == "true"?1:0); b.lat = Convert.ToDouble(e.ExtraParams["lat1"]); b.lon = Convert.ToDouble(e.ExtraParams["lon1"]); if (b.shape == 1) { b.radius = Convert.ToDouble(e.ExtraParams["radius"]); b.lat2 = 0; b.lon2 = 0; } else { b.lat2 = Convert.ToDouble(e.ExtraParams["lat2"]); b.lon2 = Convert.ToDouble(e.ExtraParams["lon2"]); b.radius = 0; } // Define the object to add or edit as null if (string.IsNullOrEmpty(id)) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <Geofence> request = new PostRequest <Geofence>(); request.entity = b; PostResponse <Geofence> r = _timeAttendanceService.ChildAddOrUpdate <Geofence>(request); //check if the insert failed if (!r.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { b.recordId = r.recordId; //Add this record to the store this.Store1.Insert(0, b); //Display successful notification Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); this.EditRecordWindow.Close(); RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel; sm.DeselectAll(); sm.Select(b.recordId.ToString()); } } catch (Exception ex) { //Error exception displaying a messsage box X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show(); } } else { //Update Mode try { //getting the id of the record PostRequest <Geofence> request = new PostRequest <Geofence>(); request.entity = b; PostResponse <Geofence> r = _timeAttendanceService.ChildAddOrUpdate <Geofence>(request); //Step 1 Selecting the object or building up the object for update purpose //Step 2 : saving to store //Step 3 : Check if request fails if (!r.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); return; } else { ModelProxy record = this.Store1.GetById(id); BasicInfoTab.UpdateRecord(record); record.Set("branchName", b.branchName); record.Commit(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); this.EditRecordWindow.Close(); } } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } } }