private decimal SoldQty(string txType, string type) { decimal result = 0, totalCAS = 0, totalVOD = 0; if (type == "M") { type = "AND YEAR(TxDate) = " + DateTime.Now.Year.ToString() + " AND MONTH(TxDate) = " + DateTime.Now.Month.ToString(); } else { type = "AND YEAR(TxDate) = " + DateTime.Now.Year.ToString(); } string sql = "ProductId = '" + this.ProductId.ToString() + "' AND TxType IN (" + txType + ")" + type; PosLedgerDetailsCollection oDetails = PosLedgerDetails.LoadCollection(sql); for (int i = 0; i < oDetails.Count; i++) { switch (oDetails[i].TxType) { case "CRT": case "VOD": totalVOD += oDetails[i].Qty; break; case "CAS": totalCAS += oDetails[i].Qty; break; } } result = totalCAS - totalVOD; return(result); }
/// <summary> /// Loads a collection of PosLedgerDetails objects from the database. /// </summary> /// <returns>A collection containing all of the PosLedgerDetails objects in the database.</returns> public static PosLedgerDetailsCollection LoadCollection(string spName, SqlParameter[] parms) { PosLedgerDetailsCollection result = new PosLedgerDetailsCollection(); using (SqlDataReader reader = SqlHelper.Default.ExecuteReader(spName, parms)) { while (reader.Read()) { PosLedgerDetails tmp = new PosLedgerDetails(); tmp.LoadFromReader(reader); result.Add(tmp); } } return(result); }