Esempio n. 1
0
        private void SaveDay(AttendanceScheduleDay day, bool workingDay, List <AttendanceBreak> breaks)
        {
            try
            {
                //getting the id of the record
                PostRequest <AttendanceScheduleDay> modifyHeaderRequest = new PostRequest <AttendanceScheduleDay>();
                modifyHeaderRequest.entity = day;
                if (string.IsNullOrEmpty(modifyHeaderRequest.entity.duration))
                {
                    modifyHeaderRequest.entity.duration = "0";
                }
                PostResponse <AttendanceScheduleDay> r = _branchService.ChildAddOrUpdate <AttendanceScheduleDay>(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;
                    Common.errorMessage(r);
                    return;
                }
                if (workingDay)
                {
                    PostResponse <AttendanceBreak> deleteResponse = _branchService.DeleteDayBreaks(day.scId, day.dow);
                    if (!deleteResponse.Success)//it maybe another check
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, deleteResponse.Summary).Show();
                        return;
                    }
                    try

                    {
                        AddBreaksList(day.scId.ToString(), day.dow, breaks);
                    }
                    catch (Exception ex)
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        Common.errorMessage(r);
                        return;
                    }
                }



                //ModelProxy record = this.scheduleStore.GetById(day.dow);
                //dayBreaksForm.UpdateRecord(record);
                //if (!workingDay)
                //{
                //    record.Set("firstIn", "00:00");
                //    record.Set("lastOut", "00:00");
                //}
                //record.Commit();
            }
            catch (Exception ex)
            {
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
            }
        }
Esempio n. 2
0
        protected void SaveDayBreaks(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 dayJ    = e.ExtraParams["day"];
            string breaksJ = e.ExtraParams["breaks"];

            AttendanceScheduleDay day     = JsonConvert.DeserializeObject <AttendanceScheduleDay>(dayJ);
            bool workingDay               = IsWorkingDay.Text == "True";
            List <AttendanceBreak> breaks = null;

            if (workingDay)
            {
                breaks = JsonConvert.DeserializeObject <List <AttendanceBreak> >(breaksJ);
            }
            else
            {
                day.firstIn = "00:00";
                day.lastOut = "00:00";
            }
            day.scId = Convert.ToInt32(CurrentSchedule.Text);
            if (!string.IsNullOrEmpty(CurrentDow.Text))
            {
                day.dow = Convert.ToInt16(CurrentDow.Text);
            }

            // Define the object to add or edit as null

            if (isBatch.Text == "1")
            {
                for (short i = 1; i <= 7; i++)
                {
                    day.dow = i;
                    SaveDay(day, workingDay, breaks);
                }
                ReloadDays();
            }
            else
            {
                SaveDay(day, workingDay, breaks);
                ReloadDays();
            }
            Notification.Show(new NotificationConfig
            {
                Title = Resources.Common.Notification,
                Icon  = Icon.Information,
                Html  = Resources.Common.RecordUpdatedSucc
            });

            this.EditDayBreaks.Close();
        }
Esempio n. 3
0
        protected void SaveDayBreaks(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 dayJ    = e.ExtraParams["day"];
            string breaksJ = e.ExtraParams["breaks"];

            AttendanceScheduleDay day     = JsonConvert.DeserializeObject <AttendanceScheduleDay>(dayJ);
            bool workingDay               = IsWorkingDay.Text == "True";
            List <AttendanceBreak> breaks = null;

            if (workingDay)
            {
                breaks = JsonConvert.DeserializeObject <List <AttendanceBreak> >(breaksJ);
            }
            else
            {
                day.firstIn = "00:00";
                day.lastOut = "00:00";
            }
            day.scId = Convert.ToInt32(e.ExtraParams["scId"]);
            day.dow  = Convert.ToInt16(CurrentDow.Text);

            // Define the object to add or edit as null



            try
            {
                //getting the id of the record
                PostRequest <AttendanceScheduleDay> modifyHeaderRequest = new PostRequest <AttendanceScheduleDay>();
                modifyHeaderRequest.entity = day;
                PostResponse <AttendanceScheduleDay> r = _branchService.ChildAddOrUpdate <AttendanceScheduleDay>(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, r.Summary).Show();
                    return;
                }
                if (workingDay)
                {
                    PostResponse <AttendanceBreak> deleteResponse = _branchService.DeleteDayBreaks(day.scId, day.dow);
                    if (!deleteResponse.Success)//it maybe another check
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, deleteResponse.Summary).Show();
                        return;
                    }
                    try

                    {
                        AddBreaksList(day.scId.ToString(), day.dow, breaks);
                    }
                    catch (Exception ex)
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, r.Summary).Show();
                        return;
                    }
                }



                ModelProxy record = this.scheduleStore.GetById(day.dow);
                dayBreaksForm.UpdateRecord(record);
                if (!workingDay)
                {
                    record.Set("firstIn", "00:00");
                    record.Set("lastOut", "00:00");
                }
                record.Commit();
                Notification.Show(new NotificationConfig
                {
                    Title = Resources.Common.Notification,
                    Icon  = Icon.Information,
                    Html  = Resources.Common.RecordUpdatedSucc
                });
                this.EditDayBreaks.Close();
            }
            catch (Exception ex)
            {
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
            }
        }