Exemple #1
0
        private void BindStockTakingMaster()
        {
            StockTakingMasterQueryAgrs agrs = new StockTakingMasterQueryAgrs();

            agrs.StartTime = dateEditStartTime1.DateTime;
            agrs.EndTime   = dateEditStartTime2.DateTime;
            agrs.UserName  = txtUserName.Text;
            agrs.Number    = txtNumber.Text;
            agrs.StoreID   = UserInfo.Instance.StoreID;

            var result = stock.StockTakingMasterQuery(agrs);

            this.gridStockTaking.DataSource = result;
        }
Exemple #2
0
        /// <summary>
        /// 查询盘点记录
        /// </summary>
        /// <param name="queryAgrs">盘点记录参数</param>
        /// <returns></returns>
        public DataTable StockTakingMasterQuery(StockTakingMasterQueryAgrs queryAgrs)
        {
            string select_content = "SELECT * FROM StocktakingMaster ";
            string select_where   = " WHERE ";

            IList <DbParameter> parms = new List <DbParameter>();

            if (queryAgrs != null)
            {
                if (queryAgrs.StartTime.HasValue)
                {
                    select_where += " StartTime>@StartTime AND ";
                    parms.Add(new SqlParameter("@StartTime", queryAgrs.StartTime));
                }

                if (queryAgrs.EndTime.HasValue)
                {
                    select_where += " StartTime < @EndTime AND ";
                    parms.Add(new SqlParameter("@EndTime", queryAgrs.EndTime));
                }

                if (!string.IsNullOrEmpty(queryAgrs.UserName))
                {
                    select_where += " UserName = @UserName AND ";

                    parms.Add(new SqlParameter("@UserName", queryAgrs.UserName));
                }

                if (!string.IsNullOrEmpty(queryAgrs.Number))
                {
                    select_where += " Number Like '%'+ @Number +'%' AND ";

                    parms.Add(new SqlParameter("@Number", queryAgrs.Number));
                }

                if (!string.IsNullOrEmpty(queryAgrs.Remark))
                {
                    select_where += " Remark  Like '%'+ @Remark +'%' AND ";

                    parms.Add(new SqlParameter("@Remark", queryAgrs.Remark));
                }

                if (queryAgrs.Status.HasValue)
                {
                    select_where += " Status=@Status AND ";
                    parms.Add(new SqlParameter("@Status", queryAgrs.Status));
                }

                if (queryAgrs.StoreID.HasValue)
                {
                    select_where += " StoreID=@StoreID AND ";
                    parms.Add(new SqlParameter("@StoreID", queryAgrs.StoreID));
                }
            }

            DataSet result;

            try
            {
                if (parms.Count > 0)
                {
                    select_where    = select_where.Remove(select_where.LastIndexOf("AND"));
                    select_content += select_where + " ORDER BY Number DESC ";
                    result          = db.ExecuteDataSet(CommandType.Text, select_content, parms.ToArray());
                }
                else
                {
                    result = db.ExecuteDataSet(CommandType.Text, select_content);
                }

                if (result != null)
                {
                    return(result.Tables[0]);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }