Пример #1
0
        public List <Last3WeekOrder> GetOrderAmt()
        {
            SqlCommand            cmd     = null;
            SqlDataReader         SDR     = null;
            List <Last3WeekOrder> ListTmp = new List <Last3WeekOrder>();
            Last3WeekOrder        ObjTmp  = null;
            DBCon Obj = new DBCon();

            GetOrder.Ondate = DateTime.Now;
            try
            {
                cmd             = new SqlCommand("OrderAmt", Obj.Con);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@FromDate", DateTime.Now.AddDays(-21).Date.ToString("MM/dd/yyyy"));
                cmd.Parameters.AddWithValue("@Todate", DateTime.Now.AddDays(-1).Date.ToString("MM/dd/yyyy"));
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    ObjTmp            = new Last3WeekOrder();
                    ObjTmp.OrgId      = SDR.GetInt32(0);
                    ObjTmp.OrderAmt   = SDR.GetDouble(1);
                    ObjTmp.NumOfOrder = SDR.GetInt32(2);
                    ListTmp.Add(ObjTmp);
                }
            }
            catch (Exception e) { e.ToString(); }
            finally { cmd.Dispose(); SDR.Close(); Obj.Con.Close(); Obj.Con.Dispose(); }
            return(ListTmp);
        }
Пример #2
0
 public static double GetTotalAmt(int Orgid)
 {
     if (Ondate == null || Ondate.Date < DateTime.Now.Date || List == null)
     {
         List = new Last3WeekOrder().GetOrderAmt();
     }
     try
     {
         var Obj = List.Find(x => x.OrgId == Orgid);
         return(Obj.OrderAmt / Obj.NumOfOrder);
     }
     catch (Exception)
     {
         return(0);
     }
 }