Exemplo n.º 1
0
        public void DeleteRow(KlonsADataSet.SALARY_SHEETS_RRow dr_lapas_r)
        {
            var table_algas_ps = MyData.DataSetKlons.SALARY_PLUSMINUS;

            CheckTotalListForPeriod();
            int idp    = dr_lapas_r.IDP;
            int idam   = dr_lapas_r.IDAM;
            var drs_ps = table_algas_ps.WhereX(
                d =>
                d.IDSX == dr_lapas_r.IDSX &&
                !d.IsIDANull() &&
                d.IDA == idam
                ).ToArray();

            foreach (var dr in drs_ps)
            {
                dr.Delete();
            }
            dr_lapas_r.Delete();
            var salary_sheet_row = new SalarySheetRowSetInfo();
            var err = salary_sheet_row.SetUpFromRowB(this, idp);

            if (err.Count > 0)
            {
                return;
            }
            if (salary_sheet_row.DrLinkedRows.Length == 0 &&
                salary_sheet_row.DrTotalRow == null)
            {
                return;
            }
            salary_sheet_row.FillRow();
        }
Exemplo n.º 2
0
        public void MakeTotalsRow(int idp)
        {
            if (SalarySheet == null || SalarySheet.TotalsList == null)
            {
                throw new Exception("Bad init.");
            }

            var table_sar_r = MyData.DataSetKlons.SALARY_SHEETS_R;

            var new_dr_sar_r = table_sar_r.NewSALARY_SHEETS_RRow();

            new_dr_sar_r.ID   = (int)MyData.KlonsQueriesTableAdapter.SP_GEN_SALARY_SHEETS_R_ID();
            new_dr_sar_r.IDS  = SalarySheet.TotalsList.ID;
            new_dr_sar_r.IDSX = new_dr_sar_r.ID;
            new_dr_sar_r.SALARY_SHEETSRowByFK_SALARY_SHEETS_R_IDST = SalarySheet.TotalsList;
            new_dr_sar_r.IDST           = SalarySheet.TotalsList.ID;
            new_dr_sar_r.IDP            = idp;
            new_dr_sar_r["IDAM"]        = DBNull.Value;
            new_dr_sar_r.XType          = ESalarySheetRowType.Total;
            new_dr_sar_r.FNAME          = DR_Person_r.FNAME;
            new_dr_sar_r.LNAME          = DR_Person_r.LNAME;
            new_dr_sar_r.POSITION_TITLE = "KOPĀ";
            new_dr_sar_r.IS_TEMP        = SalarySheet.TotalsList.IS_TEMP;

            table_sar_r.Rows.Add(new_dr_sar_r);

            DrTotalRow = new_dr_sar_r;
        }
Exemplo n.º 3
0
        public void MakeRow(int idp, int idam, int snr)
        {
            var table_sar_r  = MyData.DataSetKlons.SALARY_SHEETS_R;
            var new_dr_sar_r = table_sar_r.NewSALARY_SHEETS_RRow();

            new_dr_sar_r.ID   = (int)MyData.KlonsQueriesTableAdapter.SP_GEN_SALARY_SHEETS_R_ID();
            new_dr_sar_r.IDSX = new_dr_sar_r.ID;
            new_dr_sar_r.SALARY_SHEETSRowByFK_SALARY_SHEETS_R_IDS = SalarySheet.DR_algas_lapa;
            new_dr_sar_r.IDP     = idp;
            new_dr_sar_r.IDAM    = idam;
            new_dr_sar_r.SNR     = (short)snr;
            new_dr_sar_r.FNAME   = DR_Person_r.FNAME;
            new_dr_sar_r.LNAME   = DR_Person_r.LNAME;
            new_dr_sar_r.IS_TEMP = SalarySheet.DR_algas_lapa.IS_TEMP;

            var s1 = GetPositionTitle(idam);

            if (s1 != null)
            {
                new_dr_sar_r.POSITION_TITLE = s1;
            }


            table_sar_r.Rows.Add(new_dr_sar_r);

            Row = new_dr_sar_r;

            CheckLinkedRows(Row.IDP);
            CheckAlgasPS();
        }
Exemplo n.º 4
0
        public ErrorList SetUpFromRowX(KlonsADataSet.SALARY_SHEETS_RRow dr_r)
        {
            Row = dr_r;
            var dr_sar = dr_r.SALARY_SHEETSRowByFK_SALARY_SHEETS_R_IDS;
            var ssh    = new SalarySheetInfo(dr_sar);

            SalarySheet = ssh;
            var er = ssh.SetUpLightFromSarRow(dr_sar);

            if (er != "OK")
            {
                return(new ErrorList("", er));
            }

            if (dr_r.XType == ESalarySheetRowType.Total)
            {
                return(SetUpT(dr_r.IDP));
            }

            if (dr_r.IsIDAMNull())
            {
                throw new Exception("Bad row.");
            }

            return(SetUp(dr_r.IDP, dr_r.IDAM));
        }
Exemplo n.º 5
0
        public static bool SaveReportToPdf(KlonsADataSet.SALARY_SHEETS_RRow dr_lapas_r, string filename)
        {
            var rd = MakeReportData(dr_lapas_r);

            if (rd == null)
            {
                return(false);
            }
            return(ReportHelper.RenderToPdf(rd, filename));
        }
Exemplo n.º 6
0
        public static void MakeReport1(KlonsADataSet.SALARY_SHEETS_RRow dr_lapas_r)
        {
            var rd = MakeReportData(dr_lapas_r);

            if (rd == null)
            {
                return;
            }
            MyData.MyMainForm.ShowReport(rd);
        }
Exemplo n.º 7
0
        public void ChangeIDSXForAlgasPSRows(int new_idsx, KlonsADataSet.SALARY_SHEETS_RRow dr_totalrow)
        {
            var drs_ps = dr_totalrow.GetSALARY_PLUSMINUSRows();

            foreach (var dr in drs_ps)
            {
                if (dr.IDSX != new_idsx)
                {
                    dr.IDSX = new_idsx;
                }
            }
        }
Exemplo n.º 8
0
        public ErrorList SetUpFromRowX(KlonsADataSet.SALARY_SHEETS_RRow dr_r)
        {
            var dr_sar1 = dr_r.SALARY_SHEETSRowByFK_SALARY_SHEETS_R_IDS;
            var ssh     = new SalarySheetInfo(dr_sar1);
            var er      = ssh.SetUpLightFromSarRow(dr_sar1);

            if (er != "OK")
            {
                return(new ErrorList("", er));
            }
            return(SetUpFromRowB(ssh, dr_r.IDP));
        }
Exemplo n.º 9
0
        public ErrorList CalcList(KlonsADataSet.SALARY_SHEETS_RRow dr)
        {
            var dr_sar = dr.SALARY_SHEETSRowByFK_SALARY_SHEETS_R_IDS;
            var srs    = new SalarySheetRowSetInfo();
            var err    = srs.SetUpFromRowX(dr);

            if (err.HasErrors)
            {
                return(err);
            }
            return(CalcList(srs.SalarySheet, srs.IDP, srs.TotalPersonPay));
        }
Exemplo n.º 10
0
        public void SetFromRow(KlonsADataSet.SALARY_SHEETS_RRow dr)
        {
            var props = TypeDescriptor.GetProperties(this);

            for (int i = 0; i < props.Count; i++)
            {
                var prop = props[i];
                if (!prop.Name.StartsWith("_"))
                {
                    continue;
                }
                var    fieldname = prop.Name.Substring(1);
                object val       = dr[fieldname];
                if (val == null || val == DBNull.Value)
                {
                    val = prop.PropertyType.GetDefaultValue();
                }
                prop.SetValue(this, val);
            }
        }
Exemplo n.º 11
0
        public void WriteToRow(KlonsADataSet.SALARY_SHEETS_RRow dr)
        {
            var  props       = TypeDescriptor.GetProperties(this);
            bool has_changes = false;

            dr.BeginEdit();
            for (int i = 0; i < props.Count; i++)
            {
                var prop = props[i];
                if (!prop.Name.StartsWith("_"))
                {
                    continue;
                }
                if (DontUpdateThese.Contains(prop.Name))
                {
                    continue;
                }
                var fieldname = prop.Name.Substring(1);
                var val1      = prop.GetValue(this);
                if (val1 == null)
                {
                    val1 = DBNull.Value;
                }
                var val2 = dr[fieldname];
                if (object.Equals(val1, val2))
                {
                    continue;
                }
                dr[fieldname] = val1;
                has_changes   = true;
            }
            if (has_changes)
            {
                dr.DT_EDITED = DateTime.Now;
            }
            dr.EndEditX();
        }
Exemplo n.º 12
0
        // seperate totalrow is used only when there are more than one linked rows
        public void CheckLinkedRows(int idp)
        {
            if (SalarySheet == null || SalarySheet.TotalsList == null)
            {
                throw new Exception("No totals sheet.");
            }

            var table_lapas_r = MyData.DataSetKlons.SALARY_SHEETS_R;

            var dt1 = SalarySheet.DT1;
            var dt2 = SalarySheet.DT2;

            var drs_lapas_r = table_lapas_r.WhereX(
                d =>
                d.IDP == IDP &&
                d.SALARY_SHEETSRowByFK_SALARY_SHEETS_R_IDS.DT1 == dt1 &&
                d.SALARY_SHEETSRowByFK_SALARY_SHEETS_R_IDS.DT2 == dt2
                ).ToArray();

            var drs_total_r = drs_lapas_r.Where(
                d =>
                d.XType == ESalarySheetRowType.Total
                ).ToArray();

            var drs_linked_r = drs_lapas_r.Where(
                d =>
                d.XType != ESalarySheetRowType.Total
                ).ToArray();

            if (drs_linked_r.Length == 0)
            {
                foreach (var dr in drs_total_r)
                {
                    dr.Delete();
                }
                this.DrTotalRow   = null;
                this.DrLinkedRows = new KlonsADataSet.SALARY_SHEETS_RRow[0];
            }
            else if (drs_linked_r.Length == 1)
            {
                foreach (var dr in drs_total_r)
                {
                    dr.Delete();
                }

                var dr0 = drs_linked_r[0];

                this.DrTotalRow = dr0;

                if (dr0.IsIDSTNull() || dr0.IDST != SalarySheet.TotalsList.ID)
                {
                    dr0["IDST"] = SalarySheet.TotalsList.ID;
                }
                if (dr0.IDSX != dr0.ID)
                {
                    dr0.IDSX = dr0.ID;
                }
                if (dr0.XType != ESalarySheetRowType.OnlyOne)
                {
                    dr0.XType = ESalarySheetRowType.OnlyOne;
                }

                this.DrLinkedRows    = new KlonsADataSet.SALARY_SHEETS_RRow[1];
                this.DrLinkedRows[0] = this.DrTotalRow;
            }
            else
            {
                for (int i = 1; i < drs_total_r.Length; i++)
                {
                    drs_total_r[i].Delete();
                }

                if (drs_total_r.Length == 0)
                {
                    MakeTotalsRow(idp);
                }
                else
                {
                    DrTotalRow = drs_total_r[0];
                }

                ChangeIDSXForAlgasPSRows(DrTotalRow.ID);

                foreach (var dr in drs_linked_r)
                {
                    if (dr.IDSX != DrTotalRow.ID)
                    {
                        dr.IDSX = DrTotalRow.ID;
                    }
                    if (dr["IDST"] != DBNull.Value)
                    {
                        dr["IDST"] = DBNull.Value;
                    }
                    if (dr.XType != ESalarySheetRowType.OneOfMany)
                    {
                        dr.XType = ESalarySheetRowType.OneOfMany;
                    }
                }

                DrLinkedRows = drs_linked_r;
            }
        }
Exemplo n.º 13
0
 public ErrorList SetUpFromRow(KlonsADataSet.SALARY_SHEETS_RRow dr_r)
 {
     Row = dr_r;
     return(SetUp(dr_r.IDP, dr_r.IDAM));
 }
Exemplo n.º 14
0
 public SalarySheetRowInfo(SalarySheetInfo salarySheet, KlonsADataSet.SALARY_SHEETS_RRow dr_r)
 {
     SalarySheet = salarySheet;
     Row         = dr_r;
 }
Exemplo n.º 15
0
        public static ReportViewerData MakeReportData(KlonsADataSet.SALARY_SHEETS_RRow dr_lapas_r)
        {
            var sr  = new SalarySheetRowInfo();
            var err = sr.SetUpFromRowX(dr_lapas_r);

            if (err.HasErrors)
            {
                Form_ErrorList.ShowErrorList(MyData.MyMainForm, err);
                return(null);
            }
            sr.CheckLinkedRows(dr_lapas_r.IDP);

            var sc = new SalaryCalcTInfo(sr.SalarySheetRowSet, new SalaryInfo(), true);

            err = sc.FillRow();
            if (err.HasErrors)
            {
                Form_ErrorList.ShowErrorList(MyData.MyMainForm, err);
                return(null);
            }

            var person = string.Format("{0} {1}, {2}", sr.DR_Person_r.FNAME,
                                       sr.DR_Person_r.LNAME, sr.GetPositionTitle().Nz().ToLower());
            var period = string.Format("{0:dd.MM.yyyy} - {1:dd.MM.yyyy}",
                                       sr.SalarySheet.DT1, sr.SalarySheet.DT2);

            ReportViewerData rd = new ReportViewerData();

            rd.FileName = "ReportA_AprIzklasts_1";
            if (sr.IsSingleRow())
            {
                var sc0 = sc.LinkedSCI[0];
                sc0.CheckBeforeReport();

                sc0.AvPayCalc.SetCurMonthPay(sr.SalarySheet.YR, sr.SalarySheet.MT, sc.TotalSI._TOTAL_BEFORE_TAXES, sc.TotalSI._PAY);

                rd.Sources["dsSickPay"]     = sc0.SickDayCalc?.Rows;
                rd.Sources["dsAvPay"]       = sc0.AvPayCalc.ReportRows;
                rd.Sources["dsWorkPay"]     = sc0.WorkPayCalc.GetRows2();
                rd.Sources["dsVacationPay"] = sc0.VacationCalc.Rows;
                rd.Sources["dsCalcR"]       = sc0.CalcR.ReportRows;
                rd.Sources["dsBonus"]       = sc0.BonusCalc.ReportRows;
                rd.Sources["dsSalary"]      = sc0.MakeReport1();
                rd.AddReportParameters(new string[]
                {
                    "CompanyName", MyData.Params.CompNameX,
                    "RPerson", person,
                    "RPeriod", period,
                    "RSickPay", sc0.SickDayCalc.TotalRow.SickDayPay.ToString("N2"),
                    "RSickPay75", sc0.SickDayCalc.TotalRow.SickDayPay75.ToString("N2"),
                    "RSickPay80", sc0.SickDayCalc.TotalRow.SickDayPay80.ToString("N2"),
                    "RAvPayHour", sc0.AvPayCalc.RateHour.ToString("N4"),
                    "RAvPayDay", sc0.AvPayCalc.RateDay.ToString("N4"),
                    "RAvPayCalDay", sc0.AvPayCalc.RateCalendarDay.ToString("N4"),
                    "RAvPayRemark", sc0.AvPayCalc.UsingMinRate?"Izmantotas minimālās likmes.": "",
                    "RPosTitle0", sc0.SR.GetPositionTitle(),
                    "RPosTitle1", null,
                    "RPosTitle2", null,
                    "RPosTitle3", null,
                    "RPosTitle4", null,
                    "RIsAvPayUsed", sc0.SI.IsAvPayUsed().ToString()
                });
            }
            else
            {
                var rep = sc.MakeReport1();
                sc.CheckBeforeReport();

                sc.AvPayCalc.SetCurMonthPay(sr.SalarySheet.YR, sr.SalarySheet.MT, sc.TotalSI._TOTAL_BEFORE_TAXES, sc.TotalSI._PAY);

                rd.Sources["dsSickPay"]     = sc.SickDayCalc.Rows;
                rd.Sources["dsAvPay"]       = sc.AvPayCalc.ReportRows;
                rd.Sources["dsWorkPay"]     = sc.WorkPayCalc.GetRows2();
                rd.Sources["dsVacationPay"] = sc.VacationCalc.Rows;
                rd.Sources["dsCalcR"]       = sc.CalcR.ReportRows;
                rd.Sources["dsBonus"]       = sc.BonusCalc.ReportRows;
                rd.Sources["dsSalary"]      = rep.GetGoodRows();
                rd.AddReportParameters(new string[]
                {
                    "CompanyName", MyData.Params.CompNameX,
                    "RPerson", person,
                    "RPeriod", period,
                    "RSickPay", sc.SickDayCalc.TotalRow.SickDayPay.ToString("N2"),
                    "RSickPay75", sc.SickDayCalc.TotalRow.SickDayPay75.ToString("N2"),
                    "RSickPay80", sc.SickDayCalc.TotalRow.SickDayPay80.ToString("N2"),
                    "RAvPayHour", sc.AvPayCalc.RateHour.ToString("N4"),
                    "RAvPayDay", sc.AvPayCalc.RateDay.ToString("N4"),
                    "RAvPayCalDay", sc.AvPayCalc.RateCalendarDay.ToString("N4"),
                    "RAvPayRemark", sc.AvPayCalc.UsingMinRate?"Izmantotas minimālās likmes.": "",
                    "RPosTitle0", rep.Titles[0],
                    "RPosTitle1", rep.Titles[1],
                    "RPosTitle2", rep.Titles[2],
                    "RPosTitle3", rep.Titles[3],
                    "RPosTitle4", rep.Titles[4],
                    "RIsAvPayUsed", sc.TotalSI.IsAvPayUsed().ToString()
                });
            }
            return(rd);
        }