Esempio n. 1
0
        protected void Store1_RefreshData(object sender, StoreReadDataEventArgs e)
        {
            try
            {
                //GEtting the filter from the page

                string rep_params = vals.Text;
                //ReportGenericRequest req = new ReportGenericRequest();
                TVListRequest req = new TVListRequest();
                req.paramString = rep_params;
                req.size        = "5000";
                req.startAt     = "0";
                req.sortBy      = "date,employeeRef";

                ListResponse <DashBoardTimeVariation3> daysResponse = _timeAttendanceService.ChildGetAll <DashBoardTimeVariation3>(req);

                //ActiveAttendanceRequest r = GetActiveAttendanceRequest();

                //ListResponse<ActiveAbsence> daysResponse = _timeAttendanceService.ChildGetAll<ActiveAbsence>(r);
                if (!daysResponse.Success)
                {
                    Common.errorMessage(daysResponse);
                    return;
                }
                bool rtl = _systemService.SessionHelper.CheckIfArabicSession();
                List <XMLDictionary> timeCode   = ConstTimeVariationType.TimeCodeList(_systemService);
                List <XMLDictionary> statusList = Common.XMLDictionaryList(_systemService, "13");
                List <XMLDictionary> damageList = Common.XMLDictionaryList(_systemService, "22");
                daysResponse.Items.ForEach(
                    x =>
                {
                    x.clockDurationString = time(x.clockDuration, true);
                    x.durationString      = time(x.duration, true);
                    x.timeCodeString      = timeCode.Where(y => y.key == Convert.ToInt16(x.timeCode)).Count() != 0 ? timeCode.Where(y => y.key == Convert.ToInt32(x.timeCode)).First().value : string.Empty;

                    x.apStatusString    = statusList.Where(y => y.key == x.apStatus).Count() != 0 ? statusList.Where(y => y.key == x.apStatus).First().value : "";
                    x.damageLevelString = damageList.Where(y => y.key == x.damageLevel).Count() != 0 ? damageList.Where(y => y.key == x.damageLevel).First().value : "";
                    if (rtl)
                    {
                        x.dayIdString = DateTime.ParseExact(x.dayId, "yyyyMMdd", new CultureInfo("en")).ToString("dddd  dd MMMM yyyy ", new System.Globalization.CultureInfo("ar-AE"));
                    }
                    else
                    {
                        x.dayIdString = DateTime.ParseExact(x.dayId, "yyyyMMdd", new CultureInfo("en")).ToString("dddd  dd MMMM yyyy ", new System.Globalization.CultureInfo("en-US"));
                    }
                }
                    );
                Store1.DataSource = daysResponse.Items;
                Store1.DataBind();
                e.Total     = daysResponse.count;
                format.Text = _systemService.SessionHelper.GetDateformat().ToUpper();
            }
            catch (Exception exp)
            {
                X.Msg.Alert(Resources.Common.Error, exp.Message).Show();
            }
        }
Esempio n. 2
0
        protected void Apply_Click(object sender, DirectEventArgs e)
        {
            try
            {
                if (ApprovalStatusId.SelectedItem.Value == null && DamageLevelId.SelectedItem.Value == null && justification.Text == "")
                {
                    if (ApprovalStatusId.SelectedItem.Value == null)
                    {
                        X.Msg.Alert(Resources.Common.Error, (string)GetLocalResourceObject("SelectApproval")).Show();
                        return;
                    }
                    else if (DamageLevelId.SelectedItem.Value == null)
                    {
                        X.Msg.Alert(Resources.Common.Error, (string)GetLocalResourceObject("SelectDamage")).Show();
                        return;
                    }
                    else if (justification.Text == null)
                    {
                        X.Msg.Alert(Resources.Common.Error, (string)GetLocalResourceObject("FillJustification")).Show();
                        return;
                    }
                }
                else
                {
                    string rep_params = vals.Text;
                    //ReportGenericRequest req = new ReportGenericRequest();
                    TVListRequest req = new TVListRequest();
                    req.paramString = rep_params;
                    req.size        = "5000";
                    req.startAt     = "0";
                    req.sortBy      = "date,employeeRef";

                    ListResponse <DashBoardTimeVariation3> daysResponse = _timeAttendanceService.ChildGetAll <DashBoardTimeVariation3>(req);
                    if (!daysResponse.Success)
                    {
                        Common.errorMessage(daysResponse);
                        return;
                    }

                    DashBoardTimeVariation b = new DashBoardTimeVariation();

                    if (daysResponse.Items.Count > 0)
                    {
                        daysResponse.Items.ForEach(
                            x =>
                        {
                            b.apId = x.apId;
                            if (ApprovalStatusId.SelectedItem.Value == null)
                            {
                                b.apStatus       = x.apStatus;
                                b.apStatusString = x.apStatusString;
                            }
                            else
                            {
                                b.apStatus       = Convert.ToInt16(ApprovalStatusId.SelectedItem.Value);
                                b.apStatusString = ApprovalStatusId.SelectedItem.Text;
                            }
                            b.branchName          = x.branchName;
                            b.clockDuration       = x.clockDuration;
                            b.clockDurationString = x.clockDurationString;
                            if (arId.SelectedItem.Value == null)
                            {
                                b.arId = x.arId;
                            }
                            else
                            {
                                b.arId = arId.SelectedItem.Value;
                            }

                            if (DamageLevelId.SelectedItem.Value == null)
                            {
                                b.damageLevel       = x.damageLevel;
                                b.damageLevelString = x.damageLevelString;
                            }
                            else
                            {
                                b.damageLevel       = Convert.ToInt16(DamageLevelId.SelectedItem.Value);
                                b.damageLevelString = DamageLevelId.SelectedItem.Text;
                            }

                            b.date           = x.date;
                            b.dayId          = x.dayId;
                            b.dayIdDate      = x.dayIdDate;
                            b.dayIdString    = x.dayIdString;
                            b.dtFrom         = x.dtFrom;
                            b.dtTo           = x.dtTo;
                            b.duration       = x.duration;
                            b.durationString = x.durationString;
                            b.employeeId     = x.employeeId;
                            b.employeeName   = x.employeeName;
                            b.employeeRef    = x.employeeRef;
                            if (justification.Text == "")
                            {
                                b.justification = x.justification;
                            }
                            else
                            {
                                b.justification = justification.Text;
                            }
                            b.positionName = x.positionName;
                            //b.primaryKey = x.primaryKey;
                            b.recordId       = x.recordId;
                            b.shiftId        = x.shiftId;
                            b.timeCode       = x.timeCode;
                            b.timeCodeString = x.timeCodeString;

                            PostRequest <DashBoardTimeVariation> request = new PostRequest <DashBoardTimeVariation>();
                            request.entity = b;

                            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;
                            }
                        }
                            );
                        //ReloadData(new object(), new DirectEventArgs(new Ext.Net.ParameterCollection()));
                    }
                }
            }
            catch (Exception exp)
            {
                X.MessageBox.Alert(Resources.Common.Error, exp.Message);
            }

            //ReloadData(new object(), new DirectEventArgs(new Ext.Net.ParameterCollection()));

            Store1.RemoveAll();
        }