Beispiel #1
0
        public void DeleteEH(string dayID, string employeeId)
        {
            try
            {
                //Step 1 Code to delete the object from the database
                EmployeeCal n = new EmployeeCal();
                n.dayId      = dayID;
                n.employeeId = Convert.ToInt32(employeeId);



                PostRequest <EmployeeCal> req = new PostRequest <EmployeeCal>();
                req.entity = n;
                PostResponse <EmployeeCal> res = _employeeService.ChildDelete <EmployeeCal>(req);
                if (!res.Success)
                {
                    //Show an error saving...
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, res.Summary).Show();
                    return;
                }
                else
                {
                    //Step 2 :  remove the object from the store

                    employeeCalenderyStore.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();
            }
        }
Beispiel #2
0
        protected void SaveEH(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"];
            EmployeeCal b   = JsonConvert.DeserializeObject <EmployeeCal>(obj);

            b.dayId = b.dayIdDt.ToString("yyyyMMdd");
            //b.employeeId = Convert.ToInt32(Request.QueryString["employeeId"]);
            b.caName = e.ExtraParams["caName"];
            b.scName = e.ExtraParams["scName"];


            if (ADDNewRecord.Text.Equals("1"))
            {
                try
                {
                    //New Mode
                    //Step 1 : Fill The object and insert in the store
                    PostRequest <EmployeeCal> request = new PostRequest <EmployeeCal>();

                    request.entity = b;
                    PostResponse <EmployeeCal> r = _employeeService.ChildAddOrUpdate <EmployeeCal>(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.employeeCalenderyStore.Reload();

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

                        this.EditEHwindow.Close();

                        /*  RowSelectionModel sm = this.employeeCalenderGrid.GetSelectionModel() as RowSelectionModel;
                         * sm.DeselectAll();
                         * sm.Select(b.recordId.ToString());
                         * EHCount.Text = (Convert.ToInt32(EHCount.Text) + 1).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 <EmployeeCal> request = new PostRequest <EmployeeCal>();
                    request.entity = b;
                    PostResponse <EmployeeCal> r = _employeeService.ChildAddOrUpdate <EmployeeCal>(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
                    {
                        this.employeeCalenderyStore.Reload();
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordUpdatedSucc
                        });

                        this.EditEHwindow.Close();
                    }
                }


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