Example #1
0
        private void BindData()
        {
            StockLimitBLL bll       = null;
            DataPage      dp        = new DataPage();
            WHStockLimit  condition = new WHStockLimit();
            string        whID      = Request.QueryString["whID"];

            try
            {
                bll = BLLFactory.CreateBLL <StockLimitBLL>();
                this.hiWHID.Value   = whID;
                condition.MatID     = this.MatID.SelectedValue;
                condition.Warehouse = whID;

                PagerHelper.InitPageControl(this.AspNetPager1, dp, true);
                dp = bll.GetList(condition, dp);

                List <WHStockLimit> list = dp.Result as List <WHStockLimit>;
                this.GvList.DataSource = list;
                this.GvList.DataBind();

                for (int i = 0; i < this.GvList.Rows.Count; i++)
                {
                    string click = string.Format("return edit('{0}');", this.GvList.DataKeys[i]["ID"].ToString());

                    (this.GvList.Rows[i].Cells[8].Controls[0] as WebControl).Attributes.Add("onclick", click);
                }
                PagerHelper.SetPageControl(AspNetPager1, dp, true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        protected void btSave_Click(object sender, EventArgs e)
        {
            WHStockLimit  info = new WHStockLimit();
            StockLimitBLL bll  = null;

            try
            {
                UIBindHelper.BindModelByControls(this.Page, info);

                bll            = BLLFactory.CreateBLL <StockLimitBLL>();
                info.Warehouse = this.Warehourse.SelectedValue;
                if (this.hiID.Value == "")
                {
                    bll.Insert(info);
                }
                else
                {
                    info.CREATEUSER = this.HiCREATEUSER.Value;
                    info.CREATETIME = DateTime.Parse(this.HiCREATETIME.Value);
                    info.ID         = this.hiID.Value;
                    bll.Update(info);
                }

                ClientScript.RegisterStartupScript(this.GetType(), "myjs", "parent.refreshData();parent.closeAppWindow1();", true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #3
0
        /// <summary>
        /// 插入信息(单表)
        /// </summary>
        /// <param name="">信息</param>
        /// <returns>插入行数</returns>
        public DataResult <int> Insert(WHStockLimit info)
        {
            DataResult <int> result = new DataResult <int>();

            try
            {
                //基本信息
                info.ID         = Guid.NewGuid().ToString();
                info.CREATEUSER = this.LoginUser.UserID;
                info.CREATETIME = DateTime.Now;
                info.UPDATEUSER = info.CREATEUSER;
                info.UPDATETIME = info.CREATETIME;
                if (Exists(info))
                {
                    result.Msg    = "名称已存在";
                    result.Result = -1;
                    return(result);
                }
                result.Result    = new StockLimitDAL().Insert(info);
                result.IsSuccess = true;
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #4
0
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="condition">条件</param>
        /// <param name="page">数据页</param>
        /// <returns>数据页</returns>
        public DataPage GetList(WHStockLimit condition, DataPage page)
        {
            string sql = null;
            List <DataParameter> parameters = new List <DataParameter>();

            try
            {
                sql = this.GetQuerySql(condition, ref parameters);
                //分页关键字段及排序
                page.KeyName = "ID";
                if (string.IsNullOrEmpty(page.SortExpression))
                {
                    page.SortExpression = "UPDATETIME DESC";
                }
                using (IDataSession session = AppDataFactory.CreateMainSession())
                {
                    page = session.GetDataPage <WHStockLimit>(sql, parameters.ToArray(), page);
                }
                return(page);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #5
0
 /// <summary>
 /// 判断名称是否存在
 /// </summary>
 /// <param name="">信息</param>
 /// <returns>true:已存在;fasel:不存在。</returns>
 public bool Exists(WHStockLimit info)
 {
     try
     {
         return(new StockLimitDAL().Exists(info));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #6
0
 /// <summary>
 /// 获取列表
 /// </summary>
 /// <param name="condition">条件</param>
 /// <param name="page">数据页</param>
 /// <returns>数据页</returns>
 public DataPage GetList(WHStockLimit condition, DataPage page)
 {
     try
     {
         return(new StockLimitDAL().GetList(condition, page));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #7
0
 /// <summary>
 /// 获取信息
 /// </summary>
 /// <param name="">条件</param>
 /// <returns>信息</returns>
 public WHStockLimit Get(WHStockLimit info)
 {
     try
     {
         return(new StockLimitDAL().Get(info));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #8
0
 /// <summary>
 /// 获取导出的数据
 /// </summary>
 /// <param name="">查询条件</param>
 /// <returns>数据</returns>
 public DataTable GetExportData(WHStockLimit info)
 {
     try
     {
         return(new StockLimitDAL().GetExportData(info));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #9
0
 /// <summary>
 /// 删除信息
 /// </summary>
 /// <param name="">信息</param>
 /// <returns>删除个数</returns>
 public int Delete(WHStockLimit info)
 {
     try
     {
         return(new StockLimitDAL().Delete(info));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #10
0
 /// <summary>
 /// 获取信息
 /// </summary>
 /// <param name="">条件</param>
 /// <returns>*信息</returns>
 public WHStockLimit Get(WHStockLimit info)
 {
     try
     {
         using (IDataSession session = AppDataFactory.CreateMainSession())
         {
             //获取信息
             info = session.Get <WHStockLimit>(info);
         }
         return(info);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #11
0
        /// <summary>
        /// 删除信息
        /// </summary>
        /// <param name=""></param>
        /// <returns>删除个数</returns>
        public int Delete(WHStockLimit info)
        {
            int count = 0;

            try
            {
                using (IDataSession session = AppDataFactory.CreateMainSession())
                {
                    //删除基本信息
                    count = session.Delete <WHStockLimit>(info);
                }
                return(count);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #12
0
        private void BindData()
        {
            string        id   = Request.QueryString["id"];
            StockLimitBLL bll  = null;
            WHStockLimit  info = new WHStockLimit();
            string        whID = Request.QueryString["whID"];

            try
            {
                if (string.IsNullOrEmpty(whID) == false)
                {
                    this.Warehourse.Enabled = false;
                }
                else
                {
                    this.Warehourse.Enabled = true;
                }


                bll = BLLFactory.CreateBLL <StockLimitBLL>();
                if (string.IsNullOrEmpty(id) == false)
                {
                    info.ID = id;
                    info    = bll.Get(info);

                    UIBindHelper.BindForm(this.Page, info);
                    this.Warehourse.SelectedValue = info.Warehouse;
                    this.hiID.Value         = info.ID;
                    this.HiCREATEUSER.Value = info.CREATEUSER;
                    this.HiCREATETIME.Value = info.CREATETIME.ToString();

                    this.Warehourse.Enabled = false;
                }
                else
                {
                    info = new WHStockLimit();
                    this.Warehourse.SelectedValue = whID;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #13
0
        /// <summary>
        /// 获取导出的数据
        /// </summary>
        /// <param name="user">查询条件</param>
        /// <returns>数据</returns>
        public DataTable GetExportData(WHStockLimit info)
        {
            DataTable            dt         = null;
            string               sql        = null;
            List <DataParameter> parameters = new List <DataParameter>();

            try
            {
                //构成查询语句
                sql = this.GetQuerySql(info, ref parameters);
                using (IDataSession session = AppDataFactory.CreateMainSession())
                {
                    dt           = session.GetTable(sql, parameters.ToArray());
                    dt.TableName = "WHStockLimit";
                }
                return(dt);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #14
0
        /// <summary>
        /// 获取查询语句
        /// </summary>
        /// <param name="user">查询条件</param>
        /// <param name="parameters">参数</param>
        /// <returns>查询语句</returns>
        private string GetQuerySql(WHStockLimit condition, ref List <DataParameter> parameters)
        {
            StringBuilder sqlBuilder   = new StringBuilder();
            StringBuilder whereBuilder = new StringBuilder();

            try
            {
                //构成查询语句
                sqlBuilder.Append(@"SELECT t1.ID,t1.MatID,t1.Warehouse,t2.Description as WarehouseName
                    ,t1.Remark,t1.CREATEUSER,t1.CREATETIME,t1.UPDATEUSER,t1.UPDATETIME,t3.Description as UnitName 
                    ,t4.MatCode,t4.MatName,t1.MaxAmount,t1.MinAmount
                    FROM T_WH_StockLimit t1
                    inner join T_WH_Warehouse t2 on t1.Warehouse=t2.ID
                    inner join T_WH_MatUnit t3 on t1.UnitID=t3.ID
                    inner join T_WH_Mat t4 on t1.MatID=t4.ID");

                if (string.IsNullOrEmpty(condition.Warehouse) == false)
                {
                    whereBuilder.Append(" AND t1.Warehouse = @Warehouse");
                    parameters.Add(new DataParameter("Warehouse", condition.Warehouse));
                }

                if (string.IsNullOrEmpty(condition.MatID) == false)
                {
                    whereBuilder.Append(" AND t1.MatID = @MatID");
                    parameters.Add(new DataParameter("MatID", condition.MatID));
                }
                //查询条件
                if (whereBuilder.Length > 0)
                {
                    sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
                }
                return(sqlBuilder.ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #15
0
        /// <summary>
        /// 更新信息
        /// </summary>
        /// <param name="">信息</param>
        /// <returns>更新行数</returns>
        public DataResult <int> Update(WHStockLimit info)
        {
            DataResult <int> result = new DataResult <int>();

            try
            {
                if (Exists(info))
                {
                    result.Msg    = "名称已存在";
                    result.Result = -1;
                    return(result);
                }
                info.UPDATEUSER  = this.LoginUser.UserID;
                result.Result    = new StockLimitDAL().Update(info);
                result.IsSuccess = true;
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #16
0
        /// <summary>
        /// 判断名称是否存在
        /// </summary>
        /// <param name="info"></param>
        /// <returns>true:已存在;fasel:不存在。</returns>
        public bool Exists(WHStockLimit info)
        {
            StringBuilder        sqlBuilder   = new StringBuilder();
            StringBuilder        whereBuilder = new StringBuilder();
            List <DataParameter> parameters   = new List <DataParameter>();
            int count = 0;

            try
            {
                sqlBuilder.Append("SELECT COUNT(0) FROM T_WH_StockLimit");
                whereBuilder.Append(" AND ID <> @ID ");
                parameters.Add(new DataParameter {
                    ParameterName = "ID", DataType = DbType.String, Value = info.ID
                });
                if (!string.IsNullOrEmpty(info.MatID))
                {
                    whereBuilder.Append(" AND MatID = @MatID ");
                    parameters.Add(new DataParameter {
                        ParameterName = "MatID", DataType = DbType.String, Value = info.MatID
                    });
                }
                if (whereBuilder.Length > 0)
                {
                    sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
                }
                using (IDataSession session = AppDataFactory.CreateMainSession())
                {
                    count = Convert.ToInt32(session.ExecuteSqlScalar(sqlBuilder.ToString(), parameters.ToArray()));
                }
                return(count > 0);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }