Exemple #1
0
        protected void addED(object sender, DirectEventArgs e)
        {
            PayCode obj = new PayCode();

            obj.name    = paycodeRef.Text;
            obj.payCode = paycodeRef.Text;

            PostRequest <PayCode> req = new PostRequest <PayCode>();

            req.entity = obj;
            PostResponse <PayCode> response = _PayrollService.ChildAddOrUpdate <PayCode>(req);

            if (response.Success)
            {
                Store2.Reload();
                paycodeRef.Select(paycodeRef.Text);
                paycodeRef.SetValue(paycodeRef.Text);
            }
            else
            {
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                Common.errorMessage(response);
                return;
            }
        }
Exemple #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"];
            TimeCode b   = JsonConvert.DeserializeObject <TimeCode>(obj);

            //if (!string.IsNullOrEmpty(timeCodeCombo.Value.ToString()))
            //    b.timeCode = Convert.ToInt16(timeCodeCombo.Value.ToString());

            // Define the object to add or edit as null
            try
            {
                //New Mode
                //Step 1 : Fill The object and insert in the store
                PostRequest <TimeCode> request = new PostRequest <TimeCode>();

                request.entity = b;
                PostResponse <TimeCode> r = _payrollService.ChildAddOrUpdate <TimeCode>(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
                    Store1.Reload();

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

                    this.EditRecordWindow.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();
            }
        }
Exemple #3
0
        protected override void ProcessElement(PayCode item)
        {
            PostRequest <PayCode> req = new PostRequest <PayCode>();

            req.entity = item;

            PostResponse <PayCode> resp = _payrollService.ChildAddOrUpdate <PayCode>(req);

            if (!resp.Success)
            {
                errors.Add(item);
                errorMessages.Add(resp.Summary);
                return;
            }
        }
Exemple #4
0
        protected void SyncLoanDeductions(object sender, DirectEventArgs e)
        {
            PostRequest <SyncED>  req  = new PostRequest <SyncED>();
            PostResponse <SyncED> resp = _payrollService.ChildAddOrUpdate <SyncED>(req);

            if (!resp.Success)
            { //Show an error saving...
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                Common.errorMessage(resp);
                return;
            }
            else
            {
                X.Msg.Alert("", GetGlobalResourceObject("Common", "LoanSyncSucc").ToString()).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["schedule"];
            PayrollIndemnity b           = JsonConvert.DeserializeObject <PayrollIndemnity>(obj);
            string           pers        = e.ExtraParams["periods"];
            string           indemnities = e.ExtraParams["indemnities"];

            b.recordId = id;
            // Define the object to add or edit as null
            List <PayrollIndemnityDetails>     periods         = JsonConvert.DeserializeObject <List <PayrollIndemnityDetails> >(pers);
            List <PayrollIndemnityRecognition> indemnitiesList = JsonConvert.DeserializeObject <List <PayrollIndemnityRecognition> >(indemnities);

            if (periods == null || periods.Count == 0 || indemnitiesList == null || indemnitiesList.Count == 0)
            {
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", "Error_Empty_IndemnityDetails_IndemnityResignation")).Show();
                return;
            }
            if (string.IsNullOrEmpty(id))
            {
                try
                {
                    //New Mode
                    //Step 1 : Fill The object and insert in the store
                    PostRequest <PayrollIndemnity> request = new PostRequest <PayrollIndemnity>();
                    request.entity = b;
                    PostResponse <PayrollIndemnity> r = _payrollService.ChildAddOrUpdate <PayrollIndemnity>(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;
                    }

                    PostResponse <PayrollIndemnityDetails[]> result = AddPeriodsList(b.recordId, periods);
                    //  AddPeriodsList1(b.recordId, periods);


                    if (!result.Success)
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", result.ErrorCode) != null ? GetGlobalResourceObject("Errors", result.ErrorCode).ToString() : GetGlobalResourceObject("Errors", result.ErrorCode) != null ? GetGlobalResourceObject("Errors", result.ErrorCode).ToString() : result.Summary).Show();
                        return;
                    }


                    PostResponse <PayrollIndemnityRecognition[]> result1 = AddindemnitiesList(b.recordId, indemnitiesList);
                    //  AddPeriodsList1(b.recordId, periods);

                    if (!result1.Success)
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", result.ErrorCode) != null ? GetGlobalResourceObject("Errors", result.ErrorCode).ToString() : GetGlobalResourceObject("Errors", result.ErrorCode) != null ? GetGlobalResourceObject("Errors", result.ErrorCode).ToString() : result.Summary).Show();
                        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());
                    }
                }
                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 <PayrollIndemnity> modifyHeaderRequest = new PostRequest <PayrollIndemnity>();
                    modifyHeaderRequest.entity = b;

                    PostResponse <PayrollIndemnity> r = _payrollService.ChildAddOrUpdate <PayrollIndemnity>(modifyHeaderRequest);

                    //Step 1 Selecting the object or building up the object for update purpose
                    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;
                    }
                    //List<PayrollIndemnityDetails> periods = JsonConvert.DeserializeObject<List<PayrollIndemnityDetails>>(pers);
                    //List<PayrollIndemnityRecognition> indemnitiesList = JsonConvert.DeserializeObject<List<PayrollIndemnityRecognition>>(indemnities);
                    //if (periods == null || periods.Count == 0 || indemnitiesList == null || indemnitiesList.Count == 0)
                    //{
                    //    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    //    X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", "Error_Empty_IndemnityDetails_IndemnityResignation")).Show();
                    //    return;

                    //}

                    //_payrollService.DeleteVacationSchedulePeriods(Convert.ToInt32(b.recordId));
                    DeleteVacationSchedulePeriods(Convert.ToInt32(b.recordId));
                    //if (!deleteDesponse.Success)//it maybe another check
                    // {
                    //     X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    //      X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", deleteDesponse.ErrorCode) != null ? GetGlobalResourceObject("Errors", deleteDesponse.ErrorCode).ToString() : deleteDesponse.Summary).Show();
                    //     return;
                    // }

                    PostResponse <PayrollIndemnityDetails[]> result = AddPeriodsList(b.recordId, periods);

                    //Step 2 : saving to store

                    //Step 3 :  Check if request fails
                    if (!result.Success)//it maybe another check
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", result.ErrorCode) != null ? GetGlobalResourceObject("Errors", result.ErrorCode).ToString() : result.Summary).Show();
                        return;
                    }


                    PostResponse <PayrollIndemnityRecognition[]> result1 = AddindemnitiesList(b.recordId, indemnitiesList);
                    //  AddPeriodsList1(b.recordId, periods);

                    if (!result1.Success)
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", result.ErrorCode) != null ? GetGlobalResourceObject("Errors", result.ErrorCode).ToString() : GetGlobalResourceObject("Errors", result.ErrorCode) != null ? GetGlobalResourceObject("Errors", result.ErrorCode).ToString() : result.Summary).Show();
                        return;
                    }
                    else
                    {
                        ModelProxy record = this.Store1.GetById(index);
                        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();
                }
            }
            Store1.Reload();
        }
Exemple #6
0
        protected void SaveNewRecord(object sender, DirectEventArgs e)
        {
            socialSetupStore.Reload();


            //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"];
            SocialSecuritySchedule b = JsonConvert.DeserializeObject <SocialSecuritySchedule>(obj);

            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 <SocialSecuritySchedule> request = new PostRequest <SocialSecuritySchedule>();

                    request.entity          = b;
                    request.entity.recordId = SocailSecurityrecordId.Text;


                    PostResponse <SocialSecuritySchedule> r = _PayrollService.ChildAddOrUpdate <SocialSecuritySchedule>(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
                    {
                        if (!string.IsNullOrEmpty(SocailSecurityrecordId.Text))
                        {
                            b.recordId = r.recordId;
                            //Add this record to the store
                            this.Store1.Insert(0, b);

                            this.EditRecordWindow.Close();
                            RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel;
                            sm.DeselectAll();
                            sm.Select(b.recordId.ToString());

                            socialSetupStore.Reload();
                        }

                        Store1.Reload();
                        SocailSecurityrecordId.Text = r.recordId;

                        socialSetupGrid.Disabled = false;



                        //Display successful notification
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordSavingSucc
                        });
                    }
                }
                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 <SocialSecuritySchedule> request = new PostRequest <SocialSecuritySchedule>();
                    request.entity = b;
                    PostResponse <SocialSecuritySchedule> r = _PayrollService.ChildAddOrUpdate <SocialSecuritySchedule>(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
                        });
                        Store1.Reload();
                        this.EditRecordWindow.Close();
                    }
                }
                catch (Exception ex)
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
                }
            }
        }
Exemple #7
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"];
            PayrollBenefitSchedule b = JsonConvert.DeserializeObject <PayrollBenefitSchedule>(obj);

            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 <PayrollBenefitSchedule> request = new PostRequest <PayrollBenefitSchedule>();

                    request.entity = b;
                    PostResponse <PayrollBenefitSchedule> r = _payrollService.ChildAddOrUpdate <PayrollBenefitSchedule>(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
                        Store1.Reload();

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

                        this.EditRecordWindow.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 <PayrollBenefitSchedule> request = new PostRequest <PayrollBenefitSchedule>();
                    request.entity = b;
                    PostResponse <PayrollBenefitSchedule> r = _payrollService.ChildAddOrUpdate <PayrollBenefitSchedule>(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
                    {
                        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();
                }
            }
        }
Exemple #8
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"];
            PenaltyType          b   = JsonConvert.DeserializeObject <PenaltyType>(obj);
            List <PenaltyDetail> PD  = JsonConvert.DeserializeObject <List <PenaltyDetail> >(e.ExtraParams["codes"]);


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

            // Define the object to add or edit as null
            if (!string.IsNullOrEmpty(currentPenaltyType.Text))
            {
                id         = currentPenaltyType.Text;
                b.recordId = currentPenaltyType.Text;
            }
            if (string.IsNullOrEmpty(id))
            {
                try
                {
                    //New Mode
                    //Step 1 : Fill The object and insert in the store
                    PostRequest <PenaltyType> request = new PostRequest <PenaltyType>();

                    request.entity = b;
                    PostResponse <PenaltyType> r = _PayrollService.ChildAddOrUpdate <PenaltyType>(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
                    {
                        currentPenaltyType.Text = r.recordId;



                        //PostRequest<PenaltyDetail> codesReq = new PostRequest<PenaltyDetail>();

                        //PD.ForEach(x =>

                        //{
                        //    DeletePenaltyDetailsRecord(x);
                        //    codesReq.entity = x;
                        //    codesReq.entity.recordId = null;
                        //    PostResponse<PenaltyDetail> codesResp = _PayrollService.ChildAddOrUpdate<PenaltyDetail>(codesReq);
                        //    if (!codesResp.Success)//it maybe be another condition
                        //{
                        //    //Show an error saving...
                        //    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        //        X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", codesResp.ErrorCode) != null ? GetGlobalResourceObject("Errors", codesResp.ErrorCode).ToString() : codesResp.Summary).Show();
                        //        throw new Exception();
                        //    }
                        //});


                        Store1.Reload();
                        penaltyDetailGrid.Disabled = false;

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


                        //RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel;
                        //sm.DeselectAll();
                        //sm.Select(b.recordId.ToString());
                    }
                }
                catch (Exception ex)
                {
                    if (ex.Message != null)
                    {
                        //Error exception displaying a messsage box
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, ex.Message).Show();
                    }
                }
            }
            else
            {
                penaltyDetailGrid.Disabled = false;
                //Update Mode

                try
                {
                    //getting the id of the record
                    PostRequest <PenaltyType> request = new PostRequest <PenaltyType>();
                    request.entity = b;
                    PostResponse <PenaltyType> r = _PayrollService.ChildAddOrUpdate <PenaltyType>(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
                    {
                        DeleteAllPenaltyDetailsRecords(damage.Value.ToString());
                        PostRequest <PenaltyDetail> codesReq = new PostRequest <PenaltyDetail>();
                        PD.ForEach(x =>
                        {
                            codesReq.entity          = x;
                            codesReq.entity.recordId = null;

                            PostResponse <PenaltyDetail> codesResp = _PayrollService.ChildAddOrUpdate <PenaltyDetail>(codesReq);

                            if (!codesResp.Success)//it maybe be another condition
                            {
                                //Show an error saving...
                                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                                X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", codesResp.ErrorCode) != null ? GetGlobalResourceObject("Errors", codesResp.ErrorCode).ToString() : codesResp.Summary).Show();
                                throw new Exception();
                            }
                        });

                        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();
                }
            }
        }
Exemple #9
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"];
            LeavePayment b   = JsonConvert.DeserializeObject <LeavePayment>(obj);

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

            // Define the object to add or edit as null

            //  b.employeeName = new EmployeeName();
            //if (ldMethodCom.SelectedItem != null)
            //    b.ldMethod = ldMethodCom.SelectedItem.Value;
            if (employeeId.SelectedItem != null)
            {
                b.employeeName = employeeId.SelectedItem.Text;
            }

            if (date.ReadOnly)
            {
                b.date = DateTime.Now;
            }
            //b.effectiveDate = new DateTime(b.effectiveDate.Year, b.effectiveDate.Month, b.effectiveDate.Day, 14, 0, 0);


            if (string.IsNullOrEmpty(id))
            {
                try
                {
                    //New Mode
                    //Step 1 : Fill The object and insert in the store
                    PostRequest <LeavePayment> request = new PostRequest <LeavePayment>();
                    request.entity = b;
                    PostResponse <LeavePayment> r = _payrollService.ChildAddOrUpdate <LeavePayment>(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
                        });
                        recordId.Text = b.recordId;

                        currentCase.Text = b.recordId;

                        //RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel;
                        //sm.DeselectAll();
                        //sm.Select(b.recordId.ToString());
                        Store1.Reload();
                        this.EditRecordWindow.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 <LeavePayment> request = new PostRequest <LeavePayment>();
                    request.entity = b;
                    PostResponse <LeavePayment> r = _payrollService.ChildAddOrUpdate <LeavePayment>(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);

                        if (date.ReadOnly)
                        {
                            record.Set("date", null);
                        }

                        record.Set("employeeName", b.employeeName);



                        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();
                }
            }
        }
Exemple #10
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 id = e.ExtraParams["id"];

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


            // Define the object to add or edit as null


            try
            {
                //New Mode
                //Step 1 : Fill The object and insert in the store
                PostRequest <FiscalYear> request = new PostRequest <FiscalYear>();
                request.entity = b;
                if (b.startDate > b.endDate)
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, GetLocalResourceObject("ErrorStartEnd").ToString()).Show();
                    return;
                }
                PostResponse <FiscalYear> r = _payrollService.ChildAddOrUpdate <FiscalYear>(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
                    Store1.Reload();

                    //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.fiscalYear.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();
            }
        }