Пример #1
0
 public static void update(CompanyWeekEntity companyWeek)
 {
     DbHelper.ExecuteNonQuery("p_CompanyWeek_update",
       companyWeek.CsId,
       companyWeek.Products
        );
 }
Пример #2
0
 public static void insert(CompanyWeekEntity companyWeek)
 {
     DbHelper.ExecuteNonQuery("p_CompanyWeek_insert",
       companyWeek.CompanyId,
       companyWeek.Weekday,
       companyWeek.Products,
       companyWeek.CustomerId
        );
 }
Пример #3
0
 public static CompanyWeekEntity getByWeek(int weekday,int companyId)
 {
     DataRow dr = DbHelper.ExecuteDataRow("p_CompanyWeek_getByWeek", weekday, companyId);
     CompanyWeekEntity companyWeek = new CompanyWeekEntity();
     if (dr != null)
     {
         companyWeek.CsId = Convert.ToInt32(dr["csId"]);
         companyWeek.CompanyId = companyId;
         companyWeek.Weekday = weekday;
         companyWeek.Products = dr["products"].ToString();
         companyWeek.CustomerId = Convert.ToInt32(dr["customerId"]);
         if (dr["updateDt"]==DBNull.Value)
             companyWeek.UpdateDt = Convert.ToDateTime(dr["updateDt"]);
     }
     return companyWeek;
 }
        void delProducts(int productId)
        {
            CompanyWeekEntity cw = new CompanyWeekEntity();
            int companyId = logic.customer.getCompanyId();
            cw = logic.companyWeek.getByWeek(week, companyId);
            if (cw.CsId != 0)
            {
                string cw_pros = "";
                string[] splitstr = { "," };
                string[] pros = cw.Products.Split(splitstr, StringSplitOptions.RemoveEmptyEntries);

                for (int i = 0; i < pros.Length; i++)
                {
                    if (pros[i] != productId.ToString())
                    {
                        cw_pros += pros[i] + ",";
                    }
                }
                cw.Products = cw_pros;
                logic.companyWeek.update(cw);
            }
        }
        void addProduct(int productId)
        {
            CompanyWeekEntity cw = new CompanyWeekEntity();
            int companyId = logic.customer.getCompanyId();
            cw = logic.companyWeek.getByWeek(week, companyId);
            if (cw.CsId != 0)
            {
                string cw_pros = cw.Products;
                string[] splitstr = { "," };
                string[] pros = cw_pros.Split(splitstr, StringSplitOptions.RemoveEmptyEntries);
                //bool hasProduct=false;

                bool hasProduct = pros.Contains<string>(productId.ToString());

                //for (int i = 0; i < pros.Length; i++)
                //{
                //    if (pros[i] == productId.ToString())
                //    {
                //        hasProduct = true;
                //        break;
                //    }
                //}
                if (!hasProduct)
                {
                    cw.Products = productId.ToString() + "," + cw_pros;
                    logic.companyWeek.update(cw);
                }

            }
            else
            {
                cw.CustomerId = logic.customer.userId;
                cw.CompanyId = companyId;
                cw.Weekday = week;
                cw.Products = productId.ToString() + ",";
                logic.companyWeek.insert(cw);

            }
        }
Пример #6
0
 public static void update(CompanyWeekEntity cw)
 {
     CompanyWeek.update(cw);
 }
Пример #7
0
 public static void insert(CompanyWeekEntity cw)
 {
     CompanyWeek.insert(cw);
 }