Example #1
0
        private SalaryInfo GetPrevRowA()
        {
            var dt1           = SalarySheet.DT1;
            var dt2           = SalarySheet.DT2;
            var idp           = Row.IDP;
            var idam          = Row["IDAM"];
            var id            = Row.ID;
            var dtp1          = dt2.FirstDayOfMonth().AddMonths(-1);
            var dtp2          = dtp1.LastDayOfMonth();
            var table_lapas_r = MyData.DataSetKlons.SALARY_SHEETS_R;

            var dr_lapas_r = table_lapas_r.WhereX(
                d =>
                d.ID != id &&
                d.IDP == idp &&
                object.Equals(d["IDAM"], idam) &&
                d.SALARY_SHEETSRowByFK_SALARY_SHEETS_R_IDS.DT2.IsBetween(dtp1, dtp2) &&
                d.SALARY_SHEETSRowByFK_SALARY_SHEETS_R_IDS.IS_TEMP == 0 &&
                d.SALARY_SHEETSRowByFK_SALARY_SHEETS_R_IDS.XKind != ESalarySheetKind.Total
                ).WithMaxOrDefault(d => d.SALARY_SHEETSRowByFK_SALARY_SHEETS_R_IDS.DT2);

            if (dr_lapas_r == null)
            {
                return(null);
            }

            var dtm = dr_lapas_r.SALARY_SHEETSRowByFK_SALARY_SHEETS_R_IDS.DT2;

            var ret = new SalaryInfo();

            ret.SetFromRow(dr_lapas_r);
            return(ret);
        }
Example #2
0
        public static List <SalaryRepRow2> MakeReport2(SalarySheetInfo sh)
        {
            var ret = new List <SalaryRepRow2>();
            var drs = sh.DR_algas_lapa.KIND == 1 ?
                      sh.DR_algas_lapa.GetSALARY_SHEETS_RRowsByFK_SALARY_SHEETS_R_IDST().OrderBy(d => d.SNR) :
                      sh.DR_algas_lapa.GetSALARY_SHEETS_RRowsByFK_SALARY_SHEETS_R_IDS().OrderBy(d => d.SNR);
            var drsa = drs.ToArray();

            for (int i = 0; i < drsa.Length; i++)
            {
                var dr = drsa[i];
                var si = new SalaryInfo();
                si.SetFromRow(dr);
                var reprow = new SalaryRepRow2();
                reprow.SetFrom(si);
                reprow.SNR = i + 1;
                ret.Add(reprow);
            }
            return(ret);
        }
Example #3
0
        public SalaryInfo GetPrevRow()
        {
            if (Row.XType != ESalarySheetRowType.Total)
            {
                return(GetPrevRowA());
            }

            var dt1           = SalarySheet.DT1;
            var dt2           = SalarySheet.DT2;
            var idp           = Row.IDP;
            var id            = Row.ID;
            var dtp1          = dt2.FirstDayOfMonth().AddMonths(-1);
            var dtp2          = dtp1.LastDayOfMonth();
            var table_lapas_r = MyData.DataSetKlons.SALARY_SHEETS_R;

            var dr_lapas_r = table_lapas_r.WhereX(
                d =>
                d.ID != id &&
                d.IDP == idp &&
                d.IsIDAMNull() &&
                d.SALARY_SHEETSRowByFK_SALARY_SHEETS_R_IDS.DT2 >= dtp1 &&
                d.SALARY_SHEETSRowByFK_SALARY_SHEETS_R_IDS.DT2 <= dtp2 &&
                d.SALARY_SHEETSRowByFK_SALARY_SHEETS_R_IDS.IS_TEMP == 0 &&
                d.SALARY_SHEETSRowByFK_SALARY_SHEETS_R_IDS.XKind == ESalarySheetKind.Total
                ).WithMaxOrDefault(d => d.SALARY_SHEETSRowByFK_SALARY_SHEETS_R_IDS.DT2);

            if (dr_lapas_r == null)
            {
                return(null);
            }

            var ret = new SalaryInfo();

            ret.SetFromRow(dr_lapas_r);
            return(ret);
        }
Example #4
0
        public ErrorList SetUpT(int idp)
        {
            if (SalarySheet == null)
            {
                throw new Exception("Bad init.");
            }

            var table_sar     = MyData.DataSetKlons.SALARY_SHEETS;
            var table_sar_r   = MyData.DataSetKlons.SALARY_SHEETS_R;
            var table_persons = MyData.DataSetKlons.PERSONS;

            var    error_list = new ErrorList();
            string error_source;

            int yr  = SalarySheet.YR;
            int mt  = SalarySheet.MT;
            var dt1 = SalarySheet.MDT1;
            var dt2 = SalarySheet.MDT2;

            var dr_person = table_persons.FindByID(idp);

            if (dr_person == null)
            {
                error_list.AddError("Algas lapa", "Nav darbinieka");
                return(error_list);
            }

            error_source = string.Format("Darbinieks :{0} {1})",
                                         dr_person.FNAME,
                                         dr_person.LNAME);

            var drs_persons_r = dr_person.GetPERSONS_RRows().OrderBy(d => d.EDIT_DATE).ToArray();


            DR_Person_r = PeriodInfo.FindNearestBefore(drs_persons_r,
                                                       dt2, d => d.EDIT_DATE);

            if (DR_Person_r == null)
            {
                error_list.AddError(error_source, "Norādītajam periodam nav ievadīti darbinieka dati.");
                return(error_list);
            }

            PersonR.DateFirst = dt1;
            PersonR.DateLast  = dt2;

            var drs_person_r = dr_person.GetPERSONS_RRows().OrderBy(d => d.EDIT_DATE).ToArray();

            //var rete = PersonR.ReadDateListFilter(drs_person_r, d => d.EDIT_DATE);
            var rete = PersonR.ReadDateListAll(drs_person_r, d => d.EDIT_DATE);

            if (rete != PeriodInfo.ERetReadStartEndList.OK || PersonR.LinkedPeriods[0].DateFirst > dt2)
            {
                error_list.AddError(error_source, "Norādītajam periodam nav ievadīti darbinieka dati.");
                return(error_list);
            }

            if (Events == null)
            {
                if (!GetEventList(error_list, idp))
                {
                    return(error_list);
                }
            }

            if (Row != null)
            {
                TotalPositionPay = new SalaryInfo();
                TotalPositionPay.SetFromRow(Row);
            }

            return(error_list);
        }
Example #5
0
        public ErrorList SetUp(int idp, int idam)
        {
            if (SalarySheet == null)
            {
                throw new Exception("Bad init.");
            }

            var table_sar         = MyData.DataSetKlons.SALARY_SHEETS;
            var table_sar_r       = MyData.DataSetKlons.SALARY_SHEETS_R;
            var table_darba_laiks = MyData.DataSetKlons.TIMESHEET;
            var table_sh          = MyData.DataSetKlons.SALARY_SHEET_TEMPL;
            var table_sh_r        = MyData.DataSetKlons.SALARY_SHEET_TEMPL_R;
            var table_persons     = MyData.DataSetKlons.PERSONS;
            var table_amati       = MyData.DataSetKlons.POSITIONS;
            var table_dl_sar_r    = MyData.DataSetKlons.TIMESHEET_LISTS_R;


            var    error_list = new ErrorList();
            string error_source;

            int yr  = SalarySheet.YR;
            int mt  = SalarySheet.MT;
            var dt1 = SalarySheet.MDT1;
            var dt2 = SalarySheet.MDT2;

            //var dv_dl_sar_r = new DataView(table_dl_sar_r);
            //dv_dl_sar_r.RowFilter = string.Format("Parent(FK_TIMESHEET_LISTS_R_IDS).YR = {0} AND Parent(FK_TIMESHEET_LISTS_R_IDS).MT = {1}", yr, mt);

            var dr_person = table_persons.FindByID(idp);
            var dr_amats  = table_amati.FindByID(idam);

            if (dr_person == null)
            {
                error_list.AddError("Algas lapa", "Nav darbinieka");
                return(error_list);
            }

            if (dr_amats == null)
            {
                error_list.AddError("Algas lapa", "Nav amata");
                return(error_list);
            }

            if (DR_salary_sheet_r_templ == null)
            {
                error_source = string.Format("Darbinieks :{0} {1} ({2})",
                                             dr_person.FNAME,
                                             dr_person.LNAME,
                                             dr_amats.TITLE);
            }
            else
            {
                error_source = string.Format("Lapa:{0} rinda:{1}",
                                             DR_salary_sheet_r_templ.SALARY_SHEET_TEMPLRow.SNR,
                                             DR_salary_sheet_r_templ.SNR);
            }

            var drs_persons_r = dr_person.GetPERSONS_RRows().OrderBy(d => d.EDIT_DATE).ToArray();


            DR_Person_r = PeriodInfo.FindNearestBefore(drs_persons_r,
                                                       dt2, d => d.EDIT_DATE);

            if (DR_Person_r == null)
            {
                error_list.AddError(error_source, "Norādītajam periodam nav ievadīti darbinieka dati.");
                return(error_list);
            }

            PersonR.DateFirst = dt1;
            PersonR.DateLast  = dt2;

            var drs_person_r = dr_person.GetPERSONS_RRows().OrderBy(d => d.EDIT_DATE).ToArray();

            //var rete = PersonR.ReadDateListFilter(drs_person_r, d => d.EDIT_DATE);
            var rete = PersonR.ReadDateListAll(drs_person_r, d => d.EDIT_DATE);

            if (rete != PeriodInfo.ERetReadStartEndList.OK || PersonR.LinkedPeriods[0].DateFirst > dt2)
            {
                error_list.AddError(error_source, "Norādītajam periodam nav ievadīti darbinieka dati.");
                return(error_list);
            }


            PositionsR.DateFirst = dt1;
            PositionsR.DateLast  = dt2;

            var drs_amats_r = dr_amats.GetPOSITIONS_RRows().OrderBy(d => d.EDIT_DATE).ToArray();

            rete = PositionsR.ReadDateListFilter(drs_amats_r, d => d.EDIT_DATE);
            if (rete != PeriodInfo.ERetReadStartEndList.OK)
            {
                error_list.AddError(error_source, "Norādītajam periodam nav ievadīti amata dati.");
                return(error_list);
            }

            var drs_dl_sar_r = dr_person.GetTIMESHEET_LISTS_RRows()
                               .WhereX(
                d =>
                d.TIMESHEET_LISTSRow.YR == yr &&
                d.TIMESHEET_LISTSRow.MT == mt &&
                d.IDAM == dr_amats.ID)
                               .ToArray();

            if (drs_dl_sar_r.Length == 0)
            {
                error_list.AddError(error_source, "Norādītajam periodam nav darba laika uzskaites datu.");
                return(error_list);
            }

            if (drs_dl_sar_r.Length > 1)
            {
                error_list.AddError(error_source, "Darba laika uzskaites datu rindu skaits > 1.");
                return(error_list);
            }

            var dr_dl_sar_r = drs_dl_sar_r[0];

            var dlrowset = dr_dl_sar_r.GetDLRowSet();

            DLRows = dlrowset;
            SetDLRows(dlrowset);

            if (DLRows == null || DLRows.Plan == null || DLRows.Fact == null ||
                (dr_dl_sar_r.NIGHT == 1 && (DLRows.PlanNight == null || DLRows.FactNight == null)) ||
                (dr_dl_sar_r.OVERTIME == 1 && DLRows.FactOvertime == null))
            {
                error_list.AddError(error_source, "Nekorekti darba laika uzskaites dati.");
                return(error_list);
            }

            if (Events == null)
            {
                if (!GetEventList(error_list, idp))
                {
                    return(error_list);
                }
            }

            if (IsRateTypeChangedDuringVacation(drs_amats_r))
            {
                error_list.AddError(error_source, "Atvaļinājuma laikā nevar mainīt algas likmes veidu.");
            }

            var err1 = CheckVacationTimePlan(idam);

            if (err1 != "OK")
            {
                error_list.AddError(error_source, err1);
                return(error_list);
            }

            if (Row != null)
            {
                TotalPositionPay = new SalaryInfo();
                TotalPositionPay.SetFromRow(Row);
            }

            return(error_list);
        }