protected void SaveCalendarYear(object sender, DirectEventArgs e) { string caId = e.ExtraParams["caId"]; string year = e.ExtraParams["year"]; CalendarYear b = JsonConvert.DeserializeObject <CalendarYear>(year); b.caId = Convert.ToInt32(CurrentCalendar.Text); PostRequest <CalendarYear> request = new PostRequest <CalendarYear>(); request.entity = b; PostResponse <CalendarYear> response = _branchService.ChildAddOrUpdate <CalendarYear>(request); if (!response.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(response); return; } //Step 2 : saving to store else { this.scheduleStore.Insert(0, b); //Display successful notification Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); this.EditYearDetails.Close(); RowSelectionModel sm = this.calendarYears.GetSelectionModel() as RowSelectionModel; sm.DeselectAll(); sm.Select(b.year.ToString()); } }
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["schedule"]; AttendanceSchedule b = JsonConvert.DeserializeObject <AttendanceSchedule>(obj); if (!b.fci_max_lt.HasValue) { b.fci_max_lt = 0; } if (!b.fci_min_ot.HasValue) { b.fci_min_ot = 0; } if (!b.lco_max_el.HasValue) { b.lco_max_el = 0; } if (!b.lco_max_ot.HasValue) { b.lco_max_ot = 0; } if (!b.lco_min_ot.HasValue) { b.lco_min_ot = 0; } 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 <AttendanceSchedule> request = new PostRequest <AttendanceSchedule>(); request.entity = b; PostResponse <AttendanceSchedule> r = _branchService.ChildAddOrUpdate <AttendanceSchedule>(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.Store1.Insert(0, b); //Display successful notification Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); // setDefaultBtn.Hidden = false; recordId.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 { int index = Convert.ToInt32(id);//getting the id of the record PostRequest <AttendanceSchedule> modifyHeaderRequest = new PostRequest <AttendanceSchedule>(); modifyHeaderRequest.entity = b; PostResponse <AttendanceSchedule> r = _branchService.ChildAddOrUpdate <AttendanceSchedule>(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, Resources.Common.ErrorUpdatingRecord).Show(); return; } //Step 2 : saving to store else { ModelProxy record = this.Store1.GetById(index); 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 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["schedule"]; LeaveSchedule b = JsonConvert.DeserializeObject <LeaveSchedule>(obj); string pers = e.ExtraParams["periods"]; 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 <LeaveSchedule> request = new PostRequest <LeaveSchedule>(); request.entity = b; PostResponse <LeaveSchedule> r = _branchService.ChildAddOrUpdate <LeaveSchedule>(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; } List <LeaveSchedulePeriod> periods = JsonConvert.DeserializeObject <List <LeaveSchedulePeriod> >(pers); bool Success = AddPeriodsList(b.recordId, periods); if (Success) { //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 <LeaveSchedule> modifyHeaderRequest = new PostRequest <LeaveSchedule>(); modifyHeaderRequest.entity = b; PostResponse <LeaveSchedule> r = _branchService.ChildAddOrUpdate <LeaveSchedule>(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, Resources.Common.ErrorUpdatingRecord).Show(); return; } LeaveSchedulesListRequest leaveScheduleReq = new LeaveSchedulesListRequest(); leaveScheduleReq.LeaveScheduleId = b.recordId; ListResponse <LeaveSchedulePeriod> leaveScheduleResponse = _branchService.ChildGetAll <LeaveSchedulePeriod>(leaveScheduleReq); leaveScheduleResponse.Items.ForEach(x => { PostRequest <LeaveSchedulePeriod> LeaveScheduleDEleteRequest = new PostRequest <LeaveSchedulePeriod>(); LeaveScheduleDEleteRequest.entity = x; PostResponse <LeaveSchedulePeriod> LeaveScheduleDEleteResponse = _branchService.ChildDelete <LeaveSchedulePeriod>(LeaveScheduleDEleteRequest); if (!LeaveScheduleDEleteResponse.Success) { Common.errorMessage(LeaveScheduleDEleteResponse); throw new Exception(); } }); List <LeaveSchedulePeriod> periods = JsonConvert.DeserializeObject <List <LeaveSchedulePeriod> >(pers); bool result = AddPeriodsList(b.recordId, periods); //Step 2 : saving to store //Step 3 : Check if request fails if (result) { ModelProxy record = this.Store1.GetById(index); 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 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"]; 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(); } } }
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["schedule"]; PayrollIndemnity b = JsonConvert.DeserializeObject <PayrollIndemnity>(obj); string pers = e.ExtraParams["periods"]; string indemnities = e.ExtraParams["indemnities"]; b.recordId = id; // Define the object to add or edit as null List <PayrollIndemnityDetails> periods = JsonConvert.DeserializeObject <List <PayrollIndemnityDetails> >(pers); List <PayrollIndemnityRecognition> indemnitiesList = JsonConvert.DeserializeObject <List <PayrollIndemnityRecognition> >(indemnities); if (periods == null || periods.Count == 0 || indemnitiesList == null || indemnitiesList.Count == 0) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", "Error_Empty_IndemnityDetails_IndemnityResignation")).Show(); return; } if (string.IsNullOrEmpty(id)) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <PayrollIndemnity> request = new PostRequest <PayrollIndemnity>(); request.entity = b; PostResponse <PayrollIndemnity> r = _payrollService.ChildAddOrUpdate <PayrollIndemnity>(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; } PostResponse <PayrollIndemnityDetails[]> result = AddPeriodsList(b.recordId, periods); // AddPeriodsList1(b.recordId, periods); if (!result.Success) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", result.ErrorCode) != null ? GetGlobalResourceObject("Errors", result.ErrorCode).ToString() : GetGlobalResourceObject("Errors", result.ErrorCode) != null ? GetGlobalResourceObject("Errors", result.ErrorCode).ToString() : result.Summary).Show(); return; } PostResponse <PayrollIndemnityRecognition[]> result1 = AddindemnitiesList(b.recordId, indemnitiesList); // AddPeriodsList1(b.recordId, periods); if (!result1.Success) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", result.ErrorCode) != null ? GetGlobalResourceObject("Errors", result.ErrorCode).ToString() : GetGlobalResourceObject("Errors", result.ErrorCode) != null ? GetGlobalResourceObject("Errors", result.ErrorCode).ToString() : result.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 <PayrollIndemnity> modifyHeaderRequest = new PostRequest <PayrollIndemnity>(); modifyHeaderRequest.entity = b; PostResponse <PayrollIndemnity> r = _payrollService.ChildAddOrUpdate <PayrollIndemnity>(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, Resources.Common.ErrorUpdatingRecord).Show(); return; } //List<PayrollIndemnityDetails> periods = JsonConvert.DeserializeObject<List<PayrollIndemnityDetails>>(pers); //List<PayrollIndemnityRecognition> indemnitiesList = JsonConvert.DeserializeObject<List<PayrollIndemnityRecognition>>(indemnities); //if (periods == null || periods.Count == 0 || indemnitiesList == null || indemnitiesList.Count == 0) //{ // X.MessageBox.ButtonText.Ok = Resources.Common.Ok; // X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", "Error_Empty_IndemnityDetails_IndemnityResignation")).Show(); // return; //} //_payrollService.DeleteVacationSchedulePeriods(Convert.ToInt32(b.recordId)); DeleteVacationSchedulePeriods(Convert.ToInt32(b.recordId)); //if (!deleteDesponse.Success)//it maybe another check // { // X.MessageBox.ButtonText.Ok = Resources.Common.Ok; // X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", deleteDesponse.ErrorCode) != null ? GetGlobalResourceObject("Errors", deleteDesponse.ErrorCode).ToString() : deleteDesponse.Summary).Show(); // return; // } PostResponse <PayrollIndemnityDetails[]> result = AddPeriodsList(b.recordId, periods); //Step 2 : saving to store //Step 3 : Check if request fails if (!result.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", result.ErrorCode) != null ? GetGlobalResourceObject("Errors", result.ErrorCode).ToString() : result.Summary).Show(); return; } PostResponse <PayrollIndemnityRecognition[]> result1 = AddindemnitiesList(b.recordId, indemnitiesList); // AddPeriodsList1(b.recordId, periods); if (!result1.Success) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", result.ErrorCode) != null ? GetGlobalResourceObject("Errors", result.ErrorCode).ToString() : GetGlobalResourceObject("Errors", result.ErrorCode) != null ? GetGlobalResourceObject("Errors", result.ErrorCode).ToString() : result.Summary).Show(); return; } else { ModelProxy record = this.Store1.GetById(index); 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(); } } Store1.Reload(); }
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["schedule"]; FiscalYear b = JsonConvert.DeserializeObject <FiscalYear>(obj); // Define the object to add or edit as null try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <FiscalYear> request = new PostRequest <FiscalYear>(); request.entity = b; if (b.startDate > b.endDate) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, GetLocalResourceObject("ErrorStartEnd").ToString()).Show(); return; } PostResponse <FiscalYear> r = _payrollService.ChildAddOrUpdate <FiscalYear>(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 { //Add this record to the store Store1.Reload(); //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.fiscalYear.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(); } }
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"]; Division b = JsonConvert.DeserializeObject <Division>(obj); // b.isInactive = isInactive.Checked; 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 <Division> request = new PostRequest <Division>(); request.entity = b; PostResponse <Division> r = _branchService.ChildAddOrUpdate <Division>(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 { //Add this record to the store Store1.Reload(); //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 <Division> request = new PostRequest <Division>(); request.entity = b; PostResponse <Division> r = _branchService.ChildAddOrUpdate <Division>(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 { Store1.Reload(); 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"]; 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 SaveCO(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"]; JsonSerializerSettings settings = new JsonSerializerSettings(); CustomResolver res = new CustomResolver(); res.AddRule("conaId", "naId"); res.AddRule("costId", "stateId"); res.AddRule("costreet1", "addressId.street1"); res.AddRule("localphone", "addressId.phone"); settings.ContractResolver = res; EmployeeContact b = JsonConvert.DeserializeObject <EmployeeContact>(obj, settings); b.employeeId = Convert.ToInt32(CurrentEmployee.Text); b.recordId = id; // Define the object to add or edit as null b.rtName = rtId.SelectedItem.Text; b.address = new AddressBook() { street1 = costreet1.Text, street2 = costreet2.Text, city = cocity.Text, postalCode = copostalCode.Text, countryId = b.naId, stateId = b.stateId, countryName = conaId.SelectedItem.Text, phone = localphone.Text }; b.address.recordId = coaddressId.Text; b.employeeId = Convert.ToInt32(CurrentEmployee.Text); if (string.IsNullOrEmpty(id)) { try { //New Mode PostRequest <EmployeeContact> request = new PostRequest <EmployeeContact>(); request.entity = b; PostResponse <EmployeeContact> r = _employeeService.ChildAddOrUpdate <EmployeeContact>(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.contactStore.Insert(0, b); //Display successful notification Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc, HideDelay = 250 }); this.EditContactWindow.Close(); RowSelectionModel sm = this.contactGrid.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 <EmployeeContact> request = new PostRequest <EmployeeContact>(); request.entity = b; b.recordId = index.ToString(); PostResponse <EmployeeContact> r = _employeeService.ChildAddOrUpdate <EmployeeContact>(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 { contactStore.Reload(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc, HideDelay = 250 }); this.EditContactWindow.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"]; Department b = JsonConvert.DeserializeObject <Department>(obj); b.scName = scId.SelectedItem.Text; b.recordId = id; b.caName = caId.SelectedItem.Text; // Define the object to add or edit as null if (supervisorId.SelectedItem.Text != null) { b.managerName = supervisorId.SelectedItem.Text; } if (parentId.SelectedItem != null) { b.parentName = parentId.SelectedItem.Text; } if (!b.isInactive.HasValue) { b.isInactive = false; b.activeStatus = (Int16)ActiveStatus.ACTIVE; } else { b.activeStatus = (Int16)ActiveStatus.INACTIVE; } if (scId.SelectedItem != null) { b.scId = scId.SelectedItem.Value; } if (string.IsNullOrEmpty(id)) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <Department> request = new PostRequest <Department>(); request.entity = b; PostResponse <Department> r = _branchService.ChildAddOrUpdate <Department>(request); b.recordId = r.recordId; //check if the insert failed if (!r.Success)//it maybe be another condition { //Show an error saving... Common.errorMessage(r);; return; } else { //Add this record to the store Store1.Reload(); //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 <Department> request = new PostRequest <Department>(); request.entity = b; PostResponse <Department> r = _branchService.ChildAddOrUpdate <Department>(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); //BasicInfoTab.UpdateRecord(record); //record.Set("managerName", b.managerName); //record.Set("parentName", b.parentName); //record.Set("caName", b.caName); //record.Set("scName", b.scName); //record.Commit(); Store1.Reload(); 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(); } } departmentStore.Reload(); }
protected void SaveNewRecord(object sender, DirectEventArgs e) { SystemDefaultRecordRequest req = new SystemDefaultRecordRequest(); //Getting the id to check if it is an Add or an edit as they are managed within the same form. try { string obj = e.ExtraParams["values"]; string ldMethodParam = e.ExtraParams["ldMethod"]; string ldValueParam = e.ExtraParams["ldValue"]; loanSelfService b = JsonConvert.DeserializeObject <loanSelfService>(obj); string id = e.ExtraParams["id"]; if (string.IsNullOrEmpty(id)) { if (!string.IsNullOrEmpty(ldValueParam)) { b.ldValue = Convert.ToDouble(ldValueParam); } if (!string.IsNullOrEmpty(ldMethodParam)) { b.ldMethod = Convert.ToInt16(ldMethodParam); } if (b.ldMethod == null) { req.Key = "ldMethod"; RecordResponse <KeyValuePair <string, string> > defaults = _systemService.ChildGetRecord <KeyValuePair <string, string> >(req); if (!defaults.Success) { Common.errorMessage(defaults); return; } if (!string.IsNullOrEmpty(defaults.result.Value)) { b.ldMethod = Convert.ToInt16(defaults.result.Value); } } if (b.ldValue == null) { req.Key = "ldValue"; RecordResponse <KeyValuePair <string, string> > ldValueResponse = _systemService.ChildGetRecord <KeyValuePair <string, string> >(req); if (!ldValueResponse.Success) { Common.errorMessage(ldValueResponse); return; } if (!string.IsNullOrEmpty(ldValueResponse.result.Value)) { b.ldValue = Convert.ToInt16(ldValueResponse.result.Value); } } } if (b.ldMethod == null) { X.MessageBox.Alert(GetGlobalResourceObject("Common", "Error").ToString(), GetGlobalResourceObject("Errors", "emptyLdMethod").ToString()).Show(); return; } //if (string.IsNullOrEmpty(ldMethod) //b.ldMethod =Convert.ToInt16( ldMethod); // Define the object to add or edit as null //if (ldMethodCom.SelectedItem != null) // b.ldMethod = ldMethodCom.SelectedItem.Value; if (date.ReadOnly) { b.date = DateTime.Now; } //b.effectiveDate = new DateTime(b.effectiveDate.Year, b.effectiveDate.Month, b.effectiveDate.Day, 14, 0, 0); if (branchId.SelectedItem != null) { b.branchName = branchId.SelectedItem.Text; } if (string.IsNullOrEmpty(id)) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <loanSelfService> request = new PostRequest <loanSelfService>(); request.entity = b; request.entity.employeeId = _systemService.SessionHelper.GetEmployeeId(); // request.entity.employeeName = new EmployeeName() { fullName="" }; request.entity.date = DateTime.Now; //request.entity.ltName = ""; //request.entity.currencyRef = ""; request.entity.apStatus = "1"; PostResponse <loanSelfService> r = _selfServiceService.ChildAddOrUpdate <loanSelfService>(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 { Store1.Reload(); //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()); 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 <loanSelfService> request = new PostRequest <loanSelfService>(); request.entity = b; request.entity.employeeId = _systemService.SessionHelper.GetEmployeeId(); PostResponse <loanSelfService> r = _selfServiceService.ChildAddOrUpdate <loanSelfService>(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 { Store1.Reload(); // ModelProxy record = this.Store1.GetById(id); // BasicInfoTab.UpdateRecord(record); // record.Set("currencyRef", b.currencyRef); // if (date.ReadOnly) // record.Set("date", null); // record.Set("employeeName", b.employeeName); //// 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(); } } } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, ex.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 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 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"]; CertificateLevel b = JsonConvert.DeserializeObject <CertificateLevel>(obj); string id = e.ExtraParams["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 <CertificateLevel> request = new PostRequest <CertificateLevel>(); request.entity = b; PostResponse <CertificateLevel> r = _employeeService.ChildAddOrUpdate <CertificateLevel>(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, 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 }); 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 <CertificateLevel> request = new PostRequest <CertificateLevel>(); request.entity = b; PostResponse <CertificateLevel> r = _employeeService.ChildAddOrUpdate <CertificateLevel>(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, r.Summary).Show(); return; } else { ModelProxy record = this.Store1.GetById(id); 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 id = e.ExtraParams["id"]; string obj = e.ExtraParams["values"]; EmployeePenalty b = JsonConvert.DeserializeObject <EmployeePenalty>(obj); //if (referToPositionId.SelectedItem != null) // b.referToPositionName = referToPositionId.SelectedItem.Text; //if (tsId.SelectedItem != null) // b.tsName = tsId.SelectedItem.Text; b.recordId = CurrentpenaltyId.Text; // Define the object to add or edit as null b.apStatus = string.IsNullOrEmpty(b.apStatus) ? "1" : b.apStatus; if (string.IsNullOrEmpty(CurrentpenaltyId.Text)) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <EmployeePenalty> request = new PostRequest <EmployeePenalty>(); request.entity = b; PostResponse <EmployeePenalty> r = _employeeService.ChildAddOrUpdate <EmployeePenalty>(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 Store1.Reload(); CurrentpenaltyId.Text = b.recordId; //Display successful notification Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); 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 <EmployeePenalty> request = new PostRequest <EmployeePenalty>(); request.entity = b; b.recordId = CurrentpenaltyId.Text; PostResponse <EmployeePenalty> r = _employeeService.ChildAddOrUpdate <EmployeePenalty>(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 { Store1.Reload(); 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(); } } }