示例#1
0
        public void DeleteFUNConstRecord(int fnId)
        {
            try
            {
                //Step 1 Code to delete the object from the database
                PayrollFunConst n = new PayrollFunConst();
                n.constant   = CurrentDelFuncID.Text;//exId.ToString();
                n.functionId = fnId.ToString();

                PostRequest <PayrollFunConst> req = new PostRequest <PayrollFunConst>();
                req.entity = n;
                PostResponse <PayrollFunConst> res = _payrollService.ChildDelete <PayrollFunConst>(req);
                if (!res.Success)
                {
                    //Show an error saving...
                    Common.errorMessage(res);
                    return;
                }
                else
                {
                    //Step 2 :  remove the object from the store
                    FunctionConstStore.Remove(CurrentDelFuncID.Text);

                    FunctionConstStore.Reload();
                    //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();
            }
        }
示例#2
0
        protected void SaveNewFUNConstRecord(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         = CurrentFunctionId.Text; //e.ExtraParams["expressionId"];
            string functionId = e.ExtraParams["functionId"];
            string constant   = e.ExtraParams["constant"];

            string          obj = e.ExtraParams["values"];
            PayrollFunConst b   = JsonConvert.DeserializeObject <PayrollFunConst>(obj);

            b.functionId = 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 <PayrollFunConst> request = new PostRequest <PayrollFunConst>();
                request.entity            = new PayrollFunConst();
                request.entity.functionId = id;
                request.entity.constant   = constant;
                PostResponse <PayrollFunConst> r = _payrollService.ChildAddOrUpdate <PayrollFunConst>(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
                    //this.ClientAddressStore.Insert(0, b);

                    //Display successful notification
                    Notification.Show(new NotificationConfig
                    {
                        Title = Resources.Common.Notification,
                        Icon  = Icon.Information,
                        Html  = Resources.Common.RecordSavingSucc
                    });
                    FunctionConstStore.Reload();


                    this.EditFUNConstWindow.Close();
                    //RowSelectionModel sm = this.ClientGridPanel.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
            //    {
            //        PostRequest<ClientAddress> request = new PostRequest<ClientAddress>();
            //        request.entity = new ClientAddress();
            //        request.entity.address = b;
            //        request.entity.clientId = CurrentClientId.Text;
            //        request.entity.addressId = id;
            //        PostResponse<ClientAddress> r = _saleService.ChildAddOrUpdate<ClientAddress>(request);
            //        b.recordId = r.recordId;

            //        //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.ClientStore.GetById(index);
            //            //BasicInfoTab.UpdateRecord(record);
            //            //record.Commit();

            //            ClientAddressStore.Reload();


            //            Notification.Show(new NotificationConfig
            //            {
            //                Title = Resources.Common.Notification,
            //                Icon = Icon.Information,
            //                Html = Resources.Common.RecordUpdatedSucc
            //            });
            //            this.EditAddressWindow.Close();


            //        }

            //    }
            //    catch (Exception ex)
            //    {
            //        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
            //        X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
            //    }
            //}
        }