示例#1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.CostItem model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update mtms_CostItem set ");

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

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

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
文件: CostItem.cs 项目: LutherW/MTMS
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.CostItem> DataTableToList(DataTable dt)
        {
            List<Model.CostItem> modelList = new List<Model.CostItem>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.CostItem model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.CostItem();
                    if (dt.Rows[n]["Id"].ToString() != "")
                    {
                        model.Id = int.Parse(dt.Rows[n]["Id"].ToString());
                    }
                    model.Name = dt.Rows[n]["Name"].ToString();
                    if (dt.Rows[n]["SortCode"].ToString() != "")
                    {
                        model.SortCode = int.Parse(dt.Rows[n]["SortCode"].ToString());
                    }

                    modelList.Add(model);

                }
            }
            return modelList;
        }
示例#3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.CostItem model)
        {
            StringBuilder strSql = new StringBuilder();

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

            parameters[0].Value = model.Name;
            parameters[1].Value = model.SortCode;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#4
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Model.CostItem> DataTableToList(DataTable dt)
        {
            List <Model.CostItem> modelList = new List <Model.CostItem>();
            int rowsCount = dt.Rows.Count;

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


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
示例#5
0
        private void ShowInfo(int _id)
        {
            BLL.CostItem   bll   = new BLL.CostItem();
            Model.CostItem model = bll.GetModel(_id);

            txtName.Text     = model.Name;
            txtSortCode.Text = model.SortCode.ToString();
        }
示例#6
0
        private bool DoAdd()
        {
            Model.CostItem model = new Model.CostItem();
            BLL.CostItem bll = new BLL.CostItem();

            model.Name = txtName.Text.Trim();
            model.SortCode = Utils.StrToInt(txtSortCode.Text.Trim(), 0);

            if (bll.Add(model) > 0)
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加出车费用项:" + model.Name); //记录日志
                return true;
            }
            return false;
        }
示例#7
0
        private bool DoAdd()
        {
            Model.CostItem model = new Model.CostItem();
            BLL.CostItem   bll   = new BLL.CostItem();

            model.Name     = txtName.Text.Trim();
            model.SortCode = Utils.StrToInt(txtSortCode.Text.Trim(), 0);

            if (bll.Add(model) > 0)
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加出车费用项:" + model.Name); //记录日志
                return(true);
            }
            return(false);
        }
示例#8
0
        private bool DoEdit(int _id)
        {
            bool result = false;

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

            model.Name     = txtName.Text.Trim();
            model.SortCode = Utils.StrToInt(txtSortCode.Text.Trim(), 0);

            if (bll.Update(model))
            {
                AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改出车费用项:" + model.Name); //记录日志
                result = true;
            }

            return(result);
        }
示例#9
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.CostItem GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

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


            Model.CostItem model = new Model.CostItem();
            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();
                if (ds.Tables[0].Rows[0]["SortCode"].ToString() != "")
                {
                    model.SortCode = int.Parse(ds.Tables[0].Rows[0]["SortCode"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#10
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.CostItem model)
 {
     return(dal.Update(model));
 }
示例#11
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.CostItem model)
 {
     return(dal.Add(model));
 }
示例#12
0
文件: CostItem.cs 项目: LutherW/MTMS
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.CostItem GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select Id, Name, SortCode  ");
            strSql.Append("  from mtms_CostItem ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters = {
                    new SqlParameter("@Id", SqlDbType.Int,4)
            };
            parameters[0].Value = Id;

            Model.CostItem model = new Model.CostItem();
            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();
                if (ds.Tables[0].Rows[0]["SortCode"].ToString() != "")
                {
                    model.SortCode = int.Parse(ds.Tables[0].Rows[0]["SortCode"].ToString());
                }

                return model;
            }
            else
            {
                return null;
            }
        }