public Int64 GetSOHPastMonth(int itemId, int storeId, int month, int year) { //ask by normal u get soh on normal month IssueDoc iss = new IssueDoc(); ReceiveDoc rec = new ReceiveDoc(); Disposal dis = new Disposal(); YearEnd yEnd = new YearEnd(); //int month = (mon > 2) ? mon - 2 : ((mon == 1) ? 11 : 12); //int year = (mon > 2) ? yr : yr - 1; Int64 cons = 0; cons = (rec.GetReceivedQuantityPastMonth(itemId, storeId, month, year) + dis.GetAdjustedQuantityPastMonth(itemId, storeId, month, year) - iss.GetIssuedQuantityPastMonth(itemId, storeId, month, year) - dis.GetLossesQuantityPastMonth(itemId, storeId, month, year)); this.FlushData(); // this.LoadFromRawSql(String.Format("SELECT SUM(QuantityLeft) AS Quantity FROM ReceiveDoc WHERE (ItemID = {0}) AND (StoreID = {1} AND ((Month(Date) <= {2} AND Year(Date) = {3}) OR (Month(Date) > 10 AND Year(Date) = {4})))", itemId, storeId, month, year, year - 1)); // cons = (this.DataTable.Rows[0]["Quantity"].ToString() != "") ? Convert.ToInt64(this.DataTable.Rows[0]["Quantity"]) : 0; return cons; }