//
 // GET: /ProductConfigure/
 public int save(string id,string LoveCount=null,string Count=null)
 {
     ProductConfigure info = new ProductConfigure();
     ProductConfigureModel model = new ProductConfigureModel();
     int i; string type = "";
     List<ProductConfigure> list = model.SelProductConfigureById(id);
     if (list != null && list.Count > 0)
     {
         info = list.First();
         type = "Update";
     }
     else {
         type = "Insert";
     }
     info.ProductId = new Guid(id);
     if (!string.IsNullOrEmpty(LoveCount))
     {
         info.LoveCount = Convert.ToInt32(LoveCount);
     }
     if (!string.IsNullOrEmpty(Count))
     {
         info.Count = Convert.ToInt32(Count);
     }
     i = model.SaveProductConfigure(type, info);
     return i;
 }
Esempio n. 2
0
        public int SaveProductConfigure(string type, ProductConfigure info)
        {
            if (string.IsNullOrEmpty(type))
            {
                return 0;
            }

            if (info == null)
            {
                return 0;
            }
            string sql = "";

            DbCommand cmd = null;
            if (type.Equals("Insert"))
            {
                sql = "INSERT INTO ProductConfigure (ProductId,LoveCount,Count)"
                       + " VALUES(@ProductId,@LoveCount,@Count)";

            }
            if (type.Equals("Update"))
            {
                sql = "UPDATE ProductConfigure SET LoveCount=@LoveCount,Count=@Count WHERE ProductId=@ProductId";

            }
            try
            {
                cmd = db.GetSqlStringCommand(sql);
                db.AddInParameter(cmd, "ProductId", DbType.Guid, info.ProductId);
                db.AddInParameter(cmd, "LoveCount", DbType.Int32, info.LoveCount);
                db.AddInParameter(cmd, "Count", DbType.Int32, info.Count);
                return ExecSql(cmd);
            }
            catch (Exception)
            {
            }
            return 0;
        }