/// <summary> /// /// </summary> /// <param name="inCN"></param> private void UpdateCSFlag(OdbcConnection inCN) { Console.WriteLine("Updating any PCS actions with the SendToCS Flag, and clearing the Pend Date."); foreach (DataRow dr in dt_AllActions.Rows) { // take the data and make sure the CS flag is set to yes, as they ran an action and it should be (they're not worked the same day as they don't populate the same day) string[] newWindowData = new string[16]; string[] previousData = AMC_Functions.GeneralFunctions.SplitAdata(dr["ADATA:A5"].ToString()); // assign the fields, all previous fields except for the pend date (if there is one), and the flag being yes newWindowData[0] = previousData[0]; newWindowData[1] = previousData[1]; newWindowData[2] = previousData[2]; newWindowData[3] = previousData[3]; newWindowData[4] = previousData[4]; newWindowData[5] = previousData[5]; newWindowData[6] = previousData[6]; newWindowData[7] = previousData[7]; newWindowData[8] = previousData[8]; newWindowData[9] = previousData[9]; newWindowData[10] = previousData[10]; newWindowData[11] = previousData[11]; newWindowData[12] = previousData[12]; newWindowData[13] = string.Empty; // pend date newWindowData[14] = previousData[14]; newWindowData[15] = "yes"; // CS flag // update all the datas AMC_Functions.UpdateBHWindows BHUpdate = new AMC_Functions.UpdateBHWindows(dr["amanumber"].ToString(), "AW", "5", inCN, newWindowData, CommonVariables.ProcessID); } }
/// <summary> /// Check the data that came from the query and see which ones already match, and which can be updated/need to be manually evaluated /// </summary> private void EvaluateData(OdbcConnection inCN, bool inTestMode) { foreach (DataRow dr in dt_allData.Rows) { // make variables for each, just in case they aren't parseable can treat them as zeros decimal CurrentBalance = dr["ambalance"].ToString().Trim() == string.Empty ? 0 : Convert.ToDecimal(dr["ambalance"].ToString().Trim().Replace("$", "")); decimal TotalCharges = dr["TotalCharges"].ToString().Trim() == string.Empty ? 0 : Convert.ToDecimal(dr["TotalCharges"].ToString().Trim().Replace("$", "")); decimal TotalPatPayments = dr["TotalPat"].ToString().Trim() == string.Empty ? 0 : Convert.ToDecimal(dr["TotalPat"].ToString().Trim().Replace("$", "")); decimal TotalInsPayments = dr["TotalIns"].ToString().Trim() == string.Empty ? 0 : Convert.ToDecimal(dr["TotalIns"].ToString().Trim().Replace("$", "")); decimal TotalAdjustments = dr["TotalAdjust"].ToString().Trim() == string.Empty ? 0 : Convert.ToDecimal(dr["TotalAdjust"].ToString().Trim().Replace("$", "")); decimal TotalAdjInPeriod = dr["TotalAdjusts"].ToString().Trim() == string.Empty ? 0 : Convert.ToDecimal(dr["TotalAdjusts"].ToString().Trim().Replace("$", "")); decimal TotalInsPayInPeriod = dr["TotalInsPayments"].ToString().Trim() == string.Empty ? 0 : Convert.ToDecimal(dr["TotalInsPayments"].ToString().Trim().Replace("$", "")); decimal TotalPatPayInPeriod = dr["TotalPayments"].ToString().Trim() == string.Empty ? 0 : Convert.ToDecimal(dr["TotalPayments"].ToString().Trim().Replace("$", "")); // check if they already match, if so, then we can ignore it if (Math.Round(CurrentBalance, 2) != Math.Round((TotalCharges - TotalPatPayments - TotalInsPayments - TotalAdjustments), 2)) { // check if adding the totals for the last time frame added together end up making them match if (Math.Round(CurrentBalance, 2) == Math.Round(((TotalCharges - TotalPatPayments - TotalInsPayments - TotalAdjustments) + TotalAdjInPeriod + TotalInsPayInPeriod + TotalPatPayInPeriod), 2)) { // update the data, need to make an array of the new data string[] newWindowData = new string[16]; newWindowData[0] = dr["ADATA:AA1"].ToString(); newWindowData[1] = dr["ADATA:AA2"].ToString(); newWindowData[2] = dr["ADATA:AA3"].ToString(); newWindowData[3] = Decimal.Add(TotalAdjustments, (TotalAdjInPeriod * -1)).ToString(); newWindowData[4] = Decimal.Add(TotalInsPayments, (TotalInsPayInPeriod * -1)).ToString(); newWindowData[5] = Decimal.Add(TotalPatPayments, (TotalPatPayInPeriod * -1)).ToString(); newWindowData[6] = dr["ADATA:AA7"].ToString(); newWindowData[7] = dr["ADATA:AA8"].ToString(); newWindowData[8] = dr["ADATA:AA9"].ToString(); newWindowData[9] = dr["ADATA:AA10"].ToString(); newWindowData[10] = dr["ADATA:AA11"].ToString(); newWindowData[11] = dr["ADATA:AA12"].ToString(); newWindowData[12] = dr["ADATA:AA13"].ToString(); newWindowData[13] = dr["ADATA:AA14"].ToString(); newWindowData[14] = dr["ADATA:AA15"].ToString(); newWindowData[15] = dr["ADATA:AA16"].ToString(); if (inTestMode) { string newADATA_AA4 = Decimal.Add(TotalAdjustments, (TotalAdjInPeriod * -1)).ToString(); string newADATA_AA5 = Decimal.Add(TotalInsPayments, (TotalInsPayInPeriod * -1)).ToString(); string newADATA_AA6 = Decimal.Add(TotalPatPayments, (TotalPatPayInPeriod * -1)).ToString(); // test mode, so want to export to a table instead so can monitor the details dt_UpdateData.Rows.Add(dr["amanumber"].ToString(), dr["ambalance"].ToString(), dr["amcnumber"].ToString(), dr["TotalCharges"].ToString().Trim(), dr["TotalAdjust"].ToString().Trim(), dr["TotalIns"].ToString().Trim(), dr["TotalPat"].ToString().Trim(), TotalPatPayInPeriod, TotalInsPayInPeriod, TotalAdjInPeriod, dr["ADATA:AA1"].ToString(), dr["ADATA:AA2"].ToString(), dr["ADATA:AA3"].ToString(), newADATA_AA4, newADATA_AA5, newADATA_AA6, dr["ADATA:AA7"].ToString(), dr["ADATA:AA8"].ToString(), dr["ADATA:AA9"].ToString(), dr["ADATA:AA10"].ToString(), dr["ADATA:AA11"].ToString(), dr["ADATA:AA12"].ToString(), dr["ADATA:AA13"].ToString(), dr["ADATA:AA14"].ToString(), dr["ADATA:AA15"].ToString(), dr["ADATA:AA16"].ToString()); } else { AMC_Functions.UpdateBHWindows oBHUpdate = new AMC_Functions.UpdateBHWindows(dr["amanumber"].ToString(), "AW", "A", inCN, newWindowData, ChangePerson); } } else { // export to manual, since it needs to be reviewed dt_ExportData.Rows.Add(dr["amanumber"].ToString(), dr["ambalance"].ToString(), dr["amcnumber"].ToString(), dr["TotalCharges"].ToString(), dr["TotalAdjust"].ToString(), dr["TotalPat"].ToString(), dr["TotalIns"].ToString(), Math.Round((TotalCharges - TotalPatPayments - TotalInsPayments - TotalAdjustments), 2)); } } // no else, don't need anything if they do match } }