///<summary>CurrentValues must be set first. Then, this applies the values to the parameter to create the outputValue. The currentValues is usually just a single value. The only time there will be multiple values is for an Enum or QueryText. For example, if a user selects multiple items from a listbox for this parameter, then each item is connected by an OR. The entire OutputValue is surrounded by parentheses.</summary> public void FillOutputValue() { outputValue = "("; if (currentValues.Count == 0) //if there are no values { outputValue += "1"; //display a 1 (true) to effectively exclude this snippet } for (int i = 0; i < currentValues.Count; i++) { if (i > 0) { outputValue += " OR "; } if (valueType == ParamValueType.Boolean) { if ((bool)currentValues[i]) { outputValue += snippet; //snippet will show. There is no ? substitution } else { outputValue += "1"; //instead of the snippet, a 1 will show } } else if (valueType == ParamValueType.Date) { outputValue += Regex.Replace(snippet, @"\?", POut.PDate((DateTime)currentValues[i], false)); } else if (valueType == ParamValueType.Enum) { outputValue += Regex.Replace(snippet, @"\?", POut.PInt((int)currentValues[i])); } else if (valueType == ParamValueType.Integer) { outputValue += Regex.Replace(snippet, @"\?", POut.PInt((int)currentValues[i])); } else if (valueType == ParamValueType.String) { outputValue += Regex.Replace(snippet, @"\?", POut.PString((string)currentValues[i])); } else if (valueType == ParamValueType.Number) { outputValue += Regex.Replace(snippet, @"\?", POut.PDouble((double)currentValues[i])); } else if (valueType == ParamValueType.QueryData) { outputValue += Regex.Replace(snippet, @"\?", POut.PString((string)currentValues[i])); } } outputValue += ")"; //MessageBox.Show(outputValue); }
public static float NetIncome(object asOfDateObj) { DateTime asOfDate; if (asOfDateObj.GetType() == typeof(string)) { asOfDate = PIn.PDate(asOfDateObj.ToString()); } else if (asOfDateObj.GetType() == typeof(DateTime)) { asOfDate = (DateTime)asOfDateObj; } else { return(0); } DateTime firstOfYear = new DateTime(asOfDate.Year, 1, 1); string command = "SELECT SUM(CreditAmt), SUM(DebitAmt), AcctType " + "FROM journalentry,account " + "WHERE journalentry.AccountNum=account.AccountNum " + "AND DateDisplayed >= " + POut.PDate(firstOfYear) + " AND DateDisplayed <= " + POut.PDate(asOfDate) + " GROUP BY AcctType"; DataConnection dcon = new DataConnection(); DataTable table = dcon.GetTable(command); float retVal = 0; for (int i = 0; i < table.Rows.Count; i++) { if (table.Rows[i][2].ToString() == "3" || //income table.Rows[i][2].ToString() == "4") //expense { retVal += PIn.PFloat(table.Rows[i][0].ToString()); //add credit retVal -= PIn.PFloat(table.Rows[i][1].ToString()); //subtract debit //if it's an expense, we are subtracting (income-expense), but the signs cancel. } } return(retVal); }