示例#1
0
        private bool DoAdd()
        {
            bool result = false;
            Model.Address model = new Model.Address();
            BLL.Address bll = new BLL.Address();

            model.Name = txtName.Text.Trim();
            model.Code = string.IsNullOrEmpty(txtCode.Text.Trim()) ? model.Name : txtCode.Text.Trim();
            model.CategoryName = ddlCategory.SelectedValue;

            if (bll.Add(model) > 0)
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加装卸货地址:" + model.Name); //记录日志
                result = true;
            }
            return result;
        }
示例#2
0
文件: Address.cs 项目: LutherW/MTMS
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.Address> DataTableToList(DataTable dt)
        {
            List<Model.Address> modelList = new List<Model.Address>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.Address model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.Address();
                    if (dt.Rows[n]["Id"].ToString() != "")
                    {
                        model.Id = int.Parse(dt.Rows[n]["Id"].ToString());
                    }
                    model.Name = dt.Rows[n]["Name"].ToString();
                    model.CategoryName = dt.Rows[n]["CategoryName"].ToString();
                    model.Code = dt.Rows[n]["Code"].ToString();

                    modelList.Add(model);
                }
            }
            return modelList;
        }
示例#3
0
文件: Address.cs 项目: LutherW/MTMS
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Address GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select Id, Name, CategoryName, Code  ");
            strSql.Append("  from mtms_Address ");
            strSql.Append(" where [email protected]");
            SqlParameter[] parameters = {
                    new SqlParameter("@Id", SqlDbType.Int,4)
            };
            parameters[0].Value = Id;

            Model.Address model = new Model.Address();
            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();
                model.CategoryName = ds.Tables[0].Rows[0]["CategoryName"].ToString();
                model.Code = ds.Tables[0].Rows[0]["Code"].ToString();

                return model;
            }
            else
            {
                return null;
            }
        }