Ejemplo n.º 1
0
 /// <summary>
 /// 更新数据
 /// 作者:章建国
 /// </summary>
 /// <param name="model">需要更新的模型</param>
 /// <returns></returns>
 private string UpdateEasyConsumeOUT(tb_EasyConsumeOUT model, string flag)
 {
     try
     {
         if (model != null && model.id > 0)
         {
             model.updateDate = DateTime.Now;
             model.updateUser = CurrentUserInfo.PersonnelID;
             var tempinmodel = _easyconsumeoutbll.GetModel(model.id);
             var devicemodel = _easyconsumebll.GetModel(model.eId.Value);
             if (_easyconsumeoutbll.Update(model))
             {
                 if (model.amount > tempinmodel.amount)
                 {
                     devicemodel.amount -= model.amount - tempinmodel.amount;
                 }
                 else if (model.amount < tempinmodel.amount)
                 {
                     devicemodel.amount += tempinmodel.amount - model.amount;
                 }
                 if (_easyconsumebll.Update(devicemodel))
                 {
                     flag = "1";
                 }
             }
         }
     }
     catch
     {
         flag = "0";
     }
     return(flag);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(tb_EasyConsumeOUT model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_EasyConsumeOUT(");
            strSql.Append("eId,OutDate,price,amount,inMoney,product,user1,remark,createUser,createDate,updateUser,updateDate,temp1,temp2,productDate,validDate,manufacturers,recipients)");
            strSql.Append(" values (");
            strSql.Append("@eId,@OutDate,@price,@amount,@inMoney,@product,@user1,@remark,@createUser,@createDate,@updateUser,@updateDate,@temp1,@temp2,@productDate,@validDate,@manufacturers,@recipients)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@eId",           SqlDbType.Int,         4),
                new SqlParameter("@OutDate",       SqlDbType.DateTime),
                new SqlParameter("@price",         SqlDbType.Decimal,     9),
                new SqlParameter("@amount",        SqlDbType.Int,         4),
                new SqlParameter("@inMoney",       SqlDbType.Decimal,     9),
                new SqlParameter("@product",       SqlDbType.NVarChar,   -1),
                new SqlParameter("@user1",         SqlDbType.Int,         4),
                new SqlParameter("@remark",        SqlDbType.NVarChar,   -1),
                new SqlParameter("@createUser",    SqlDbType.Int,         4),
                new SqlParameter("@createDate",    SqlDbType.DateTime),
                new SqlParameter("@updateUser",    SqlDbType.Int,         4),
                new SqlParameter("@updateDate",    SqlDbType.DateTime),
                new SqlParameter("@temp1",         SqlDbType.NVarChar,   -1),
                new SqlParameter("@temp2",         SqlDbType.NVarChar,   -1),
                new SqlParameter("@productDate",   SqlDbType.DateTime),
                new SqlParameter("@validDate",     SqlDbType.DateTime),
                new SqlParameter("@manufacturers", SqlDbType.NVarChar,  500),
                new SqlParameter("@recipients",    SqlDbType.NVarChar, -1)
            };
            parameters[0].Value  = model.eId;
            parameters[1].Value  = model.OutDate;
            parameters[2].Value  = model.price;
            parameters[3].Value  = model.amount;
            parameters[4].Value  = model.inMoney;
            parameters[5].Value  = model.product;
            parameters[6].Value  = model.user1;
            parameters[7].Value  = model.remark;
            parameters[8].Value  = model.createUser;
            parameters[9].Value  = model.createDate;
            parameters[10].Value = model.updateUser;
            parameters[11].Value = model.updateDate;
            parameters[12].Value = model.temp1;
            parameters[13].Value = model.temp2;
            parameters[14].Value = model.productDate;
            parameters[15].Value = model.validDate;
            parameters[16].Value = model.manufacturers;
            parameters[17].Value = model.recipients;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 新建数据
        /// 作者:章建国
        /// </summary>
        /// <param name="model"></param>
        /// <param name="flag"></param>
        /// <returns></returns>
        private string NewEasyConsumeOUT(tb_EasyConsumeOUT model, string flag)
        {
            model.createDate = DateTime.Now;
            model.createUser = CurrentUserInfo.PersonnelID;
            model.updateDate = DateTime.Now;
            model.updateUser = CurrentUserInfo.PersonnelID;
            model.temp1      = "待审批";//待审批、通过、未通过
            var _easyconsumeinmodel = _easyconsumeinbll.GetModel(Convert.ToInt32(model.temp2));
            var devicemodel         = _easyconsumebll.GetModel(model.eId.Value);

            if (_easyconsumeoutbll.Add(model) > 0)
            {
                if (_easyconsumeinmodel != null)
                {
                    _easyconsumeinmodel.temp2 = (Convert.ToInt32(_easyconsumeinmodel.temp2) - model.amount).ToString();
                    _easyconsumeinbll.Update(_easyconsumeinmodel);
                }

                devicemodel.amount = devicemodel.amount - model.amount;
                if (_easyconsumebll.Update(devicemodel))
                {
                    flag = "1";
                }
            }
            return(flag);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 新建数据或更新数据
        /// 作者:章建国
        /// </summary>
        /// <param name="model">新输入的数据</param>
        /// <returns></returns>
        public string EasyConsumeOUTCU(tb_EasyConsumeOUT model)
        {
            string flag = "0";

            try
            {
                if (model.id > 0)
                {
                    flag = UpdateEasyConsumeOUT(model, flag);
                }
                else
                {
                    flag = NewEasyConsumeOUT(model, flag);
                }
            }
            catch
            {
                flag = "0";
            }
            return(flag);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public tb_EasyConsumeOUT GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 * from tb_EasyConsumeOUT ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            tb_EasyConsumeOUT model = new tb_EasyConsumeOUT();
            DataSet           ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(tb_EasyConsumeOUT model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(tb_EasyConsumeOUT model)
 {
     return(dal.Add(model));
 }
Ejemplo n.º 8
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public tb_EasyConsumeOUT DataRowToModel(DataRow row)
        {
            tb_EasyConsumeOUT model = new tb_EasyConsumeOUT();

            if (row != null)
            {
                if (row["id"] != null && row["id"].ToString() != "")
                {
                    model.id = int.Parse(row["id"].ToString());
                }
                if (row["eId"] != null && row["eId"].ToString() != "")
                {
                    model.eId = int.Parse(row["eId"].ToString());
                }
                if (row["OutDate"] != null && row["OutDate"].ToString() != "")
                {
                    model.OutDate = DateTime.Parse(row["OutDate"].ToString());
                }
                if (row["price"] != null && row["price"].ToString() != "")
                {
                    model.price = decimal.Parse(row["price"].ToString());
                }
                if (row["amount"] != null && row["amount"].ToString() != "")
                {
                    model.amount = int.Parse(row["amount"].ToString());
                }
                if (row["inMoney"] != null && row["inMoney"].ToString() != "")
                {
                    model.inMoney = decimal.Parse(row["inMoney"].ToString());
                }
                if (row["product"] != null)
                {
                    model.product = row["product"].ToString();
                }
                if (row["user1"] != null && row["user1"].ToString() != "")
                {
                    model.user1 = int.Parse(row["user1"].ToString());
                }
                if (row["remark"] != null)
                {
                    model.remark = row["remark"].ToString();
                }
                if (row["createUser"] != null && row["createUser"].ToString() != "")
                {
                    model.createUser = int.Parse(row["createUser"].ToString());
                }
                if (row["createDate"] != null && row["createDate"].ToString() != "")
                {
                    model.createDate = DateTime.Parse(row["createDate"].ToString());
                }
                if (row["updateUser"] != null && row["updateUser"].ToString() != "")
                {
                    model.updateUser = int.Parse(row["updateUser"].ToString());
                }
                if (row["updateDate"] != null && row["updateDate"].ToString() != "")
                {
                    model.updateDate = DateTime.Parse(row["updateDate"].ToString());
                }
                if (row["temp1"] != null)
                {
                    model.temp1 = row["temp1"].ToString();
                }
                if (row["temp2"] != null)
                {
                    model.temp2 = row["temp2"].ToString();
                }
                if (row["productDate"] != null && row["productDate"].ToString() != "")
                {
                    model.productDate = DateTime.Parse(row["productDate"].ToString());
                }
                if (row["validDate"] != null && row["validDate"].ToString() != "")
                {
                    model.validDate = DateTime.Parse(row["validDate"].ToString());
                }
                if (row["manufacturers"] != null)
                {
                    model.manufacturers = row["manufacturers"].ToString();
                }
                if (row["recipients"] != null)
                {
                    model.recipients = row["recipients"].ToString();
                }
            }
            return(model);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(tb_EasyConsumeOUT model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_EasyConsumeOUT set ");
            strSql.Append("eId=@eId,");
            strSql.Append("OutDate=@OutDate,");
            strSql.Append("price=@price,");
            strSql.Append("amount=@amount,");
            strSql.Append("inMoney=@inMoney,");
            strSql.Append("product=@product,");
            strSql.Append("user1=@user1,");
            strSql.Append("remark=@remark,");
            strSql.Append("createUser=@createUser,");
            strSql.Append("createDate=@createDate,");
            strSql.Append("updateUser=@updateUser,");
            strSql.Append("updateDate=@updateDate,");
            strSql.Append("temp1=@temp1,");
            strSql.Append("temp2=@temp2,");
            strSql.Append("productDate=@productDate,");
            strSql.Append("validDate=@validDate,");
            strSql.Append("manufacturers=@manufacturers,");
            strSql.Append("recipients=@recipients");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@eId",           SqlDbType.Int,         4),
                new SqlParameter("@OutDate",       SqlDbType.DateTime),
                new SqlParameter("@price",         SqlDbType.Decimal,     9),
                new SqlParameter("@amount",        SqlDbType.Int,         4),
                new SqlParameter("@inMoney",       SqlDbType.Decimal,     9),
                new SqlParameter("@product",       SqlDbType.NVarChar,   -1),
                new SqlParameter("@user1",         SqlDbType.Int,         4),
                new SqlParameter("@remark",        SqlDbType.NVarChar,   -1),
                new SqlParameter("@createUser",    SqlDbType.Int,         4),
                new SqlParameter("@createDate",    SqlDbType.DateTime),
                new SqlParameter("@updateUser",    SqlDbType.Int,         4),
                new SqlParameter("@updateDate",    SqlDbType.DateTime),
                new SqlParameter("@temp1",         SqlDbType.NVarChar,   -1),
                new SqlParameter("@temp2",         SqlDbType.NVarChar,   -1),
                new SqlParameter("@productDate",   SqlDbType.DateTime),
                new SqlParameter("@validDate",     SqlDbType.DateTime),
                new SqlParameter("@manufacturers", SqlDbType.NVarChar,  500),
                new SqlParameter("@recipients",    SqlDbType.NVarChar,   -1),
                new SqlParameter("@id",            SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.eId;
            parameters[1].Value  = model.OutDate;
            parameters[2].Value  = model.price;
            parameters[3].Value  = model.amount;
            parameters[4].Value  = model.inMoney;
            parameters[5].Value  = model.product;
            parameters[6].Value  = model.user1;
            parameters[7].Value  = model.remark;
            parameters[8].Value  = model.createUser;
            parameters[9].Value  = model.createDate;
            parameters[10].Value = model.updateUser;
            parameters[11].Value = model.updateDate;
            parameters[12].Value = model.temp1;
            parameters[13].Value = model.temp2;
            parameters[14].Value = model.productDate;
            parameters[15].Value = model.validDate;
            parameters[16].Value = model.manufacturers;
            parameters[17].Value = model.recipients;
            parameters[18].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }