Esempio n. 1
0
        private ErrorList SetUpFromRowZ(SalarySheetRowInfo sr = null)
        {
            if ((sr != null && sr.Row == null) || DR_Person_r == null || SalarySheet == null)
            {
                throw new Exception("Bad init.");
            }

            var       error_list = new ErrorList();
            ErrorList err;

            TotalRow   = null;
            LinkedRows = new SalarySheetRowInfo[0];

            CheckLinkedRows(IDP);

            if (DrTotalRow == null || DrLinkedRows.Length == 0)
            {
                return(error_list);
            }

            LinkedRows = new SalarySheetRowInfo[DrLinkedRows.Length];

            var error_source = string.Format("{0} {1} ({2}-{3})",
                                             DR_Person_r.FNAME,
                                             DR_Person_r.LNAME,
                                             SalarySheet.CalendarMonth.Year,
                                             SalarySheet.CalendarMonth.Month);

            GetEventList(error_list, IDP);

            if (error_list.Count > 0)
            {
                return(error_list);
            }

            for (int i = 0; i < DrLinkedRows.Length; i++)
            {
                var dr = DrLinkedRows[i];
                if (dr == sr?.Row)
                {
                    LinkedRows[i]        = sr;
                    sr.SalarySheetRowSet = this;
                    sr.Events            = Events;
                    continue;
                }
                var lr = new SalarySheetRowInfo(SalarySheet, dr);
                LinkedRows[i]        = lr;
                lr.SalarySheetRowSet = this;
                lr.Events            = Events;
                err         = lr.SetUpFromRow(dr);
                error_list += err;
            }

            if (IsSingleRow())
            {
                TotalRow = LinkedRows[0];
            }
            else
            {
                if (DrTotalRow == sr?.Row)
                {
                    TotalRow = sr;
                    TotalRow.SalarySheetRowSet = this;
                }
                else
                {
                    TotalRow = new SalarySheetRowInfo(SalarySheet, DrTotalRow);
                    TotalRow.SalarySheetRowSet = this;
                    TotalRow.Events            = Events;
                    error_list += TotalRow.SetUpT(IDP);
                }
            }

            if (error_list.HasErrors)
            {
                return(error_list);
            }

            if (TotalRow?.TotalPositionPay != null)
            {
                TotalPersonPay = TotalRow.TotalPositionPay;
            }

            if (error_list.HasErrors)
            {
                LinkedRows = null;
                return(error_list);
            }

            return(error_list);
        }