Beispiel #1
0
        private TimeVariationListRequest GetAbsentRequest()
        {
            TimeVariationListRequest reqTV = new TimeVariationListRequest();

            reqTV.BranchId     = "0";
            reqTV.DepartmentId = "0";
            reqTV.DivisionId   = "0";
            reqTV.PositionId   = "0";
            reqTV.EsId         = "0";
            reqTV.fromDayId    = dateRange1.GetRange().DateFrom;
            reqTV.toDayId      = dateRange1.GetRange().DateTo;
            reqTV.employeeId   = _systemService.SessionHelper.GetEmployeeId();

            if (string.IsNullOrEmpty(apStatus.Value.ToString()))
            {
                reqTV.apStatus = "0";
            }
            else
            {
                reqTV.apStatus = apStatus.Value.ToString();
            }
            if (!string.IsNullOrEmpty(Request.QueryString["_employeeId"]) && !string.IsNullOrEmpty(Request.QueryString["_fromDayId"]) && !string.IsNullOrEmpty(Request.QueryString["_toDayId"]))
            {
                reqTV.fromDayId  = DateTime.ParseExact(Request.QueryString["_fromDayId"], "yyyyMMdd", new CultureInfo("en"));
                reqTV.toDayId    = DateTime.ParseExact(Request.QueryString["_toDayId"], "yyyyMMdd", new CultureInfo("en"));
                reqTV.employeeId = Request.QueryString["_employeeId"];
            }
            if (string.IsNullOrEmpty(fromDuration.Text))
            {
                reqTV.fromDuration = "0";
            }
            else
            {
                reqTV.fromDuration = fromDuration.Text;
            }
            if (string.IsNullOrEmpty(toDuration.Text))
            {
                reqTV.toDuration = "0";
            }
            else
            {
                reqTV.toDuration = toDuration.Text;
            }

            if (string.IsNullOrEmpty(timeVariationType.Value.ToString()))
            {
                reqTV.timeCode = "0";
            }
            else
            {
                reqTV.timeCode = timeVariationType.Value.ToString();
            }



            return(reqTV);
        }
        private TimeVariationListRequest GetAbsentRequest(DateTime day, int employeeId)
        {
            TimeVariationListRequest reqTV = new TimeVariationListRequest();

            reqTV.BranchId     = "0";
            reqTV.DepartmentId = "0";
            reqTV.DivisionId   = "0";
            reqTV.PositionId   = "0";
            reqTV.EsId         = "0";
            reqTV.fromDayId    = day;
            reqTV.toDayId      = day;
            reqTV.employeeId   = employeeId.ToString();
            reqTV.apStatus     = "0";
            reqTV.fromDuration = "0";
            reqTV.toDuration   = "0";
            reqTV.timeCode     = "0";


            return(reqTV);
        }
Beispiel #3
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"];
            DashBoardTimeVariation b = JsonConvert.DeserializeObject <DashBoardTimeVariation>(obj);



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

            // Define the object to add or edit as null



            try
            {
                //getting the id of the record
                TimeVariationListRequest req = new TimeVariationListRequest();

                ListResponse <DashBoardTimeVariation> r = _timeAttendanceService.ChildGetAll <DashBoardTimeVariation>(req);                    //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
                {
                    if (r.Items.Where(x => x.primaryKey == id).Count() == 0)
                    {
                        return;
                    }
                    else
                    {
                        PostRequest <DashBoardTimeVariation> request = new PostRequest <DashBoardTimeVariation>();
                        request.entity             = r.Items.Where(x => x.primaryKey == id).First();
                        request.entity.damageLevel = Convert.ToInt16(damage.Value);
                        request.entity.duration    = Convert.ToInt16(duration.Text);
                        PostResponse <DashBoardTimeVariation> response = _timeAttendanceService.ChildAddOrUpdate <DashBoardTimeVariation>(request);
                        if (!response.Success)//it maybe another check
                        {
                            X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                            Common.errorMessage(response);
                            return;
                        }
                    }
                }


                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();
            }
        }
Beispiel #4
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"];
            DashBoardTimeVariation b = JsonConvert.DeserializeObject <DashBoardTimeVariation>(obj);



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

            // Define the object to add or edit as null



            try
            {
                //getting the id of the record
                TimeVariationListRequest req1 = GetAbsentRequest();

                string rep_params = "";
                Dictionary <string, string> parameters = new Dictionary <string, string>();
                parameters.Add("1", req1.employeeId);
                parameters.Add("2", req1.fromDayId.ToString("yyyyMMdd"));
                parameters.Add("3", req1.toDayId.ToString("yyyyMMdd"));
                parameters.Add("4", "0");
                parameters.Add("5", req1.timeCode);
                parameters.Add("6", req1.apStatus);
                parameters.Add("7", req1.BranchId);
                parameters.Add("8", req1.DepartmentId);
                parameters.Add("9", req1.EsId);
                foreach (KeyValuePair <string, string> entry in parameters)
                {
                    rep_params += entry.Key.ToString() + "|" + entry.Value + "^";
                }
                if (rep_params.Length > 0)
                {
                    if (rep_params[rep_params.Length - 1] == '^')
                    {
                        rep_params = rep_params.Remove(rep_params.Length - 1);
                    }
                }



                ReportGenericRequest req = new ReportGenericRequest();
                req.paramString = rep_params;



                ListResponse <DashBoardTimeVariation> r = _selfServiceService.ChildGetAll <DashBoardTimeVariation>(req);                   //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
                {
                    if (r.Items.Where(x => x.recordId == id).Count() == 0)
                    {
                        return;
                    }
                    else
                    {
                        PostRequest <DashBoardTimeVariation> request = new PostRequest <DashBoardTimeVariation>();
                        request.entity               = r.Items.Where(x => x.recordId == id).First();
                        request.entity.damageLevel   = Convert.ToInt16(damage.Value);
                        request.entity.duration      = Convert.ToInt16(duration.Text);
                        request.entity.justification = b.justification;
                        // request.entity.recordId = null;
                        PostResponse <DashBoardTimeVariation> response = _selfServiceService.ChildAddOrUpdate <DashBoardTimeVariation>(request);
                        if (!response.Success)//it maybe another check
                        {
                            X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                            Common.errorMessage(response);
                            return;
                        }
                    }
                }


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