Esempio n. 1
0
        private bool SaveGridChanges()
        {
            //validate all grid cells
            double dbl         = 0;
            int    deductIdx   = gridMain.ListGridColumns.GetIndex(Lan.g("TableClaimProc", "Deduct"));
            int    allowedIdx  = gridMain.ListGridColumns.GetIndex(Lan.g("TableClaimProc", "Allowed"));
            int    insPayIdx   = gridMain.ListGridColumns.GetIndex(Lan.g("TableClaimProc", "Ins Pay"));
            int    writeoffIdx = gridMain.ListGridColumns.GetIndex(Lan.g("TableClaimProc", "Writeoff"));
            int    statusIdx   = gridMain.ListGridColumns.GetIndex(Lan.g("TableClaimProc", "Status"));

            for (int i = 0; i < gridMain.ListGridRows.Count; i++)
            {
                try{
                    //Check for invalid numbers being entered.
                    if (gridMain.ListGridRows[i].Cells[deductIdx].Text != "")
                    {
                        dbl = Convert.ToDouble(gridMain.ListGridRows[i].Cells[deductIdx].Text);
                    }
                    if (gridMain.ListGridRows[i].Cells[allowedIdx].Text != "")
                    {
                        dbl = Convert.ToDouble(gridMain.ListGridRows[i].Cells[allowedIdx].Text);
                    }
                    if (gridMain.ListGridRows[i].Cells[insPayIdx].Text != "")
                    {
                        dbl = Convert.ToDouble(gridMain.ListGridRows[i].Cells[insPayIdx].Text);
                    }
                    if (gridMain.ListGridRows[i].Cells[writeoffIdx].Text != "")
                    {
                        dbl = Convert.ToDouble(gridMain.ListGridRows[i].Cells[writeoffIdx].Text);
                        if (dbl < 0 && gridMain.ListGridRows[i].Cells[statusIdx].Text != "Supp")
                        {
                            MsgBox.Show(this, "Only supplemental payments can have a negative writeoff.");
                            return(false);
                        }
                        double claimWriteOffTotal = ClaimProcs.GetClaimWriteOffTotal(ClaimProcsToEdit[0].ClaimNum, ClaimProcsToEdit[i].ProcNum, ClaimProcsToEdit.ToList());
                        if (claimWriteOffTotal + dbl < 0)
                        {
                            MsgBox.Show(this, "The current writeoff value for supplemental payment " + (i + 1).ToString() + " will cause the procedure's total writeoff to be negative.  Please change it to be at least " + (dbl - (claimWriteOffTotal + dbl)).ToString() + " to continue.");
                            return(false);
                        }
                    }
                }
                catch {
                    MsgBox.Show(this, "Invalid number.  It needs to be in 0.00 form.");
                    return(false);
                }
            }
            if (IsWriteOffGreaterThanProcFee())
            {
                return(false);
            }
            if (!isClaimProcGreaterThanProcFee())
            {
                return(false);
            }
            for (int i = 0; i < ClaimProcsToEdit.Length; i++)
            {
                ClaimProcsToEdit[i].DedApplied = PIn.Double(gridMain.ListGridRows[i].Cells[deductIdx].Text);
                if (gridMain.ListGridRows[i].Cells[allowedIdx].Text == "")
                {
                    ClaimProcsToEdit[i].AllowedOverride = -1;
                }
                else
                {
                    ClaimProcsToEdit[i].AllowedOverride = PIn.Double(gridMain.ListGridRows[i].Cells[allowedIdx].Text);
                }
                ClaimProcsToEdit[i].InsPayAmt = PIn.Double(gridMain.ListGridRows[i].Cells[insPayIdx].Text);
                ClaimProcsToEdit[i].WriteOff  = PIn.Double(gridMain.ListGridRows[i].Cells[writeoffIdx].Text);
                int idx = gridMain.ListGridRows[i].Cells[gridMain.ListGridColumns.GetIndex(Lan.g("TableClaimProc", "Pay Tracking"))].ComboSelectedIndex;
                ClaimProcsToEdit[i].ClaimPaymentTracking = idx == 0 ? 0 : _listClaimPaymentTrackingDefs[idx - 1].DefNum;
                ClaimProcsToEdit[i].Remarks = gridMain.ListGridRows[i].Cells[gridMain.ListGridColumns.GetIndex(Lan.g("TableClaimProc", "Remarks"))].Text;
            }
            return(true);
        }