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

            strSql.Append("update mtms_CustomerType set ");

            strSql.Append(" Name = @Name  ");
            strSql.Append(" where Id=@Id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",   SqlDbType.Int,     4),
                new SqlParameter("@Name", SqlDbType.VarChar, 254)
            };

            parameters[0].Value = model.Id;
            parameters[1].Value = model.Name;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.CustomerType GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Id, Name  ");
            strSql.Append("  from mtms_CustomerType ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;


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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                model.Name = ds.Tables[0].Rows[0]["Name"].ToString();

                return(model);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.CustomerType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into mtms_CustomerType(");
            strSql.Append("Name");
            strSql.Append(") values (");
            strSql.Append("@Name");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name", SqlDbType.VarChar, 254)
            };

            parameters[0].Value = model.Name;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 4
0
        private void ShowInfo(int _id)
        {
            BLL.CustomerType   bll   = new BLL.CustomerType();
            Model.CustomerType model = bll.GetModel(_id);

            txtName.Text = model.Name;
        }
Ejemplo n.º 5
0
        private bool DoAdd()
        {
            bool result = false;
            Model.CustomerType model = new Model.CustomerType();
            BLL.CustomerType bll = new BLL.CustomerType();

            model.Name = txtName.Text.Trim();

            if (bll.Add(model) > 0)
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加客户类别:" + model.Name); //记录日志
                result = true;
            }
            return result;
        }
Ejemplo n.º 6
0
        private bool DoEdit(int _id)
        {
            bool result = false;

            BLL.CustomerType   bll   = new BLL.CustomerType();
            Model.CustomerType model = bll.GetModel(_id);

            model.Name = txtName.Text.Trim();

            if (bll.Update(model))
            {
                AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改客户类别信息:" + model.Name); //记录日志
                result = true;
            }
            return(result);
        }
Ejemplo n.º 7
0
        private bool DoAdd()
        {
            bool result = false;

            Model.CustomerType model = new Model.CustomerType();
            BLL.CustomerType   bll   = new BLL.CustomerType();

            model.Name = txtName.Text.Trim();

            if (bll.Add(model) > 0)
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加客户类别:" + model.Name); //记录日志
                result = true;
            }
            return(result);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.CustomerType> DataTableToList(DataTable dt)
        {
            List<Model.CustomerType> modelList = new List<Model.CustomerType>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.CustomerType model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.CustomerType();
                    if (dt.Rows[n]["Id"].ToString() != "")
                    {
                        model.Id = int.Parse(dt.Rows[n]["Id"].ToString());
                    }
                    model.Name = dt.Rows[n]["Name"].ToString();

                    modelList.Add(model);
                }
            }
            return modelList;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Model.CustomerType> DataTableToList(DataTable dt)
        {
            List <Model.CustomerType> modelList = new List <Model.CustomerType>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Model.CustomerType model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.CustomerType();
                    if (dt.Rows[n]["Id"].ToString() != "")
                    {
                        model.Id = int.Parse(dt.Rows[n]["Id"].ToString());
                    }
                    model.Name = dt.Rows[n]["Name"].ToString();


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.CustomerType GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select Id, Name  ");
            strSql.Append("  from mtms_CustomerType ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters = {
                    new SqlParameter("@Id", SqlDbType.Int,4)
            };
            parameters[0].Value = Id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                model.Name = ds.Tables[0].Rows[0]["Name"].ToString();

                return model;
            }
            else
            {
                return null;
            }
        }
Ejemplo n.º 11
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.CustomerType model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 12
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.CustomerType model)
 {
     return(dal.Add(model));
 }