protected void fillBodyText(object sender, DirectEventArgs e) { ApplyLetterRecordRequest req = new ApplyLetterRecordRequest(); req.ltId = Convert.ToInt32(ltId.SelectedItem.Value); req.employeeId = Convert.ToInt32(employeeId.SelectedItem.Value); RecordResponse <ApplyLetter> res = _systemService.ChildGetRecord <ApplyLetter>(req); if (!res.Success)//it maybe another check { return; } else { bodyTextTF.Text = res.result.bodyText; } }
protected void fillBodyText(object sender, DirectEventArgs e) { try { ApplyLetterRecordRequest req = new ApplyLetterRecordRequest(); req.ltId = Convert.ToInt32(ltId.SelectedItem.Value); req.employeeId = Convert.ToInt32(employeeId.SelectedItem.Value); RecordResponse <ApplyLetter> res = _systemService.ChildGetRecord <ApplyLetter>(req); if (!res.Success)//it maybe another check { return; } else { bodyTextTF.Text = res.result.bodyText; } } 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 id = e.ExtraParams["id"]; string obj = e.ExtraParams["values"]; LetterSelfservice b = JsonConvert.DeserializeObject <LetterSelfservice>(obj); b.employeeId = Convert.ToInt32(_systemService.SessionHelper.GetEmployeeId()); b.recordId = id; // Define the object to add or edit as null ApplyLetterRecordRequest req = new ApplyLetterRecordRequest(); req.ltId = Convert.ToInt32(ltId.SelectedItem.Value.ToString()); req.employeeId = b.employeeId; RecordResponse <ApplyLetter> res = _systemService.ChildGetRecord <ApplyLetter>(req); b.bodyText = res.result.bodyText; if (string.IsNullOrEmpty(id)) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <LetterSelfservice> request = new PostRequest <LetterSelfservice>(); request.entity = b; PostResponse <LetterSelfservice> r = _selfServiceService.ChildAddOrUpdate <LetterSelfservice>(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()); 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(id);//getting the id of the record PostRequest <LetterSelfservice> request = new PostRequest <LetterSelfservice>(); request.entity = b; PostResponse <LetterSelfservice> r = _selfServiceService.ChildAddOrUpdate <LetterSelfservice>(request); //Step 1 Selecting the object or building up the object for update purpose //Step 2 : saving to store //Step 3 : Check if request fails if (!r.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); return; } else { //ModelProxy record = this.Store1.GetById(index); //BasicInfoTab.UpdateRecord(record); //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(); } } }