Esempio n. 1
0
        private void BindData()
        {
            string   id   = Request.QueryString["id"];
            WHMatBLL bll  = null;
            WHMat    info = new WHMat();

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

                    UIBindHelper.BindForm(this.Page, info);
                    this.hiID.Value         = info.ID;
                    this.HiCREATEUSER.Value = info.CREATEUSER;
                    this.HiCREATETIME.Value = info.CREATETIME.ToString();
                }
                else
                {
                    info = new WHMat();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 插入信息(单表)
        /// </summary>
        /// <param name="">信息</param>
        /// <returns>插入行数</returns>
        public DataResult <int> Insert(WHMat model)
        {
            DataResult <int> result = new DataResult <int>();

            try
            {
                //基本信息
                model.ID         = Guid.NewGuid().ToString();
                model.CREATEUSER = this.LoginUser.UserID;
                model.CREATETIME = DateTime.Now;
                model.UPDATEUSER = model.CREATEUSER;
                model.UPDATETIME = model.CREATETIME;
                if (Exists(model))
                {
                    result.Msg    = "编号已存在";
                    result.Result = -1;
                    return(result);
                }
                result.Result    = new WHMatDAL().Insert(model);
                result.IsSuccess = true;
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
        private void BindData()
        {
            WHMatBLL bll       = null;
            DataPage dp        = new DataPage();
            WHMat    condition = new WHMat();

            try
            {
                bll = BLLFactory.CreateBLL <WHMatBLL>();

                PagerHelper.InitPageControl(this.AspNetPager1, dp, true);
                condition.ID           = this.hiMatID.Value;
                condition.IDCodeStatus = this.CodeStatus.SelectedValue;
                condition.SpecCode     = this.MatSpec.SelectedValue;
                dp = bll.GetMatIDCodeList(condition, dp);

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

                for (int i = 0; i < this.GvList.Rows.Count; i++)
                {
                    Label lblBarCode = this.GvList.Rows[i].Cells[2].FindControl("lblBarCode") as Label;
                    lblBarCode.Text = this.GvList.Rows[i].Cells[1].Text;
                }

                PagerHelper.SetPageControl(AspNetPager1, dp, true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 获取查询语句
        /// </summary>
        /// <param name="user">查询条件</param>
        /// <param name="parameters">参数</param>
        /// <returns>查询语句</returns>
        private string GetQuerySql(WHMat condition, ref List <DataParameter> parameters)
        {
            StringBuilder sqlBuilder   = new StringBuilder();
            StringBuilder whereBuilder = new StringBuilder();

            try
            {
                //构成查询语句
                sqlBuilder.Append(@"SELECT t1.ID,t1.MatCode,t1.MatName,t2.Description as ProductType
                                    ,t3.Description as UnitCode,t4.Description as SpecCode
                                    FROM T_WH_Mat t1
                                    left outer join T_WH_MatType t2 on t1.ProductType=t2.ID
                                    left outer join T_WH_MatUnit t3 on t1.UnitCode=t3.ID
                                    left outer join T_WH_Spec t4 on t1.SpecCode=t4.ID
                                    ");

                //查询条件
                if (whereBuilder.Length > 0)
                {
                    sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
                }
                return(sqlBuilder.ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 生成物料唯一识别码
        /// </summary>
        /// <param name="count">个数</param>
        public void BuildMatIDCode(WHMat info, int count)
        {
            string newSeq = new WHMatDAL().GetNewIDCodeSeq(info);

            if (newSeq == null)
            {
                newSeq = "0";
            }

            List <MatIDCode> list = new List <MatIDCode>();

            for (int i = 0; i < count; i++)
            {
                MatIDCode idCode = new MatIDCode();
                idCode.MatID     = info.ID;
                idCode.IDCode    = info.MatCode + DateTime.Now.ToString("yyyyMMdd").Substring(2) + (int.Parse(newSeq) + (i + 1)).ToString("000");
                idCode.BuildDate = DateTime.Now.ToString("yyyyMMdd");
                idCode.Seq       = (int.Parse(newSeq) + (i + 1));
                idCode.Status    = 0;
                idCode.MatSpec   = info.SpecCode;

                list.Add(idCode);
            }
            new WHMatDAL().SaveMatIDCode(list);
        }
Esempio n. 6
0
        protected void btSave_Click(object sender, EventArgs e)
        {
            WHMat    info = new WHMat();
            WHMatBLL bll  = null;

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

                bll = BLLFactory.CreateBLL <WHMatBLL>();

                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;
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="condition">条件</param>
        /// <param name="page">数据页</param>
        /// <returns>数据页</returns>
        public DataPage GetList(WHMat 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 = "t1.UPDATETIME DESC";
                }
                using (IDataSession session = AppDataFactory.CreateMainSession())
                {
                    page = session.GetDataPage <WHMat>(sql, parameters.ToArray(), page);
                }
                return(page);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 8
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentEncoding = Encoding.UTF8;
            context.Response.ContentType     = "application/json";

            string idCode  = context.Request.QueryString["IDCode"];
            string matCode = context.Request.QueryString["MatCode"];

            WHMatBLL bll = BLLFactory.CreateBLL <WHMatBLL>();

            WHMat mat = null;

            bool exists = false;

            if (string.IsNullOrEmpty(idCode) == false)
            {
                //根据识别码
                mat = bll.GetMatByIDCode(idCode);
                if (mat != null)
                {
                    mat.BarCode = idCode;

                    //判断条码是否已入库
                    WHMatAmount amount = new StockBLL().GetStockByBarCode(idCode);
                    exists = amount != null ? true : false;
                    if (amount != null)
                    {
                        mat.Warehouse = amount.Warehouse;
                        mat.SaveSite  = amount.SaveSite;
                    }
                }
            }
            else
            {
                //根据货品编号
                mat = bll.GetMatByMatCode(matCode);
                if (mat != null)
                {
                    mat.BarCode = "";
                }
            }

            if (mat == null)
            {
                mat = new WHMat();
                if (mat != null)
                {
                    mat.MatCode = "none";
                }
            }

            MatGetResult result = LAF.Common.Util.BindHelper.CopyToModel <MatGetResult, WHMat>(mat);

            result.CheckResult = exists == true?"该条码已入库,无需再次操作":"";

            context.Response.Write(LAF.Common.Serialization.JsonConvertHelper.GetSerializes(result));
        }
Esempio n. 9
0
 /// <summary>
 /// 判断名称是否存在
 /// </summary>
 /// <param name="">信息</param>
 /// <returns>true:已存在;fasel:不存在。</returns>
 public bool Exists(WHMat model)
 {
     try
     {
         return(new WHMatDAL().Exists(model));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 10
0
 /// <summary>
 /// 删除信息
 /// </summary>
 /// <param name="">信息</param>
 /// <returns>删除个数</returns>
 public int Delete(WHMat model)
 {
     try
     {
         return(new WHMatDAL().Delete(model));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 11
0
 /// <summary>
 /// 获取导出的数据
 /// </summary>
 /// <param name="">查询条件</param>
 /// <returns>数据</returns>
 public DataTable GetExportData(WHMat model)
 {
     try
     {
         return(new WHMatDAL().GetExportData(model));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 12
0
 /// <summary>
 /// 获取列表
 /// </summary>
 /// <param name="condition">条件</param>
 /// <param name="page">数据页</param>
 /// <returns>数据页</returns>
 public DataPage GetList(WHMat condition, DataPage page)
 {
     try
     {
         return(new WHMatDAL().GetList(condition, page));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 13
0
 /// <summary>
 /// 获取信息
 /// </summary>
 /// <param name="">条件</param>
 /// <returns>信息</returns>
 public WHMat Get(WHMat info)
 {
     try
     {
         return(new WHMatDAL().Get(info));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 14
0
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="condition">条件</param>
        /// <returns>仓库列表</returns>
        public List <WHMat> GetList(WHMat condition)
        {
            List <WHMat> list = null;
            string       sql  = null;

            using (IDataSession session = AppDataFactory.CreateMainSession())
            {
                sql  = "SELECT * FROM T_WH_Mat";
                list = session.GetList <WHMat>(sql, new List <DataParameter>().ToArray()).ToList <WHMat>();
            }

            return(list);
        }
Esempio n. 15
0
        protected void btDelete_Click(object sender, EventArgs e)
        {
            ArrayList     pkArray = null;
            WHMatBLL      bll     = null;
            List <string> msgList = new List <string>();

            try
            {
                bll = BLLFactory.CreateBLL <WHMatBLL>();

                pkArray = GvHelper.GetPKValueByChk(this.GvList, 0, "cbxSelect", 0);

                for (int i = 0; i < this.GvList.Rows.Count; i++)
                {
                    CheckBox cbxSelect = this.GvList.Rows[i].Cells[0].FindControl("cbxSelect") as CheckBox;

                    if (cbxSelect.Checked == false)
                    {
                        continue;
                    }

                    WHMat mat = new WHMat();
                    mat.ID      = this.GvList.DataKeys[i]["ID"].ToString();
                    mat.MatName = this.GvList.Rows[i].Cells[2].Text;

                    //判断是否已使用
                    bool r = bll.IsUse(mat);
                    if (r == true)
                    {
                        msgList.Add(mat.MatName);
                        continue;
                    }

                    //删除
                    bll.Delete(mat);
                }
                string msg = string.Join(",", msgList.ToArray());
                if (msg != "")
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myjs", "MSI('提示','" + msg + "货品已使用,无法删除');", true);
                }

                this.BindData();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 16
0
 /// <summary>
 /// 获取信息
 /// </summary>
 /// <param name="">条件</param>
 /// <returns>*信息</returns>
 public WHMat Get(WHMat info)
 {
     try
     {
         using (IDataSession session = AppDataFactory.CreateMainSession())
         {
             //获取信息
             info = session.Get <WHMat>(info);
         }
         return(info);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 17
0
        /// <summary>
        /// 更新信息
        /// </summary>
        /// <param name=""></param>
        /// <returns>更新行数</returns>
        public int Update(WHMat info)
        {
            int count = 0;

            try
            {
                using (IDataSession session = AppDataFactory.CreateMainSession())
                {
                    //更新信息
                    count = session.Update <WHMat>(info);
                }
                return(count);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 18
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name=""></param>
        /// <returns>删除个数</returns>
        public int Delete(WHMat info)
        {
            StringBuilder        sqlBuilder = new StringBuilder();
            List <DataParameter> parameters = new List <DataParameter>();
            int count = 0;

            try
            {
                using (IDataSession session = AppDataFactory.CreateMainSession())
                {
                    count = session.Delete <WHMat>(info);
                }
                return(count);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 19
0
        /// <summary>
        /// 根据货品编号获取货品信息
        /// </summary>
        /// <param name="matCode">货品编号</param>
        /// <returns>货品信息</returns>
        public WHMat GetMatByMatCode(string matCode)
        {
            WHMat mat = null;

            string sql = null;

            sql = @"select t1.ID,t1.ID as MatID,t1.MatCode,t1.MatName,t3.Description as SpecCode,t4.Description as UnitName,t4.ID as UnitCode
                    from T_WH_Mat t1
                    left join T_WH_Spec t3 on t1.SpecCode=t3.ID
                    left join T_WH_MatUnit t4 on t1.UnitCode=t4.ID
                    where t1.MatCode = @MatCode";

            using (IDataSession session = AppDataFactory.CreateMainSession())
            {
                sql = this.ChangeSqlByDB(sql, session);
                mat = session.Get <WHMat>(sql, new DataParameter("MatCode", matCode));
            }

            return(mat);
        }
Esempio n. 20
0
        /// <summary>
        /// 获取货品最新唯一识别码
        /// </summary>
        /// <param name="info">货品信息</param>
        public string GetNewIDCodeSeq(WHMat info)
        {
            string no    = null;
            object value = null;
            string sql   = "select max(Seq) from T_WH_MatIDCode where MatID = @MatID and BuildDate = @BuildDate";

            using (IDataSession session = AppDataFactory.CreateMainSession())
            {
                sql   = this.ChangeSqlByDB(sql, session);
                value = session.ExecuteSqlScalar(sql, new DataParameter("MatID", info.ID)
                                                 , new DataParameter("BuildDate", DateTime.Now.ToString("yyyyMMdd")));
            }

            if (value != null && value != System.DBNull.Value)
            {
                no = value.ToString();
            }

            return(no);
        }
Esempio n. 21
0
        /// <summary>
        /// 判断是否被使用
        /// </summary>
        /// <param name="info">货品</param>
        /// <returns>true:已使用;false:未使用</returns>
        public bool IsUse(WHMat info)
        {
            int    count = 0;
            string sql   = null;

            sql = "select count(ID) from T_WH_InStockDetail where MatID = @MatID";

            using (IDataSession session = AppDataFactory.CreateMainSession())
            {
                count = int.Parse(session.ExecuteSqlScalar(sql, new DataParameter("MatID", info.ID)).ToString());
            }

            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 22
0
        private void BindMatInfo()
        {
            string          matID = Request.QueryString["matID"];
            List <DictInfo> dicts = null;

            WHMat mat = BLLFactory.CreateBLL <WHMatBLL>().Get(new WHMat {
                ID = matID
            });

            this.MatCode.Text  = mat.MatCode;
            this.MatName.Text  = mat.MatName;
            this.hiMatID.Value = matID;

            //绑定规格
            List <MatUnit> specList = BLLFactory.CreateBLL <WHMatSpecBLL>().GetMayUnits(matID);

            dicts = specList.Select(p => new DictInfo {
                ID = p.ID, Des = p.Description
            }).ToList <DictInfo>();
            Tools.BindDataToDDL(this.MatSpec, dicts, null);
        }
Esempio n. 23
0
        /// <summary>
        /// 获取货品唯一识别码列表
        /// </summary>
        /// <param name="condition">条件</param>
        /// <param name="page">数据页</param>
        /// <returns>数据页</returns>
        public DataPage GetMatIDCodeList(WHMat condition, DataPage page)
        {
            string sql = null;
            List <DataParameter> parameters = new List <DataParameter>();

            try
            {
                sql = "select * from T_WH_MatIDCode where MatID = @MatID";

                if (condition.IDCodeStatus == "0")
                {
                    sql += " and PrintCount = 0";
                }
                else
                {
                    sql += " and PrintCount > 0";
                }

                //分页关键字段及排序
                page.KeyName = "IDCode";
                if (string.IsNullOrEmpty(page.SortExpression))
                {
                    page.SortExpression = "PrintCount,BuildDate DESC,IDCode";
                }

                parameters.Add(new DataParameter("MatID", condition.ID));

                using (IDataSession session = AppDataFactory.CreateMainSession())
                {
                    sql  = this.ChangeSqlByDB(sql, session);
                    page = session.GetDataPage <MatIDCode>(sql, parameters.ToArray(), page);
                }
                return(page);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 24
0
        private void BindData()
        {
            WHMatBLL bll       = null;
            DataPage dp        = new DataPage();
            WHMat    condition = new WHMat();

            try
            {
                bll = BLLFactory.CreateBLL <WHMatBLL>();
                condition.MatName = this.Description.Text;

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

                List <WHMat> list = dp.Result as List <WHMat>;
                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[10].Controls[0] as WebControl).Attributes.Add("onclick", click);

                    LinkButton lbtBuildCode = this.GvList.Rows[i].Cells[11].FindControl("lbtBuildCode") as LinkButton;

                    lbtBuildCode.PostBackUrl = "BuildMatIDCode.aspx?matID=" + this.GvList.DataKeys[i]["ID"].ToString();

                    LinkButton lbtSetSpec = this.GvList.Rows[i].Cells[12].FindControl("lbtSetSpec") as LinkButton;

                    lbtSetSpec.PostBackUrl = "ManageMatSpec.aspx?matID=" + this.GvList.DataKeys[i]["ID"].ToString();
                }
                PagerHelper.SetPageControl(AspNetPager1, dp, true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 25
0
        /// <summary>
        /// 更新信息
        /// </summary>
        /// <param name="">信息</param>
        /// <returns>更新行数</returns>
        public DataResult <int> Update(WHMat model)
        {
            DataResult <int> result = new DataResult <int>();

            try
            {
                if (Exists(model))
                {
                    result.Msg    = "名称已存在";
                    result.Result = -1;
                    return(result);
                }
                model.UPDATEUSER = this.LoginUser.UserID;
                result.Result    = new WHMatDAL().Update(model);
                result.IsSuccess = true;
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 26
0
        /// <summary>
        /// 获取导出的数据
        /// </summary>
        /// <param name="user">查询条件</param>
        /// <returns>数据</returns>
        public DataTable GetExportData(WHMat model)
        {
            DataTable            dt         = null;
            string               sql        = null;
            List <DataParameter> parameters = new List <DataParameter>();

            try
            {
                //构成查询语句
                sql = this.GetQuerySql(model, ref parameters);
                using (IDataSession session = AppDataFactory.CreateMainSession())
                {
                    dt           = session.GetTable(sql, parameters.ToArray());
                    dt.TableName = "Warehouse";
                }
                return(dt);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 27
0
        private void BindData()
        {
            WHMatSpecBLL bll       = null;
            DataPage     dp        = new DataPage();
            WHMatSpec    condition = new WHMatSpec();
            string       matID     = Request.QueryString["matID"];

            try
            {
                bll = BLLFactory.CreateBLL <WHMatSpecBLL>();
                this.MatID.Value = matID;

                WHMat mat = BLLFactory.CreateBLL <WHMatBLL>().Get(new WHMat {
                    ID = matID
                });
                this.MatCode.Text = mat.MatCode;
                this.MatName.Text = mat.MatName;

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

                List <WHMatSpec> list = dp.Result as List <WHMatSpec>;
                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[6].Controls[0] as WebControl).Attributes.Add("onclick", click);
                }
                PagerHelper.SetPageControl(AspNetPager1, dp, true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 28
0
        /// <summary>
        /// 判断名称是否存在
        /// </summary>
        /// <param name="info"></param>
        /// <returns>true:已存在;fasel:不存在。</returns>
        public bool Exists(WHMat 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_Mat");
                whereBuilder.Append(" AND ID <> @ID ");
                parameters.Add(new DataParameter {
                    ParameterName = "ID", DataType = DbType.String, Value = info.ID
                });
                if (!string.IsNullOrEmpty(info.MatCode))
                {
                    whereBuilder.Append(" AND MatCode = @MatCode ");
                    parameters.Add(new DataParameter {
                        ParameterName = "MatCode", DataType = DbType.String, Value = info.MatCode
                    });
                }
                if (whereBuilder.Length > 0)
                {
                    sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
                }
                using (IDataSession session = AppDataFactory.CreateMainSession())
                {
                    string sql = this.ChangeSqlByDB(sqlBuilder.ToString(), session);
                    count = Convert.ToInt32(session.ExecuteSqlScalar(sql, parameters.ToArray()));
                }
                return(count > 0);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 29
0
 /// <summary>
 /// 判断是否被使用
 /// </summary>
 /// <param name="info">货品</param>
 /// <returns>true:已使用;false:未使用</returns>
 public bool IsUse(WHMat info)
 {
     return(new WHMatDAL().IsUse(info));
 }
Esempio n. 30
0
 /// <summary>
 /// 获取货品唯一识别码列表
 /// </summary>
 /// <param name="condition">条件</param>
 /// <param name="page">数据页</param>
 /// <returns>数据页</returns>
 public DataPage GetMatIDCodeList(WHMat condition, DataPage page)
 {
     return(new WHMatDAL().GetMatIDCodeList(condition, page));
 }