Ejemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.daikuan_chanye model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update daikuan_chanye set ");
            strSql.Append("name=@name,");
            strSql.Append("amount=@amount,");
            strSql.Append("add_time=@add_time");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@name",     SqlDbType.NVarChar,  50),
                new SqlParameter("@amount",   SqlDbType.Decimal),
                new SqlParameter("@add_time", SqlDbType.DateTime),
                new SqlParameter("@id",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.name;
            parameters[1].Value = model.amount;
            parameters[2].Value = model.add_time;
            parameters[3].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
 private void ShowInfo(int _id)
 {
     BLL.daikuan_chanye   bll   = new BLL.daikuan_chanye();
     Model.daikuan_chanye model = bll.GetModel(_id);
     txtName.Text = model.name;
     //txtAmount.Text = model.amount.ToString();
     txtAddTime.Text = model.add_time.Value.ToString("yyyy-MM-dd HH:mm:ss");
 }
Ejemplo n.º 3
0
        private bool DoEdit(int _id)
        {
            bool result = false;

            BLL.daikuan_chanye   bll   = new BLL.daikuan_chanye();
            Model.daikuan_chanye model = bll.GetModel(_id);
            model.name = txtName.Text.Trim();
            //model.amount = Utils.StrToDecimal(txtAmount.Text, 0);
            model.add_time = Utils.StrToDateTime(txtAddTime.Text.Trim());
            if (bll.Update(model))
            {
                AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改产业规模:" + model.name); //记录日志
                result = true;
            }

            return(result);
        }
Ejemplo n.º 4
0
 private bool DoAdd()
 {
     Model.daikuan_chanye model = new Model.daikuan_chanye();
     BLL.daikuan_chanye   bll   = new BLL.daikuan_chanye();
     //检测会员证号码是否重复
     if (bll.Exists(txtName.Text.Trim()))
     {
         return(false);
     }
     model.name = txtName.Text.Trim();
     //model.amount = Utils.StrToDecimal(txtAmount.Text, 0);
     model.add_time = Utils.StrToDateTime(txtAddTime.Text.Trim());
     if (bll.Add(model) > 0)
     {
         AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加产业规模:" + model.name); //记录日志
         return(true);
     }
     return(false);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.daikuan_chanye model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        #region 添加主表数据====================
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("insert into daikuan_chanye(");
                        strSql.Append("name,amount,add_time)");
                        strSql.Append(" values (");
                        strSql.Append("@name,@amount,@add_time)");
                        strSql.Append(";select @@IDENTITY");
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@name",     SqlDbType.NVarChar, 50),
                            new SqlParameter("@amount",   SqlDbType.Decimal),
                            new SqlParameter("@add_time", SqlDbType.DateTime)
                        };
                        parameters[0].Value = model.name;
                        parameters[1].Value = model.amount;
                        parameters[2].Value = model.add_time;
                        //添加主表数据
                        object obj = DbHelperSQL.GetSingle(conn, trans, strSql.ToString(), parameters); //带事务
                        model.id = Convert.ToInt32(obj);
                        #endregion

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        return(0);
                    }
                }
            }
            return(model.id);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.daikuan_chanye DataRowToModel(DataRow row)
 {
     Model.daikuan_chanye model = new Model.daikuan_chanye();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["name"] != null)
         {
             model.name = row["name"].ToString();
         }
         if (row["amount"] != null && row["amount"].ToString() != "")
         {
             model.amount = decimal.Parse(row["amount"].ToString());
         }
         if (row["add_time"] != null && row["add_time"].ToString() != "")
         {
             model.add_time = DateTime.Parse(row["add_time"].ToString());
         }
     }
     return(model);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.daikuan_chanye GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

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

            Model.daikuan_chanye model = new Model.daikuan_chanye();
            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.º 8
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.daikuan_chanye model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.daikuan_chanye model)
 {
     return(dal.Add(model));
 }