Example #1
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

                RecordRequest req = new RecordRequest();
                req.RecordID = id;


                RecordResponse <DashBoardTimeVariation> r = _timeAttendanceService.ChildGetRecord <DashBoardTimeVariation>(req);                    //Step 1 Selecting the object or building up the object for update purpose

                if (!r.Success)
                {
                    Common.errorMessage(r);
                    return;
                }
                if (r.result != null)
                {
                    PostRequest <DashBoardTimeVariation> request = new PostRequest <DashBoardTimeVariation>();
                    request.entity               = r.result;
                    request.entity.damageLevel   = Convert.ToInt16(damage.Value);
                    request.entity.duration      = Convert.ToInt16(duration.Text);
                    request.entity.justification = b.justification;
                    request.entity.arId          = TimeApprovalReasonControl.getApprovalReason() == "0"?null: TimeApprovalReasonControl.getApprovalReason();


                    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();
            }
        }
Example #2
0
        protected void PoPuP(object sender, DirectEventArgs e)
        {
            try {
                BasicInfoTab.Reset();
                FillDamageStore();
                string id                 = e.ExtraParams["id"];
                int    dayId              = Convert.ToInt32(e.ExtraParams["dayId"]);
                int    employeeId         = Convert.ToInt32(e.ExtraParams["employeeId"]);
                string damageLavel        = e.ExtraParams["damage"];
                string durationValue      = e.ExtraParams["duration"];
                string timeCodeParameter  = e.ExtraParams["timeCode"];
                string shiftId            = e.ExtraParams["shiftId"];
                string apStatus           = e.ExtraParams["apStatus"];
                string type               = e.ExtraParams["type"];
                string justificationParam = e.ExtraParams["justification"];
                string clockDuration      = e.ExtraParams["clockDuration"];
                string arId               = e.ExtraParams["arId"];


                switch (type)
                {
                case "imgEdit":
                    //Step 1 : get the object from the Web Service

                    //Step 2 : call setvalues with the retrieved object

                    damage.Select(damageLavel);
                    duration.Text = durationValue;
                    clock.Text    = clockDuration;
                    // recordId.Text = id;
                    justification.Text = justificationParam;
                    TimeApprovalReasonControl.setApprovalReason(arId);
                    if (apStatus == "2" || apStatus == "-1")
                    {
                        disableEditing(false);
                    }
                    else
                    {
                        disableEditing(true);
                    }

                    recordId.Text = id;
                    this.EditRecordWindow.Title = Resources.Common.EditWindowsTitle;
                    this.EditRecordWindow.Show();
                    break;

                case "imgDelete":
                    X.Msg.Confirm(Resources.Common.Confirmation, Resources.Common.DeleteOneRecord, new MessageBoxButtonsConfig
                    {
                        Yes = new MessageBoxButtonConfig
                        {
                            //We are call a direct request metho for deleting a record
                            Handler = String.Format("App.direct.DeleteRecord({0})", id),
                            Text    = Resources.Common.Yes
                        },
                        No = new MessageBoxButtonConfig
                        {
                            Text = Resources.Common.No
                        }
                    }).Show();
                    break;



                case "imgReject":
                    X.Msg.Confirm(Resources.Common.Confirmation, GetLocalResourceObject("RejectRecord").ToString(), new MessageBoxButtonsConfig
                    {
                        Yes = new MessageBoxButtonConfig
                        {
                            //We are call a direct request metho for deleting a record
                            Handler = String.Format("App.direct.RejectRecord({0})", id),
                            Text    = Resources.Common.Yes
                        },
                        No = new MessageBoxButtonConfig
                        {
                            Text = Resources.Common.No
                        }
                    }).Show();
                    break;

                case "imgAttach":
                    overrideForm.Reset();
                    RecordRequest req = new RecordRequest();
                    //req.employeeId = employeeId.ToString();
                    //req.dayId = dayId.ToString();
                    //req.shiftId = shiftId;
                    //req.timeCode = timeCodeParameter;
                    req.RecordID = id;
                    RecordResponse <DashBoardTimeVariation> resp = _timeAttendanceService.ChildGetRecord <DashBoardTimeVariation>(req);
                    if (!resp.Success)
                    {
                        Common.errorMessage(resp);
                        return;
                    }

                    ORId.Text = resp.result.recordId;
                    timeCodeStore.DataSource = ConstTimeVariationType.TimeCodeList(_systemService).Where(x => x.key == Convert.ToInt32(timeCodeParameter)).ToList();
                    timeCodeStore.DataBind();

                    FillBranch();
                    EmployeeQuickViewRecordRequest QVReq = new EmployeeQuickViewRecordRequest();
                    QVReq.RecordID = employeeId.ToString();

                    QVReq.asOfDate = DateTime.Now;
                    RecordResponse <EmployeeQuickView> qv = _employeeService.ChildGetRecord <EmployeeQuickView>(QVReq);

                    if (!qv.Success)
                    {
                        Common.errorMessage(qv);
                        return;
                    }
                    overrideForm.SetValues(resp.result);


                    branchId.Select(qv.result.branchId);

                    ListRequest UdIdReq = new ListRequest();

                    UdIdReq.Filter = "";
                    ListResponse <BiometricDevice> UdIdResp = _timeAttendanceService.ChildGetAll <BiometricDevice>(UdIdReq);
                    if (!UdIdResp.Success)
                    {
                        Common.errorMessage(UdIdResp);
                        return;
                    }
                    udIdStore.DataSource = UdIdResp.Items;
                    udIdStore.DataBind();
                    FlatPunchesListRequest FPreq = new FlatPunchesListRequest();
                    FPreq.shiftId = shiftId;
                    FPreq.sortBy  = "clockStamp";
                    FPreq.StartAt = "0";
                    FPreq.Size    = "30";
                    ListResponse <FlatPunch> FPresp = _timeAttendanceService.ChildGetAll <FlatPunch>(FPreq);

                    if (!FPresp.Success)
                    {
                        Common.errorMessage(FPresp);
                        return;
                    }

                    punchesList.Text = "";
                    FPresp.Items.ForEach(x =>
                    {
                        punchesList.Text += x.clockStamp.ToString(_systemService.SessionHelper.GetDateformat() + " HH:mm", CultureInfo.CurrentUICulture) + System.Environment.NewLine;
                    }


                                         );


                    inOutStore.DataSource = Common.XMLDictionaryList(_systemService, "34");
                    inOutStore.DataBind();
                    overrideWindow.Show();

                    break;

                case "LinkRender":
                    FillTimeApproval(id);
                    TimeApprovalWindow.Show();

                    break;

                case "imgHistory":

                    TimeVariationHistoryControl1.Show("41203", id);
                    break;

                default:
                    break;
                }
            }
            catch (Exception exp)
            {
                X.Msg.Alert(Resources.Common.Error, exp.Message).Show();
            }
        }