예제 #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Style model)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("insert into style(");
            strSql.Append("material_id,name,price,code,rgb,scheme)");
            strSql.Append(" values (");
            strSql.Append("?material_id,?name,?price,?code,?rgb,?scheme)");
            MySqlParameter[] parameters = {
                    new MySqlParameter("?material_id", MySqlDbType.Int32,10),
                    new MySqlParameter("?name", MySqlDbType.VarChar,50),
                    new MySqlParameter("?price", MySqlDbType.Decimal,12),
                    new MySqlParameter("?code", MySqlDbType.VarChar,50),
                    new MySqlParameter("?rgb", MySqlDbType.VarChar,50),
                    new MySqlParameter("?scheme", MySqlDbType.Enum)};
            parameters[0].Value = model.MaterialID;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.Price;
            parameters[3].Value = model.Code;
            parameters[4].Value = model.RGB;
            parameters[5].Value = model.Scheme;

            int rows=MysqlHelper.ExecuteNonQuery(strSql.ToString(),parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
예제 #2
0
 public JsonResult AddAccessory()
 {
     string strStyle = Request["mstyle"];
     string strCount = Request["count"];
     string strID = Request["materialid"];
     int id = 0;
     int count = 0;
     int carftID = 0;
     int styleID = 0;
     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  && styleID > 0 && id > 0)
     {
         DetailItem item = new DetailItem();
         item.Craft = carftID;
         item.Style = styleID;
         item.Type = CategoryType.Accessory;
         item.MaterialID = id;
         item.Count = count;
         Style model = new Style();
         StyleOperation sop = new StyleOperation();
         model = sop.GetModel(styleID);
         if (model != null)
         {
             item.StylePrice = model.Price;
             if (item.StylePrice > 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;
 }
예제 #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Style DataRowToModel(DataRow row)
 {
     Style model=new Style();
     if (row != null)
     {
         foreach (DataColumn col in row.Table.Columns)
         {
             if (row[col] != null && row[col].ToString() != "")
             {
                 switch (col.ColumnName)
                 {
                     case "styleid":
                         model.StyleID = int.Parse(row[col].ToString());
                         break;
                     case "material_id":
                         model.MaterialID = int.Parse(row[col].ToString());
                         break;
                     case "name":
                         model.Name = row[col].ToString();
                         break;
                     case "price":
                         model.Price = decimal.Parse(row[col].ToString());
                         break;
                     case "code":
                         model.Code = row[col].ToString();
                         break;
                     case "rgb":
                         model.RGB = row[col].ToString();
                         break;
                     case "scheme":
                         model.Scheme = row[col].ToString();
                         break;
                 }
             }
         }
     }
     return model;
 }
예제 #4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(Style model)
 {
     return dal.Add(model);
 }
예제 #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Style model)
 {
     return dal.Update(model);
 }
예제 #6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Style model)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("update style set ");
            strSql.Append("material_id=?material_id,");
            strSql.Append("name=?name,");
            strSql.Append("price=?price,");
            strSql.Append("code=?code,");
            strSql.Append("rgb=?rgb,");
            strSql.Append("scheme=?scheme");
            strSql.Append(" where styleid=?styleid");
            MySqlParameter[] parameters = {
                    new MySqlParameter("?material_id", MySqlDbType.Int32,10),
                    new MySqlParameter("?name", MySqlDbType.VarChar,50),
                    new MySqlParameter("?price", MySqlDbType.Decimal,12),
                    new MySqlParameter("?code", MySqlDbType.VarChar,50),
                    new MySqlParameter("?rgb", MySqlDbType.VarChar,50),
                    new MySqlParameter("?scheme", MySqlDbType.Enum),
                    new MySqlParameter("?styleid", MySqlDbType.Int32,10)};
            parameters[0].Value = model.MaterialID;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.Price;
            parameters[3].Value = model.Code;
            parameters[4].Value = model.RGB;
            parameters[5].Value = model.Scheme;
            parameters[6].Value = model.StyleID;

            int rows=MysqlHelper.ExecuteNonQuery(strSql.ToString(),parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
예제 #7
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Style GetModel(int styleid)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select styleid,material_id,name,price,`code`,rgb,scheme from style ");
     strSql.AppendFormat(" where styleid={0} ",styleid);
     Style model = new Style();
     DataSet ds = MysqlHelper.ExecuteDataSet(strSql.ToString());
     if (ds.Tables[0].Rows.Count > 0)
     {
         return DataRowToModel(ds.Tables[0].Rows[0]);
     }
     else
     {
         return null;
     }
 }