Пример #1
0
        public void DeleteSocialRecord(string ssId, string seqNo)
        {
            try
            {
                //Step 1 Code to delete the object from the database
                SocialSecurityScheduleSetup s = new SocialSecurityScheduleSetup();
                s.ssId  = Convert.ToInt32(ssId);
                s.seqNo = Convert.ToInt32(seqNo);


                //s.intName = "";

                PostRequest <SocialSecurityScheduleSetup> req = new PostRequest <SocialSecurityScheduleSetup>();
                req.entity = s;
                PostResponse <SocialSecurityScheduleSetup> r = _PayrollService.ChildDelete <SocialSecurityScheduleSetup>(req);
                if (!r.Success)
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    Common.errorMessage(r);
                    return;
                }
                else
                {
                    //Step 2 :  remove the object from the store
                    socialSetupStore.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 saveSocialButton(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"];
            SocialSecurityScheduleSetup b = JsonConvert.DeserializeObject <SocialSecurityScheduleSetup>(obj);

            string id = e.ExtraParams["id"];

            // Define the object to add or edit as null

            if (string.IsNullOrEmpty(id))
            {
                try
                {
                    SocailSecurityseqId.Text = Convert.ToString(Convert.ToInt32(SocailSecurityseqId.Text) + 1);
                    //New Mode
                    //Step 1 : Fill The object and insert in the store
                    PostRequest <SocialSecurityScheduleSetup> request = new PostRequest <SocialSecurityScheduleSetup>();

                    request.entity       = b;
                    request.entity.ssId  = Convert.ToInt32(SocailSecurityrecordId.Text);
                    request.entity.seqNo = Convert.ToInt32(SocailSecurityseqId.Text);


                    PostResponse <SocialSecurityScheduleSetup> r = _PayrollService.ChildAddOrUpdate <SocialSecurityScheduleSetup>(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
                    {
                        //Add this record to the store

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

                        this.EditSocialSecuritySetupWindow.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 <SocialSecurityScheduleSetup> request = new PostRequest <SocialSecurityScheduleSetup>();
                    request.entity       = b;
                    request.entity.ssId  = b.ssId;
                    request.entity.seqNo = b.seqNo;
                    PostResponse <SocialSecurityScheduleSetup> r = _PayrollService.ChildAddOrUpdate <SocialSecurityScheduleSetup>(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
                    {
                        socialSetupStore.Reload();
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordUpdatedSucc
                        });
                        this.EditSocialSecuritySetupWindow.Close();
                    }
                }
                catch (Exception ex)
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
                }
            }
        }