Ejemplo n.º 1
0
        public static bool CanPlanHaveFact(EDayPlanId dp, EDayFactId df)
        {
            switch (dp)
            {
            case EDayPlanId.SD:
            case EDayPlanId.DDSD:
                if (IsDayFactIdIN(df, EDayFactId.N, EDayFactId.V, EDayFactId.S))
                {
                    return(false);
                }
                break;

            case EDayPlanId.BD:
                if (IsDayFactIdIN(df, EDayFactId.N, EDayFactId.V, EDayFactId.S,
                                  EDayFactId.DS, EDayFactId.KS))
                {
                    return(false);
                }
                break;

            case EDayPlanId.SDDD:
                if (IsDayFactIdIN(df, EDayFactId.N, EDayFactId.B))
                {
                    return(false);
                }
                break;
            }

            return(true);
        }
Ejemplo n.º 2
0
        public static EDayFactId PlanIdToFactId(EDayPlanId planid)
        {
            switch (planid)
            {
            case EDayPlanId.DD: return(EDayFactId.D);

            case EDayPlanId.BD: return(EDayFactId.B);

            case EDayPlanId.SD: return(EDayFactId.B);

            case EDayPlanId.DDSD: return(EDayFactId.DS);

            case EDayPlanId.SDDD: return(EDayFactId.S);
            }
            return(EDayFactId.Error);
        }
Ejemplo n.º 3
0
        private void dgvPlans_CellParsing(object sender, DataGridViewCellParsingEventArgs e)
        {
            if (e.ColumnIndex >= dgcV1.Index && e.ColumnIndex <= dgcV31.Index)
            {
                if (e.Value == null || e.Value == DBNull.Value)
                {
                    return;
                }

                if (e.Value is string)
                {
                    EDayPlanId daycode;
                    float      hours;

                    if (!SomeDataDefs.ParsePlanDayStr(e.Value as string, out daycode, out hours))
                    {
                        e.Value          = 0.0f;
                        e.ParsingApplied = true;
                        return;
                    }

                    int daynr = e.ColumnIndex - dgcV1.Index + 1;

                    var dr = (dgvPlans.Rows[e.RowIndex].DataBoundItem as DataRowView).Row as KlonsADataSet.TIMESHEETRow;

                    EDayPlanId curdaycode = dr.DxPlan[daynr - 1];

                    if (daycode == EDayPlanId.None)
                    {
                        daycode = curdaycode;
                    }
                    if (daycode == EDayPlanId.BD || daycode == EDayPlanId.SD)
                    {
                        hours = 0.0f;
                    }

                    e.Value          = hours;
                    e.ParsingApplied = true;

                    if (daycode != curdaycode)
                    {
                        dr.DxPlan[daynr - 1] = daycode;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public static string GetPlanIdStr(EDayPlanId daycode)
        {
            switch (daycode)
            {
            case EDayPlanId.None: return("");

            case EDayPlanId.BD: return("B");

            case EDayPlanId.DD: return("D");

            case EDayPlanId.DDSD: return("DS");

            case EDayPlanId.SDDD: return("SD");

            case EDayPlanId.SD: return("S");
            }
            return(null);
        }
Ejemplo n.º 5
0
        public static bool ParsePlanDayStr(string fs, out EDayPlanId daycode, out float hours)
        {
            daycode = EDayPlanId.None;
            hours   = 0.0f;
            int v, k = -1;

            for (int i = 0; i < fs.Length; i++)
            {
                var c = fs.Substring(i, 1);
                if (int.TryParse(c, out v))
                {
                    k = i;
                    break;
                }
            }

            if (k == -1)
            {
                hours   = 0.0f;
                daycode = SomeDataDefs.GetPlanStrId(fs.Trim().ToUpper());
                return(daycode != EDayPlanId.None && daycode != EDayPlanId.Error);
            }

            if (k > 0)
            {
                var daystr = fs.Substring(0, k).Trim().ToUpper();
                daycode = SomeDataDefs.GetPlanStrId(daystr);
                if (daycode == EDayPlanId.None || daycode == EDayPlanId.Error)
                {
                    return(false);
                }
            }
            else
            {
                daycode = EDayPlanId.None;
            }
            var hoursstr = fs.Substring(k).Trim();

            return(float.TryParse(hoursstr, out hours));
        }
Ejemplo n.º 6
0
        private void cmsMenuMarkDay_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (bsPlans.Current == null || dgvPlans.CurrentCell == null || dgvPlans.CurrentRow.IsNewRow)
            {
                return;
            }
            var menuitems = new[] { miDD, miBD, miSD, miSDDD, miDDSD };
            var daycodes  = new[] { EDayPlanId.DD, EDayPlanId.BD,
                                    EDayPlanId.SD, EDayPlanId.DDSD, EDayPlanId.SDDD };

            int i, k = -1;

            for (i = 0; i < menuitems.Length; i++)
            {
                if (menuitems[i] == e.ClickedItem)
                {
                    k = i;
                    break;
                }
            }
            if (k == -1)
            {
                return;
            }
            var dr = (bsPlans.Current as DataRowView).Row as KlonsADataSet.TIMESHEETRow;

            EDayPlanId newdaycode = daycodes[k];
            int        colnr      = dgvPlans.CurrentCell.ColumnIndex;
            int        daynr      = colnr - dgcV1.Index + 1;

            if (dr.DxPlan[daynr - 1] != newdaycode)
            {
                dr.BeginEdit();
                dr.DxPlan[daynr - 1] = newdaycode;
                dr.EndEdit();
                RefreshCell(dr, colnr);
                dgvPlans.AutoResizeColumn(colnr);
            }
        }
Ejemplo n.º 7
0
 public static bool CanPlanHaveHours(EDayPlanId vv)
 {
     return(vv == EDayPlanId.DD || vv == EDayPlanId.DDSD ||
            vv == EDayPlanId.SDDD);
 }
Ejemplo n.º 8
0
 public static bool IsPlanWorkday(EDayPlanId vv)
 {
     return(vv == EDayPlanId.DDSD || vv == EDayPlanId.DD);
 }
Ejemplo n.º 9
0
 public static bool IsPlanHoliday(EDayPlanId vv)
 {
     return(vv == EDayPlanId.DDSD || vv == EDayPlanId.SD ||
            vv == EDayPlanId.SDDD);
 }
Ejemplo n.º 10
0
        private void dgvPlans_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.ColumnIndex == dgcKind1.Index)
            {
                if (e.Value == null || e.Value == DBNull.Value)
                {
                    return;
                }
                if (!(e.Value is short))
                {
                    return;
                }
                EKind1 k = (EKind1)e.Value;
                string s;
                if (k == EKind1.PlanGroupDay || k == EKind1.PlanIndividualDay)
                {
                    s = "diena";
                }
                else
                {
                    s = "nakts";
                }
                e.Value             = s;
                e.FormattingApplied = true;
                return;
            }
            if (e.ColumnIndex >= dgcV1.Index && e.ColumnIndex <= dgcV31.Index)
            {
                if (dgvPlans.Rows[e.RowIndex].IsNewRow)
                {
                    return;
                }
                if (e.Value == null || e.Value == DBNull.Value)
                {
                    return;
                }
                float v = (float)e.Value;

                int daynr = e.ColumnIndex - dgcV1.Index + 1;

                var dr = (dgvPlans.Rows[e.RowIndex].DataBoundItem as DataRowView).Row as KlonsADataSet.TIMESHEETRow;
                int dk = MyData.DataSetKlons.TIMESHEET.D1Column.Ordinal;

                if (dr.XKind1 == EKind1.PlanGroupaNight)
                {
                    if (v == 0.0f)
                    {
                        e.Value             = "";
                        e.FormattingApplied = true;
                    }
                    return;
                }

                EDayPlanId daycode = dr.DxPlan[daynr - 1];

                if (daycode == EDayPlanId.DD)
                {
                    return;
                }

                string daystr = SomeDataDefs.GetPlanIdStr(daycode);

                if (daycode == EDayPlanId.BD || daycode == EDayPlanId.SD)
                {
                    if (v == 0.0f)
                    {
                        e.Value = string.Format("{0}", daystr);
                    }
                    else
                    {
                        e.Value = string.Format("{0} {1}", daystr, v);
                    }

                    e.FormattingApplied = true;
                    return;
                }

                e.Value = string.Format("{0} {1}", daystr, v);

                e.FormattingApplied = true;
            }
        }
Ejemplo n.º 11
0
        public ErrorList CountTotalPlan(IWorkTimeData wt, DateTime dt1, DateTime dt2)
        {
            var        error_list = new ErrorList();
            string     errstr = string.Format("{0}.{1}", dt1.Year, dt1.Month);
            int        i, j;
            float      vp, vpn;
            int        i1          = dt1.Day;
            int        i2          = dt2.Day;
            EDayPlanId daycodeplan = EDayPlanId.None;
            EDayFactId daycodefact = EDayFactId.None;

            for (i = i1; i <= i2; i++)
            {
                bool plandayadded     = false;
                bool planworkdayadded = false;

                for (j = 0; j < this.Count; j++)
                {
                    var dlset = this[j];

                    daycodeplan = dlset.Plan.DxPlan[i - 1];
                    daycodefact = dlset.Fact.DxFact[i - 1];

                    if (daycodeplan == EDayPlanId.None)
                    {
                        continue;
                    }
                    if (daycodefact == EDayFactId.None || daycodefact == EDayFactId.X)
                    {
                        continue;
                    }

                    vp  = dlset.Plan.Vx[i - 1];
                    vpn = dlset.PlanNight == null ? 0.0f : dlset.PlanNight.Vx[i - 1];

                    if (vp + vpn == 0.0f)
                    {
                        continue;
                    }

                    if (!plandayadded)
                    {
                        wt._PLAN_DAYS++;
                    }
                    wt._PLAN_HOURS       += vp;
                    wt._PLAN_HOURS_NIGHT += vpn;

                    if (SomeDataDefs.IsPlanWorkday(daycodeplan) &&
                        (SomeDataDefs.IsDayForWork(daycodefact) || daycodefact == EDayFactId.B))
                    {
                        if (!planworkdayadded)
                        {
                            wt._PLAN_WORK_DAYS++;
                        }
                        wt._PLAN_WORK_HOURS       += vp;
                        wt._PLAN_WORK_HOURS_NIGHT += vpn;
                        planworkdayadded           = true;
                    }

                    if (daycodeplan == EDayPlanId.DDSD)
                    {
                        if (!plandayadded)
                        {
                            wt._PLAN_HOLIDAYS_DAYS++;
                        }
                        wt._PLAN_HOLIDAYS_HOURS       += vp;
                        wt._PLAN_HOLIDAYS_HOURS_NIGHT += vpn;
                    }

                    plandayadded = true;
                }
            }

            return(error_list);
        }
Ejemplo n.º 12
0
        public void CountSickDays(SickDayCalcRow sdi, DateTime dt1, DateTime dt2, int skipdays)
        {
            int        i1 = dt1.Day;
            int        i2 = dt2.Day;
            float      vp;
            EDayPlanId daycodeplan = EDayPlanId.None;
            EDayFactId daycodefact = EDayFactId.None;
            bool       isPlanWorkDay;


            for (int i = i1; i <= i2; i++)
            {
                bool dayadded = false;

                for (int j = 0; j < this.Count; j++)
                {
                    var dlset = this[j];

                    daycodeplan = dlset.Plan.DxPlan[i - 1];
                    daycodefact = dlset.Fact.DxFact[i - 1];

                    if (daycodeplan == EDayPlanId.None)
                    {
                        continue;
                    }
                    if (daycodefact == EDayFactId.X || daycodefact == EDayFactId.None)
                    {
                        continue;
                    }

                    isPlanWorkDay = daycodeplan == EDayPlanId.DD || daycodeplan == EDayPlanId.DDSD ||
                                    daycodeplan == EDayPlanId.SDDD;

                    vp = dlset.Plan.Vx[i - 1];

                    if (!isPlanWorkDay)
                    {
                        continue;
                    }
                    if (vp == 0.0f)
                    {
                        continue;
                    }

                    if (!dayadded)
                    {
                        skipdays++;
                        sdi.DaysCount++;
                    }
                    sdi.HoursCount += vp;

                    if (skipdays == 1)
                    {
                        if (!dayadded)
                        {
                            sdi.DaysCount0++;
                        }
                    }
                    else if (skipdays == 2 || skipdays == 3)
                    {
                        if (!dayadded)
                        {
                            sdi.DaysCount75++;
                        }
                        sdi.HoursCount75 += vp;
                    }
                    else if (skipdays >= 4 && skipdays <= 10)
                    {
                        if (!dayadded)
                        {
                            sdi.DaysCount80++;
                        }
                        sdi.HoursCount80 += vp;
                    }
                    dayadded = true;
                }
            }
        }
Ejemplo n.º 13
0
        public ErrorList CountTotalFact(IWorkTimeData wt, DateTime dt1, DateTime dt2)
        {
            var        error_list = new ErrorList();
            string     errstr = string.Format("{0}.{1}", dt1.Year, dt1.Month);
            int        i, j;
            float      v, vn, vo, vp;
            int        i1          = dt1.Day;
            int        i2          = dt2.Day;
            EDayPlanId daycodeplan = EDayPlanId.None;
            EDayFactId daycodefact = EDayFactId.None;

            for (i = i1; i <= i2; i++)
            {
                bool factdayadded = false;

                for (j = 0; j < this.Count; j++)
                {
                    var dlset = this[j];

                    daycodeplan = dlset.Plan.DxPlan[i - 1];
                    daycodefact = dlset.Fact.DxFact[i - 1];

                    if (daycodeplan == EDayPlanId.None)
                    {
                        continue;
                    }
                    if (daycodefact == EDayFactId.X || daycodefact == EDayFactId.None)
                    {
                        continue;
                    }

                    bool isFactHolidayWithBonus = daycodefact == EDayFactId.DS ||
                                                  daycodefact == EDayFactId.KS;
                    bool isAvPayFreeDay = daycodefact == EDayFactId.S ||
                                          daycodefact == EDayFactId.V || daycodefact == EDayFactId.AM;
                    //bool isAvPayWorkDay = daycodefact == EDayFactId.K;
                    bool isAvPayWorkDay = false;
                    bool IsFactWorkDay  = SomeDataDefs.IsDayForWork(daycodefact);


                    v  = dlset.Fact.Vx[i - 1];
                    vn = dlset.FactNight == null ? 0.0f : dlset.FactNight.Vx[i - 1];
                    vo = dlset.FactOvertime == null ? 0.0f : dlset.FactOvertime.Vx[i - 1];
                    vp = dlset.Plan.Vx[i - 1];

                    if (v + vp == 0)
                    {
                        continue;
                    }

                    if (isAvPayFreeDay)
                    {
                        if (vp == 0.0f)
                        {
                            continue;
                        }
                        if (!factdayadded)
                        {
                            wt._FACT_AVPAY_FREE_DAYS++;
                        }
                        wt._FACT_AVPAY_FREE_HOURS += vp;
                        wt._FACT_HOURS            += vp;

                        if (!factdayadded)
                        {
                            wt._FACT_DAYS++;
                        }

                        factdayadded = true;
                        continue;
                    }

                    if (!IsFactWorkDay)
                    {
                        continue;
                    }
                    if (v == 0)
                    {
                        continue;
                    }

                    wt._FACT_HOURS          += v;
                    wt._FACT_HOURS_NIGHT    += vn;
                    wt._FACT_HOURS_OVERTIME += vo;

                    if (isAvPayWorkDay)
                    {
                        if (!factdayadded)
                        {
                            wt._FACT_AVPAY_WORK_DAYS++;
                        }
                        wt._FACT_AVPAY_HOURS          += v;
                        wt._FACT_AVPAY_HOURS_OVERTIME += vo;

                        if (isFactHolidayWithBonus)
                        {
                            if (!factdayadded)
                            {
                                wt._FACT_AVPAY_WORKINHOLIDAYS++;
                            }
                            wt._FACT_AVPAY_HOLIDAYS_HOURS       += v;
                            wt._FACT_AVPAY_HOLIDAYS_HOURS_OVERT += vo;
                        }

                        if (!factdayadded)
                        {
                            wt._FACT_DAYS++;
                        }
                        factdayadded = true;
                        continue;
                    }

                    if (!factdayadded)
                    {
                        wt._FACT_WORK_DAYS++;
                    }
                    wt._FACT_WORK_HOURS          += v;
                    wt._FACT_WORK_HOURS_NIGHT    += vn;
                    wt._FACT_WORK_HOURS_OVERTIME += vo;

                    if (isFactHolidayWithBonus)
                    {
                        if (!factdayadded)
                        {
                            wt._FACT_HOLIDAYS_DAYS++;
                        }
                        wt._FACT_HOLIDAYS_HOURS          += v;
                        wt._FACT_HOLIDAYS_HOURS_NIGHT    += vn;
                        wt._FACT_HOLIDAYS_HOURS_OVERTIME += vo;
                    }

                    if (!factdayadded)
                    {
                        wt._FACT_DAYS++;
                    }
                    factdayadded = true;
                }
            }

            return(error_list);
        }
Ejemplo n.º 14
0
        public ErrorList CheckDays(SalaryInfo wt, DateTime dt1, DateTime dt2, int idp)
        {
            var        error_list = new ErrorList();
            string     errstr = string.Format("{0}.{1}", dt1.Year, dt1.Month);
            int        i, j;
            int        i1           = dt1.Day;
            int        i2           = dt2.Day;
            EDayPlanId daycodeplan  = EDayPlanId.None;
            EDayFactId daycodefact  = EDayFactId.None;
            EDayPlanId daycodeplan2 = EDayPlanId.None;
            EDayFactId daycodefact2 = EDayFactId.None;
            bool       iscodeset;

            for (i = i1; i <= i2; i++)
            {
                iscodeset = false;
                for (j = 0; j < this.Count; j++)
                {
                    daycodeplan = this[j].Plan.DxPlan[i - 1];
                    if (!iscodeset)
                    {
                        daycodeplan2 = daycodeplan;
                        iscodeset    = true;
                        continue;
                    }
                    if (daycodeplan != daycodeplan2)
                    {
                        var errs = string.Format("{0} nesakrīt darba laika plāna dati dažādiem amatiem dienai: {1}", errstr, i);
                        error_list.AddPersonError(idp, errs);
                    }
                }
                iscodeset = false;
                for (j = 0; j < this.Count; j++)
                {
                    daycodefact = this[j].Fact.DxFact[i - 1];
                    daycodeplan = this[j].Plan.DxPlan[i - 1];
                    if (daycodefact == EDayFactId.X || daycodefact == EDayFactId.None)
                    {
                        continue;
                    }
                    if (!iscodeset)
                    {
                        daycodefact2 = daycodefact;
                        daycodeplan2 = daycodeplan;
                        iscodeset    = true;

                        if (!SomeDataDefs.CanPlanHaveFact(daycodeplan, daycodefact))
                        {
                            var errs = string.Format("{0} nekorekts faktiski nostrādās dienas kods: {1}", errstr, i);
                            error_list.AddPersonError(idp, errs);
                        }

                        continue;
                    }

                    bool b1 = SomeDataDefs.IsSickDay(daycodefact) ||
                              SomeDataDefs.IsDayVacation(daycodefact) ||
                              daycodefact == EDayFactId.V;

                    bool b2 = SomeDataDefs.IsSickDay(daycodefact2) ||
                              SomeDataDefs.IsDayVacation(daycodefact2) ||
                              daycodefact2 == EDayFactId.V;

                    if (b1 != b2)
                    {
                        var errs = string.Format("{0} nesakrīt darba laika dati dažādiem amatiem dienai: {1}", errstr, i);
                        error_list.AddPersonError(idp, errs);
                    }
                }
            }

            return(error_list);
        }