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"]; Currency b = JsonConvert.DeserializeObject <Currency>(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 <Currency> request = new PostRequest <Currency>(); request.entity = b; PostResponse <Currency> r = _systemService.ChildAddOrUpdate <Currency>(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 }); 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 <Currency> request = new PostRequest <Currency>(); request.entity = b; PostResponse <Currency> r = _systemService.ChildAddOrUpdate <Currency>(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 { Common.errorMessage(r); 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(); } } }
protected void PoPuP(object sender, DirectEventArgs e) { string id = e.ExtraParams["leaveId"]; string employeeIdParam = e.ExtraParams["employeeId"]; string returnTypeParam = e.ExtraParams["returnType"]; string type = e.ExtraParams["type"]; ApprovalsGridPanel.Disabled = false; switch (type) { case "imgEdit": BasicInfoTab.Reset(); //LeaveRequestListRequest leaveReq = new LeaveRequestListRequest(); //leaveReq.BranchId = 0; //leaveReq.DepartmentId = 0; //leaveReq.raEmployeeId = 0; //leaveReq.EmployeeId = Convert.ToInt32(employeeId.SelectedItem.Value); //leaveReq.status = 2; //leaveReq.Size = "50"; //leaveReq.StartAt = "0"; //leaveReq.SortBy = "recordId"; //leaveReq.Filter = ""; //ListResponse<LeaveRequest> leaveResp = _leaveManagementService.ChildGetAll<LeaveRequest>(leaveReq); //if (!leaveResp.Success) //{ // X.MessageBox.ButtonText.Ok = Resources.Common.Ok; // Common.errorMessage(leaveResp); // return; //} //leaveIdStore.DataSource = leaveResp.Items; //leaveIdStore.DataBind(); LeaveReturnRecordRequest r = new LeaveReturnRecordRequest(); r.leaveId = id; RecordResponse <LeaveReturn> response = _leaveManagementService.ChildGetRecord <LeaveReturn>(r); if (!response.Success) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(response); return; } employeeId.GetStore().Add(new object[] { new { recordId = response.result.employeeId, fullName = response.result.employeeName } }); employeeId.SetValue(response.result.employeeId); employeeId.Select(response.result.employeeId); fillLeavesStore(); //Step 2 : call setvalues with the retrieved object this.BasicInfoTab.SetValues(response.result); FillApprovalsStore(id, employeeIdParam, returnTypeParam); this.EditRecordWindow.Title = Resources.Common.EditWindowsTitle; this.EditRecordWindow.Show(); break; case "imgDelete": X.Msg.Confirm(Resources.Common.Confirmation, Resources.Common.DeleteOneRecord, new MessageBoxButtonsConfig { Yes = new MessageBoxButtonConfig { //We are call a direct request metho for deleting a record Handler = String.Format("App.direct.DeleteRecord({0},{1},{2})", id, employeeIdParam, returnTypeParam), Text = Resources.Common.Yes }, No = new MessageBoxButtonConfig { Text = Resources.Common.No } }).Show(); break; case "imgAttach": //Here will show up a winow relatice to attachement depending on the case we are working on break; default: break; } }
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 PoPuP(object sender, DirectEventArgs e) { ScheduleNamelb.Text = e.ExtraParams["ScheduleNamePar"]; int id = Convert.ToInt32(e.ExtraParams["id"]); string type = e.ExtraParams["type"]; switch (type) { case "imgEdit": ////Step 1 : get the object from the Web Service //panelRecordDetails.ActiveIndex = 0; RecordRequest r = new RecordRequest(); r.RecordID = id.ToString(); RecordResponse <AttendanceSchedule> response = _branchService.ChildGetRecord <AttendanceSchedule>(r); if (!response.Success) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(response); return; } ////Step 2 : call setvalues with the retrieved object BasicInfoTab.Reset(); this.BasicInfoTab.SetValues(response.result); //_systemService.SessionHelper.Set("currentSchedule",r.RecordID); //// InitCombos(response.result); // setDefaultBtn.Hidden = false; this.EditRecordWindow.Title = Resources.Common.EditWindowsTitle; this.EditRecordWindow.Show(); //FillDow("1"); break; case "imgAttach": //panelRecordDetails.ActiveIndex = 0; AttendanceScheduleDayListRequest daysRequest = new AttendanceScheduleDayListRequest(); daysRequest.ScheduleId = id.ToString(); ListResponse <AttendanceScheduleDay> daysResponse = _branchService.ChildGetAll <AttendanceScheduleDay>(daysRequest); if (!daysResponse.Success) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, daysResponse.Summary).Show(); return; } //Step 2 : call setvalues with the retrieved object scheduleDays.Store[0].DataSource = daysResponse.Items; scheduleDays.Store[0].DataBind(); CurrentSchedule.Text = id.ToString(); Viewport1.ActiveIndex = 1; // InitCombos(response.result); break; case "imgDelete": X.Msg.Confirm(Resources.Common.Confirmation, Resources.Common.DeleteOneRecord, new MessageBoxButtonsConfig { Yes = new MessageBoxButtonConfig { //We are call a direct request metho for deleting a record Handler = String.Format("App.direct.DeleteRecord({0})", id), Text = Resources.Common.Yes }, No = new MessageBoxButtonConfig { Text = Resources.Common.No } }).Show(); break; case "colAttach": //Here will show up a winow relatice to attachement depending on the case we are working on break; default: break; } }
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 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 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 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 PoPuP(object sender, DirectEventArgs e) { FillBranch(); FillDepartment(); BasicInfoTab.Reset(); panelRecordDetails.ActiveIndex = 0; ApprovalsGridPanel.Disabled = false; int id = Convert.ToInt32(e.ExtraParams["id"]); currentPurchaseOrderId.Text = id.ToString(); string type = e.ExtraParams["type"]; switch (type) { case "imgEdit": ApprovalStore.Reload(); //Step 1 : get the object from the Web Service RecordRequest r = new RecordRequest(); r.RecordID = id.ToString(); RecordResponse <AssetManagementPurchaseOrder> response = _assetManagementService.ChildGetRecord <AssetManagementPurchaseOrder>(r); if (!response.Success) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(response); return; } //Step 2 : call setvalues with the retrieved object employeeId.GetStore().Add(new object[] { new { recordId = response.result.employeeId, fullName = response.result.employeeName } }); employeeId.SetValue(response.result.employeeId); this.BasicInfoTab.SetValues(response.result); supplierId.setSupplier(response.result.supplierId); categoryId.setCategory(response.result.categoryId); if (!string.IsNullOrEmpty(response.result.currencyId)) { CurrencyControl.setCurrency(response.result.currencyId); } //if (response.result.status == null) //{ // status.Select("1"); // status.SetValue("1"); //} apStatus.setApprovalStatus("1"); this.EditRecordWindow.Title = Resources.Common.EditWindowsTitle; this.EditRecordWindow.Show(); break; case "imgDelete": X.Msg.Confirm(Resources.Common.Confirmation, Resources.Common.DeleteOneRecord, new MessageBoxButtonsConfig { Yes = new MessageBoxButtonConfig { //We are call a direct request metho for deleting a record Handler = String.Format("App.direct.DeleteRecord({0})", id), Text = Resources.Common.Yes }, No = new MessageBoxButtonConfig { Text = Resources.Common.No } }).Show(); break; case "imgAttach": //Here will show up a winow relatice to attachement depending on the case we are working on break; default: break; } }
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 PoPuP(object sender, DirectEventArgs e) { try { BasicInfoTab.Reset(); FillDamageStore(); string id = e.ExtraParams["id"]; int dayId = Convert.ToInt32(e.ExtraParams["dayId"]); int employeeId = Convert.ToInt32(e.ExtraParams["employeeId"]); string damageLavel = e.ExtraParams["damage"]; string durationValue = e.ExtraParams["duration"]; string timeCodeParameter = e.ExtraParams["timeCode"]; string shiftId = e.ExtraParams["shiftId"]; string apStatus = e.ExtraParams["apStatus"]; string type = e.ExtraParams["type"]; string justificationParam = e.ExtraParams["justification"]; string clockDuration = e.ExtraParams["clockDuration"]; string arId = e.ExtraParams["arId"]; switch (type) { case "imgEdit": //Step 1 : get the object from the Web Service //Step 2 : call setvalues with the retrieved object damage.Select(damageLavel); duration.Text = durationValue; clock.Text = clockDuration; // recordId.Text = id; justification.Text = justificationParam; TimeApprovalReasonControl.setApprovalReason(arId); if (apStatus == "2" || apStatus == "-1") { disableEditing(false); } else { disableEditing(true); } recordId.Text = id; this.EditRecordWindow.Title = Resources.Common.EditWindowsTitle; this.EditRecordWindow.Show(); break; case "imgDelete": X.Msg.Confirm(Resources.Common.Confirmation, Resources.Common.DeleteOneRecord, new MessageBoxButtonsConfig { Yes = new MessageBoxButtonConfig { //We are call a direct request metho for deleting a record Handler = String.Format("App.direct.DeleteRecord({0})", id), Text = Resources.Common.Yes }, No = new MessageBoxButtonConfig { Text = Resources.Common.No } }).Show(); break; case "imgReject": X.Msg.Confirm(Resources.Common.Confirmation, GetLocalResourceObject("RejectRecord").ToString(), new MessageBoxButtonsConfig { Yes = new MessageBoxButtonConfig { //We are call a direct request metho for deleting a record Handler = String.Format("App.direct.RejectRecord({0})", id), Text = Resources.Common.Yes }, No = new MessageBoxButtonConfig { Text = Resources.Common.No } }).Show(); break; case "imgAttach": overrideForm.Reset(); RecordRequest req = new RecordRequest(); //req.employeeId = employeeId.ToString(); //req.dayId = dayId.ToString(); //req.shiftId = shiftId; //req.timeCode = timeCodeParameter; req.RecordID = id; RecordResponse <DashBoardTimeVariation> resp = _timeAttendanceService.ChildGetRecord <DashBoardTimeVariation>(req); if (!resp.Success) { Common.errorMessage(resp); return; } ORId.Text = resp.result.recordId; timeCodeStore.DataSource = ConstTimeVariationType.TimeCodeList(_systemService).Where(x => x.key == Convert.ToInt32(timeCodeParameter)).ToList(); timeCodeStore.DataBind(); FillBranch(); EmployeeQuickViewRecordRequest QVReq = new EmployeeQuickViewRecordRequest(); QVReq.RecordID = employeeId.ToString(); QVReq.asOfDate = DateTime.Now; RecordResponse <EmployeeQuickView> qv = _employeeService.ChildGetRecord <EmployeeQuickView>(QVReq); if (!qv.Success) { Common.errorMessage(qv); return; } overrideForm.SetValues(resp.result); branchId.Select(qv.result.branchId); ListRequest UdIdReq = new ListRequest(); UdIdReq.Filter = ""; ListResponse <BiometricDevice> UdIdResp = _timeAttendanceService.ChildGetAll <BiometricDevice>(UdIdReq); if (!UdIdResp.Success) { Common.errorMessage(UdIdResp); return; } udIdStore.DataSource = UdIdResp.Items; udIdStore.DataBind(); FlatPunchesListRequest FPreq = new FlatPunchesListRequest(); FPreq.shiftId = shiftId; FPreq.sortBy = "clockStamp"; FPreq.StartAt = "0"; FPreq.Size = "30"; ListResponse <FlatPunch> FPresp = _timeAttendanceService.ChildGetAll <FlatPunch>(FPreq); if (!FPresp.Success) { Common.errorMessage(FPresp); return; } punchesList.Text = ""; FPresp.Items.ForEach(x => { punchesList.Text += x.clockStamp.ToString(_systemService.SessionHelper.GetDateformat() + " HH:mm", CultureInfo.CurrentUICulture) + System.Environment.NewLine; } ); inOutStore.DataSource = Common.XMLDictionaryList(_systemService, "34"); inOutStore.DataBind(); overrideWindow.Show(); break; case "LinkRender": FillTimeApproval(id); TimeApprovalWindow.Show(); break; case "imgHistory": TimeVariationHistoryControl1.Show("41203", id); break; default: break; } } 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"]; 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 Page_Load(object sender, EventArgs e) { if (!X.IsAjaxRequest && !IsPostBack) { SetExtLanguage(); HideShowButtons(); try { AccessControlApplier.ApplyAccessControlOnPage(typeof(MyInfo), BasicInfoTab, null, null, SaveButton); } catch (AccessDeniedException exp) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorAccessDenied, "closeCurrentTab()").Show(); return; } if (string.IsNullOrEmpty(_systemService.SessionHelper.GetCurrentUserId().ToString())) { X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorOperation).Show(); } //RecordRequest r = new RecordRequest(); //r.RecordID = _systemService.SessionHelper.GetCurrentUserId(); //RecordResponse<UserInfo> response = _systemService.ChildGetRecord<UserInfo>(r); //if (!response.Success) //{ // X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", response.ErrorCode) != null ? GetGlobalResourceObject("Errors", response.ErrorCode). ToString() +"<br>"+GetGlobalResourceObject("Errors", "ErrorLogId") + response.LogId : response.Summary, "closeCurrentTab()").Show(); // return; //} CurrentEmployee.Text = _systemService.SessionHelper.GetEmployeeId(); // EditRecordWindow.Loader.Params("employeeId") = CurrentEmployee.Text; RecordRequest req = new RecordRequest(); req.RecordID = CurrentEmployee.Text; RecordResponse <MyInfo> resp = _iselfServiceService.ChildGetRecord <MyInfo>(req); if (!resp.Success) { Common.errorMessage(resp); return; } FillReligionStore(); if (resp.result != null) { if (resp.result.name != null) { resp.result.familyName = resp.result.name.familyName; resp.result.middleName = resp.result.name.middleName; resp.result.firstName = resp.result.name.firstName; resp.result.lastName = resp.result.name.lastName; resp.result.reference = resp.result.name.reference; resp.result.fullName = resp.result.name.fullName; } BasicInfoTab.Reset(); BasicInfoTab.SetValues(resp.result); } this.EditRecordWindow.Title = Resources.Common.EditWindowsTitle; this.EditRecordWindow.Show(); //try //{ // // AccessControlApplier.ApplyAccessControlOnPage(typeof(HireInfo), actualPanel, null, null, saveButton); //} //catch (AccessDeniedException exp) //{ // X.MessageBox.ButtonText.Ok = Resources.Common.Ok; // X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorAccessDenied).Show(); // return; //} ////if (recruitmentInfo.InputType == InputType.Password) ////{ //// recruitmentInfo.Visible = false; //// infoField.Visible = true; ////} } }
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"]; BusinessPartner b = JsonConvert.DeserializeObject <BusinessPartner>(obj); b.recordId = id; // Define the object to add or edit as null // 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; 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(id)) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <BusinessPartner> request = new PostRequest <BusinessPartner>(); request.entity = b; PostResponse <BusinessPartner> r = _administrationService.ChildAddOrUpdate <BusinessPartner>(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 { Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); //Add this record to the store //Display successful notification Store1.Reload(); 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 { PostRequest <BusinessPartner> request = new PostRequest <BusinessPartner>(); request.entity = b; PostResponse <BusinessPartner> r = _administrationService.ChildAddOrUpdate <BusinessPartner>(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); 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(); } } } }