public static List <PurchaseSummary> PurchaseDetails(string AgentCode, string CustomerNo, string ItemNo, string Year, string Month)
        {
            string strSQL = string.Empty;
            List <PurchaseSummary> list = new List <PurchaseSummary>();
            SqlDataReader          reader;

            strSQL = "SP_WA_PurchaseSummary_Details";
            Database        db        = DatabaseFactory.CreateDatabase();
            DbCommand       dbCommand = db.GetStoredProcCommand(strSQL);
            PurchaseSummary obj       = null;

            try
            {
                db.AddInParameter(dbCommand, "@AgentCode", DbType.String, AgentCode);
                db.AddInParameter(dbCommand, "@CustomerNo", DbType.String, CustomerNo);
                db.AddInParameter(dbCommand, "@ItemNo", DbType.String, ItemNo);
                db.AddInParameter(dbCommand, "@Year", DbType.String, Year);
                db.AddInParameter(dbCommand, "@Month", DbType.String, Month);

                reader = (SqlDataReader)db.ExecuteReader(dbCommand);
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        obj             = new PurchaseSummary();
                        obj.Month_Year  = Convert.ToString(reader.GetValue(reader.GetOrdinal("MonthYear")));
                        obj.Qty         = System.Math.Round(Convert.ToDecimal((reader.GetValue(reader.GetOrdinal("Quantity")))));
                        obj.Month       = Convert.ToString(reader.GetValue(reader.GetOrdinal("Month")));
                        obj.DocumentNo  = Convert.ToString(reader.GetValue(reader.GetOrdinal("ShipmentNo")));
                        obj.PostingDate = Convert.ToDateTime(reader.GetValue(reader.GetOrdinal("PostingDate")));
                        obj.Description = Convert.ToString(reader.GetValue(reader.GetOrdinal("Description")));
                        obj.Year        = Convert.ToString(reader.GetValue(reader.GetOrdinal("Year")));
                        list.Add(obj);
                    }
                }
                if (!reader.IsClosed)
                {
                    reader.Close();
                }
            }
            catch (SqlException e)
            { throw e; }
            catch (Exception e)
            { throw e; }
            finally
            {
                dbCommand.Dispose();
                dbCommand = null;
                db        = null;
            }
            return(list);
        }
        public static List <PurchaseSummary> YearWise(string AgentCode, string Customer, string ItemNo)
        {
            string strSQL = string.Empty;
            List <PurchaseSummary> list = new List <PurchaseSummary>();
            SqlDataReader          reader;

            strSQL = "SP_WA_PurchaseSummary_YearWise";
            Database        db        = DatabaseFactory.CreateDatabase();
            DbCommand       dbCommand = db.GetStoredProcCommand(strSQL);
            PurchaseSummary obj       = null;

            try
            {
                db.AddInParameter(dbCommand, "@AgentCode", DbType.String, AgentCode);
                db.AddInParameter(dbCommand, "@CustomerNo", DbType.String, Customer);
                db.AddInParameter(dbCommand, "@ItemNo", DbType.String, ItemNo);

                reader = (SqlDataReader)db.ExecuteReader(dbCommand);
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        obj      = new PurchaseSummary();
                        obj.Year = Convert.ToString(reader.GetValue(reader.GetOrdinal("YEAR")));
                        obj.Qty  = System.Math.Round(Convert.ToDecimal((reader.GetValue(reader.GetOrdinal("Quantity")))));

                        list.Add(obj);
                    }
                }
                if (!reader.IsClosed)
                {
                    reader.Close();
                }
            }
            catch (SqlException e)
            { throw e; }
            catch (Exception e)
            { throw e; }
            finally
            {
                dbCommand.Dispose();
                dbCommand = null;
                db        = null;
            }
            return(list);
        }