public CostFillingModel(TextBox tBox, SummingType type, DateTime from, DateTime by) { TBox = tBox; SumType = type; From = from; By = by; }
public static SqlCommand SumByDateQuery(SummingType type, DateTime from, DateTime by, SqlConnection connect) { string sqlFrom = from.ToString("yyyy-MM-dd"); string sqlBy = by.AddDays(1).ToString("yyyy-MM-dd"); //HH:mm:ss return(new SqlCommand(@"SELECT SUM(Cost) FROM Журнал WHERE Date >=" + sqlFrom.BeQuoted() + " AND Date < " + sqlBy.BeQuoted() + GenerateInfTypeQueryPart(type), connect)); }
static string GenerateInfTypeQueryPart(SummingType type) { if (type == SummingType.MapCases) { return(" AND MapCasesCount > 0"); } else if (type == SummingType.OtherInformation) { return(" AND MapCasesCount = 0"); } else { return(""); } }