Пример #1
0
 public JsonResult AddFabric()
 {
     string strCraft = Request["craft"];
     string strStyle = Request["style"];
     string strCount = Request["count"];
     string strID = Request["materialid"];
     int id = 0;
     int count = 0;
     int carftID = 0;
     int styleID = 0;
     int.TryParse(strCraft,out carftID);
     int.TryParse(strStyle,out styleID);
     int.TryParse(strCount, out count);
     int.TryParse(strID, out id);
     JsonResult json = new JsonResult();
     json.Data = new { flag = 0 };
     if (count > 0 && carftID > 0 && styleID > 0&&id>0)
     {
         DetailItem item = new DetailItem();
         item.Craft = carftID;
         item.Style=styleID;
         item.Type=CategoryType.Fabric;
         item.MaterialID=id;
         Material model = new Material();
         MaterialOperation mop = new MaterialOperation();
         model = mop.GetModel(id);
         Craft craftModel = new Craft();
         CraftOperation craftOperation = new CraftOperation();
         craftModel = craftOperation.GetModel(carftID);
         item.Count = count;
         if (model != null)
         {
             item.StylePrice = craftModel.Price;
             switch (styleID)
             {
                 case 1:
                     item.Price = model.Price ;
                     break;
                 case 2:
                     item.Price = model.PriceHigh;
                     break;
                 case 3:
                     item.Price = model.PriceFancy;
                     break;
             }
             if (item.Price > 0)
             {
                 MyCart.Add(item);
                 json.Data = new { flag = 1,count=MyCart.Orders.Count,total=MyCart.TotalPrice };
             }
         }
     }
     json.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
     json.ContentEncoding = System.Text.Encoding.UTF8;
     return json;
 }
Пример #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public TextileCity.Entity.Material DataRowToModel(DataRow row)
 {
     TextileCity.Entity.Material model = new TextileCity.Entity.Material();
     if (row != null)
     {
         foreach (DataColumn col in row.Table.Columns)
         {
             if (row[col] != null && row[col].ToString() != "")
             {
                 switch (col.ColumnName)
                 {
                     case "id":
                         model.MaterialID = int.Parse(row[col].ToString());
                         break;
                     case "category_id":
                         model.CategoryID = int.Parse(row[col].ToString());
                         break;
                     case "type":
                         model.CategoryType = row[col].ToString();
                         break;
                     case "name":
                         model.Name = row[col].ToString();
                         break;
                     case "price":
                         model.Price = decimal.Parse(row[col].ToString());
                         break;
                     case "price_high":
                         model.PriceHigh = decimal.Parse(row[col].ToString());
                         break;
                     case "price_fancy":
                         model.PriceFancy = decimal.Parse(row[col].ToString());
                         break;
                     case "styles":
                         model.StylesList = row[col].ToString();
                         break;
                     case "intro":
                         model.Intro = row[col].ToString();
                         break;
                     case "main_image":
                         model.MainImage = row[col].ToString();
                         break;
                     case "images":
                         model.Images = row[col].ToString();
                         break;
                 }
             }
         }
     }
     return model;
 }
Пример #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TextileCity.Entity.Material GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select id,category_id,type,name,price,price_high,price_fancy,styles,intro,main_image,images from material ");
            strSql.Append(" where id=?id");
            MySqlParameter[] parameters = {
                    new MySqlParameter("?id", MySqlDbType.Int32)
            };
            parameters[0].Value = id;

            TextileCity.Entity.Material model = new TextileCity.Entity.Material();
            DataSet ds = MysqlHelper.ExecuteDataSet(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
Пример #4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(Material model)
 {
     return dal.Add(model);
 }
Пример #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Material model)
 {
     return dal.Update(model);
 }