public void DeleteWSRecord(int index) { try { //Step 2 : remove the object from the store WorkSequence s = new WorkSequence(); s.seqNo = index; //s.reference = ""; s.wfId = currentWorkFlowId.Text; PostRequest <WorkSequence> req = new PostRequest <WorkSequence>(); req.entity = s; PostResponse <WorkSequence> r = _companyStructureRepository.ChildDelete <WorkSequence>(req); if (!r.Success) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { //Step 2 : remove the object from the store workSequenceStore.Remove(index); //Step 3 : Showing a notification for the user Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordDeletedSucc }); } } catch (Exception ex) { //In case of error, showing a message box to the user X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorDeletingRecord).Show(); } }
protected void SaveNewWSRecord(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"]; string seqNO = e.ExtraParams["seqNO"]; WorkSequence b = JsonConvert.DeserializeObject <WorkSequence>(obj); b.approverPositionName = approverPosition.SelectedItem.Text; b.branchName = branchId.SelectedItem.Text; b.departmentName = departmentId.SelectedItem.Text; if (string.IsNullOrEmpty(seqNO)) { b.seqNo = null; } else { b.seqNo = Convert.ToInt32(seqNO); } // Define the object to add or edit as null if (string.IsNullOrEmpty(seqNO)) { try { PostRequest <WorkSequence> request = new PostRequest <WorkSequence>(); request.entity = b; request.entity.wfId = currentWorkFlowId.Text; if (string.IsNullOrEmpty(currentSeq.Text)) { request.entity.seqNo = 1; currentSeq.Text = "1"; } else { request.entity.seqNo = Convert.ToInt32(currentSeq.Text) + 1; currentSeq.Text = (Convert.ToInt32(currentSeq.Text) + 1).ToString(); } PostResponse <WorkSequence> r = _companyStructureRepository.ChildAddOrUpdate <WorkSequence>(request); if (!r.Success) { Common.errorMessage(r); return; } FillWorkSequenceStore(currentWorkFlowId.Text); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); this.EditWSWindow.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 <WorkSequence> request = new PostRequest <WorkSequence>(); request.entity = b; request.entity.wfId = currentWorkFlowId.Text; PostResponse <WorkSequence> r = _companyStructureRepository.ChildAddOrUpdate <WorkSequence>(request); if (!r.Success) { Common.errorMessage(r); return; } Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); FillWorkSequenceStore(currentWorkFlowId.Text); this.EditWSWindow.Close(); } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } } }