示例#1
0
        public ActionResult Delete_UnitGoodsList(long id)
        {
            t_unit_goods model    = new t_unit_goods();
            var          vmResult = new CommonAjaxResponseModel <VMGDataGrid <t_unit_goods> >();

            vmResult.TData = new VMGDataGrid <t_unit_goods>();

            try
            {
                //删除
                int t1 = UnitDAL.Delete_UnitGoodsList(id);
                vmResult.BFlag           = CommonResponseBFlag.Success;
                vmResult.TData.data      = null;
                vmResult.TData.dataCount = 0;
                vmResult.Msg             = string.Format("删除该系列商品成功。");
                return(Json(vmResult));
            }
            catch (Exception ex)
            {
                vmResult.BFlag           = CommonResponseBFlag.LogicError;
                vmResult.TData.data      = null;
                vmResult.TData.dataCount = 0;
                vmResult.Msg             = "删除报错" + ex.Message;
            }

            return(Json(vmResult));
        }
示例#2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public t_unit_goods DataRowToModel(DataRow row)
        {
            t_unit_goods model = new t_unit_goods();

            if (row != null)
            {
                if (row["id"] != null && row["id"].ToString() != "")
                {
                    model.id = int.Parse(row["id"].ToString());
                }
                if (row["unit_id"] != null && row["unit_id"].ToString() != "")
                {
                    model.unit_id = int.Parse(row["unit_id"].ToString());
                }
                if (row["goods_id"] != null && row["goods_id"].ToString() != "")
                {
                    model.goods_id = int.Parse(row["goods_id"].ToString());
                }
                if (row["goods_name"] != null)
                {
                    model.goods_name = row["goods_name"].ToString();
                }
                if (row["goods_name_new"] != null)
                {
                    model.goods_name_new = row["goods_name_new"].ToString();
                }
                if (row["count"] != null && row["count"].ToString() != "")
                {
                    model.count = int.Parse(row["count"].ToString());
                }
                if (row["price"] != null && row["price"].ToString() != "")
                {
                    model.price = decimal.Parse(row["price"].ToString());
                }
                if (row["sell_min_price"] != null && row["sell_min_price"].ToString() != "")
                {
                    model.sell_min_price = decimal.Parse(row["sell_min_price"].ToString());
                }
                if (row["sell_max_price"] != null && row["sell_max_price"].ToString() != "")
                {
                    model.sell_max_price = decimal.Parse(row["sell_max_price"].ToString());
                }
                if (row["create_time"] != null && row["create_time"].ToString() != "")
                {
                    model.create_time = DateTime.Parse(row["create_time"].ToString());
                }
                if (row["update_time"] != null && row["update_time"].ToString() != "")
                {
                    model.update_time = DateTime.Parse(row["update_time"].ToString());
                }
                if (row["status_code"] != null && row["status_code"].ToString() != "")
                {
                    model.status_code = int.Parse(row["status_code"].ToString());
                }
            }
            return(model);
        }
示例#3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(t_unit_goods model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_unit_goods set ");
            strSql.Append("unit_id=@unit_id,");
            strSql.Append("goods_id=@goods_id,");
            strSql.Append("goods_name=@goods_name,");
            strSql.Append("goods_name_new=@goods_name_new,");
            strSql.Append("count=@count,");
            strSql.Append("price=@price,");
            strSql.Append("sell_min_price=@sell_min_price,");
            strSql.Append("sell_max_price=@sell_max_price,");
            strSql.Append("create_time=@create_time,");
            strSql.Append("update_time=@update_time,");
            strSql.Append("status_code=@status_code");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@unit_id",        MySqlDbType.Int32,      11),
                new MySqlParameter("@goods_id",       MySqlDbType.Int32,      11),
                new MySqlParameter("@goods_name",     MySqlDbType.VarChar,   255),
                new MySqlParameter("@goods_name_new", MySqlDbType.VarChar,   255),
                new MySqlParameter("@count",          MySqlDbType.Int32,      11),
                new MySqlParameter("@price",          MySqlDbType.Decimal,    10),
                new MySqlParameter("@sell_min_price", MySqlDbType.Decimal,    10),
                new MySqlParameter("@sell_max_price", MySqlDbType.Decimal,    10),
                new MySqlParameter("@create_time",    MySqlDbType.DateTime),
                new MySqlParameter("@update_time",    MySqlDbType.DateTime),
                new MySqlParameter("@status_code",    MySqlDbType.Int32,     255),
                new MySqlParameter("@id",             MySqlDbType.Int32, 11)
            };
            parameters[0].Value  = model.unit_id;
            parameters[1].Value  = model.goods_id;
            parameters[2].Value  = model.goods_name;
            parameters[3].Value  = model.goods_name_new;
            parameters[4].Value  = model.count;
            parameters[5].Value  = model.price;
            parameters[6].Value  = model.sell_min_price;
            parameters[7].Value  = model.sell_max_price;
            parameters[8].Value  = model.create_time;
            parameters[9].Value  = model.update_time;
            parameters[10].Value = model.status_code;
            parameters[11].Value = model.id;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(t_unit_goods model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_unit_goods(");
            strSql.Append("unit_id,goods_id,goods_name,goods_name_new,count,price,sell_min_price,sell_max_price,create_time,update_time,status_code)");
            strSql.Append(" values (");
            strSql.Append("@unit_id,@goods_id,@goods_name,@goods_name_new,@count,@price,@sell_min_price,@sell_max_price,@create_time,@update_time,@status_code)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@unit_id",        MySqlDbType.Int32,      11),
                new MySqlParameter("@goods_id",       MySqlDbType.Int32,      11),
                new MySqlParameter("@goods_name",     MySqlDbType.VarChar,   255),
                new MySqlParameter("@goods_name_new", MySqlDbType.VarChar,   255),
                new MySqlParameter("@count",          MySqlDbType.Int32,      11),
                new MySqlParameter("@price",          MySqlDbType.Decimal,    10),
                new MySqlParameter("@sell_min_price", MySqlDbType.Decimal,    10),
                new MySqlParameter("@sell_max_price", MySqlDbType.Decimal,    10),
                new MySqlParameter("@create_time",    MySqlDbType.DateTime),
                new MySqlParameter("@update_time",    MySqlDbType.DateTime),
                new MySqlParameter("@status_code",    MySqlDbType.Int32, 255)
            };
            parameters[0].Value  = model.unit_id;
            parameters[1].Value  = model.goods_id;
            parameters[2].Value  = model.goods_name;
            parameters[3].Value  = model.goods_name_new;
            parameters[4].Value  = model.count;
            parameters[5].Value  = model.price;
            parameters[6].Value  = model.sell_min_price;
            parameters[7].Value  = model.sell_max_price;
            parameters[8].Value  = model.create_time;
            parameters[9].Value  = model.update_time;
            parameters[10].Value = model.status_code;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#5
0
        public ActionResult AddUnitGoods(string formVals = "{}")
        {
            var vmResult = new CommonAjaxResponseModel <bool>();

            try
            {
                t_unit_goods model = formVals.ToModel <t_unit_goods>();

                if (!string.IsNullOrWhiteSpace(model.goods_name))
                {
                    model.goods_id   = int.Parse(model.goods_name.Split('(', ')')[1]);
                    model.goods_name = model.goods_name.Split('(', ')')[0];
                }
                else
                {
                    vmResult.BFlag = CommonResponseBFlag.SysError;
                    vmResult.Msg   = "商品id解析出错";

                    return(Json(vmResult));
                }


                if (model.id != 0)
                {
                    UnitDAL.UpdateUnitGoods(model);

                    vmResult.BFlag = CommonResponseBFlag.Success;
                    vmResult.TData = true;
                }
                else
                {
                    //插入
                    UnitDAL.AddUnitGoods(model);
                    vmResult.BFlag = CommonResponseBFlag.Success;
                    vmResult.TData = true;
                }
            }
            catch (Exception ex)
            {
                vmResult.BFlag = CommonResponseBFlag.SysError;
                vmResult.Msg   = ex.Message;
            }
            return(Json(vmResult));
        }
示例#6
0
        public static int UpdateUnitGoods(t_unit_goods model)
        {
            string sql = @"
UPDATE `t_unit_goods` SET  `goods_id`=@goods_id,`goods_name`=@goods_name, `goods_name_new`=@goods_name_new, `count`=@count, `price`=@price, `sell_min_price`=@sell_min_price, `sell_max_price`=@sell_max_price, `update_time`=now()  WHERE `id`=@id;";

            using (MySqlConnection sql_conn = new MySqlConnection(mysqlCon))
            {
                sql_conn.Open();
                MySqlCommand cmd = new MySqlCommand(sql, sql_conn);
                cmd.Parameters.AddWithValue("@goods_id", model.goods_id);
                cmd.Parameters.AddWithValue("@goods_name", model.goods_name);
                cmd.Parameters.AddWithValue("@goods_name_new", model.goods_name_new);
                cmd.Parameters.AddWithValue("@count", model.count);
                cmd.Parameters.AddWithValue("@price", model.price);
                cmd.Parameters.AddWithValue("@sell_min_price", model.sell_min_price);
                cmd.Parameters.AddWithValue("@sell_max_price", model.sell_max_price);
                cmd.Parameters.AddWithValue("@id", model.id);
                MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
                int p = cmd.ExecuteNonQuery();
                return(p);
            }
        }
示例#7
0
        public static int AddUnitGoods(t_unit_goods model)
        {
            string sql = @"
INSERT INTO `t_unit_goods` (`unit_id`, `goods_id`,`goods_name`, `goods_name_new`, `count`, `price`, `sell_min_price`, `sell_max_price`, `create_time`,`status_code`) 
 select @unit_id, @goods_id,@goods_name,@goods_name_new, @count, @price, @sell_min_price, @sell_max_price, now(), 1;";

            using (MySqlConnection sql_conn = new MySqlConnection(mysqlCon))
            {
                sql_conn.Open();
                MySqlCommand cmd = new MySqlCommand(sql, sql_conn);
                cmd.Parameters.AddWithValue("@unit_id", model.unit_id);
                cmd.Parameters.AddWithValue("@goods_id", model.goods_id);
                cmd.Parameters.AddWithValue("@goods_name", model.goods_name);
                cmd.Parameters.AddWithValue("@goods_name_new", model.goods_name_new);
                cmd.Parameters.AddWithValue("@count", model.count);
                cmd.Parameters.AddWithValue("@price", model.price);
                cmd.Parameters.AddWithValue("@sell_min_price", model.sell_min_price);
                cmd.Parameters.AddWithValue("@sell_max_price", model.sell_max_price);
                MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
                int p = cmd.ExecuteNonQuery();
                return(p);
            }
        }
示例#8
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public t_unit_goods GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,unit_id,goods_id,goods_name,goods_name_new,count,price,sell_min_price,sell_max_price,create_time,update_time,status_code from t_unit_goods ");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int32)
            };
            parameters[0].Value = id;

            t_unit_goods model = new t_unit_goods();
            DataSet      ds    = DbHelperMySQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
示例#9
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(t_unit_goods model)
 {
     return(dal.Update(model));
 }
示例#10
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(t_unit_goods model)
 {
     return(dal.Add(model));
 }