Ejemplo n.º 1
0
        public object ValidateSave(bool isPhantom, string obj, JsonObject values)
        {
            if (!values.ContainsKey("comment"))
            {
                return(new { valid = false, msg = "Error in call" });
            }

            PostRequest <LoanComment> req = new PostRequest <LoanComment>();
            LoanComment note = JsonConvert.DeserializeObject <List <LoanComment> >(obj)[0];

            //note.recordId = id;
            note.loanId  = Convert.ToInt32(currentCase.Text);
            note.comment = values["comment"].ToString();
            int bulk;

            req.entity = note;

            PostResponse <LoanComment> resp = _loanService.ChildAddOrUpdate <LoanComment>(req);

            if (!resp.Success)
            {
                Common.errorMessage(resp);
                return(new { valid = false });
            }
            //loanComments_RefreshData(note.loanId);
            return(new { valid = true });
        }
Ejemplo n.º 2
0
        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"];
            LoanType b   = JsonConvert.DeserializeObject <LoanType>(obj);

            if (b.ldValue == null)
            {
                b.ldValue = 0;
            }
            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 <LoanType> request = new PostRequest <LoanType>();

                    request.entity = b;
                    PostResponse <LoanType> r = _loanService.ChildAddOrUpdate <LoanType>(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 <LoanType> request = new PostRequest <LoanType>();
                    request.entity = b;
                    PostResponse <LoanType> r = _loanService.ChildAddOrUpdate <LoanType>(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();
                }
            }
        }