/// <summary>
        /// 更新数据
        /// </summary>
        /// <returns></returns>
        public int UpdateStorageInventoryInfo(WarehouseInventoryInfo pp)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tbStocktakeInfo set ");
            strSql.Append(" Quantity=@Quantity ");
            strSql.Append(" where StocktakeID=@StocktakeID");

            SqlParameter[] parm =
            {
                new SqlParameter("@StocktakeID", SqlDbType.Int),
                new SqlParameter("@Quantity",    SqlDbType.Decimal),
            };
            parm[0].Value = pp.StocktakeID;
            parm[1].Value = pp.Quantity;

            int state = DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parm);

            if (state > 0)
            {
                return(state);
            }
            else
            {
                return(-1);
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WarehouseInventoryInfo GetWarehouseInventoryInfoModel(int StocktakeID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select top 1 ProductsID,StorageID,Quantity,sQuantity,sDateTime,sAppendTime,StaffID,sSteps from tbStocktakeInfo  ");
            strSql.Append(" where StocktakeID=@StocktakeID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@StocktakeID", SqlDbType.Int, 4)
            };
            parameters[0].Value = StocktakeID;

            WarehouseInventoryInfo model = new WarehouseInventoryInfo();
            DataSet ds = DbHelper.ExecuteDataset(CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ProductsID"].ToString() != "")
                {
                    model.ProductsID = int.Parse(ds.Tables[0].Rows[0]["ProductsID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["StorageID"].ToString() != "")
                {
                    model.StorageID = int.Parse(ds.Tables[0].Rows[0]["StorageID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Quantity"].ToString() != "")
                {
                    model.Quantity = decimal.Parse(ds.Tables[0].Rows[0]["Quantity"].ToString());
                }
                if (ds.Tables[0].Rows[0]["sQuantity"].ToString() != "")
                {
                    model.SQuantity = decimal.Parse(ds.Tables[0].Rows[0]["sQuantity"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProductsID"].ToString() != "")
                {
                    model.ProductsID = int.Parse(ds.Tables[0].Rows[0]["ProductsID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["sDateTime"].ToString() != "")
                {
                    model.SDateTime = DateTime.Parse(ds.Tables[0].Rows[0]["sDateTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["sAppendTime"].ToString() != "")
                {
                    model.SAppendTime = DateTime.Parse(ds.Tables[0].Rows[0]["sAppendTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["StaffID"].ToString() != "")
                {
                    model.StaffID = int.Parse(ds.Tables[0].Rows[0]["StaffID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["sSteps"].ToString() != "")
                {
                    model.SSteps = int.Parse(ds.Tables[0].Rows[0]["sSteps"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 更新盘点数据
        /// </summary>
        /// <remarks>Cxty_20110711</remarks>
        /// <param name="sInventoryInfo"></param>
        /// <returns></returns>
        public bool UpdateWarehouseList(WarehouseInventoryInfo sInventoryInfo)
        {
            StringBuilder btr = new StringBuilder();

            if (sInventoryInfo.GetWarehouseDateJson != null)
            {
                if (sInventoryInfo.GetWarehouseDateJson.WarehouseInventory != null)
                {
                    btr.Append("update tbStocktakeInventoryInfo set SAppendTime=@SAppendTime,StorageStaff=@StorageStaff,StaffPhoneNum=@StaffPhoneNum,StaffAdress=@StaffAdress,InventoryName=@InventoryName where StockID=@StockID;");
                    try
                    {
                        foreach (WarehouseInventory ol in sInventoryInfo.GetWarehouseDateJson.WarehouseInventory)
                        {
                            if (ol.stocktakeid > 0)
                            {
                                btr.Append("update tbStocktakeInfo set Quantity='" + ol.pnum + "',sQuantity='" + ol.oQuantity + "',sAppendTime=@SAppendTime where StocktakeID=" + ol.stocktakeid + " ;");
                            }
                            else
                            {
                                btr.Append("insert  into tbStocktakeInfo(StockID,ProductsID,StorageID,Quantity,sQuantity,sDateTime,sAppendTime,StaffID,sSteps)");
                                btr.Append(" values(" + sInventoryInfo.StockID + ",'" + ol.pid + "','" + sInventoryInfo.StorageID + "','" + ol.pnum + "','" + ol.oQuantity + "','" + sInventoryInfo.SDateTime + "',@SAppendTime,'" + sInventoryInfo.StaffID + "',0);");
                            }
                        }
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@SAppendTime",   SqlDbType.DateTime,  8),
                            new SqlParameter("@StorageStaff",  SqlDbType.VarChar,  50),
                            new SqlParameter("@StaffPhoneNum", SqlDbType.VarChar,  50),
                            new SqlParameter("@StaffAdress",   SqlDbType.VarChar,  50),
                            new SqlParameter("@InventoryName", SqlDbType.VarChar,  50),
                            new SqlParameter("@StockID",       SqlDbType.Int, 4)
                        };
                        parameters[0].Value = sInventoryInfo.SAppendTime;
                        parameters[1].Value = sInventoryInfo.StorageStaff;
                        parameters[2].Value = sInventoryInfo.StaffPhoneNum;
                        parameters[3].Value = sInventoryInfo.StaffAdress;
                        parameters[4].Value = sInventoryInfo.InventoryName;
                        parameters[5].Value = sInventoryInfo.StockID;

                        DbHelper.ExecuteNonQuery(CommandType.Text, btr.ToString(), parameters);
                        return(true);
                    }
                    catch {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 添加仓库盘点信息
        /// </summary>
        /// <remarks>Cxty_20110711,tbStocktakeInfo中增加字段StockID</remarks>
        /// <returns></returns>
        public bool AddWarehouseList(WarehouseInventoryInfo sInventoryInfo)
        {
            StringBuilder btr = new StringBuilder();

            if (sInventoryInfo.GetWarehouseDateJson != null)
            {
                if (sInventoryInfo.GetWarehouseDateJson.WarehouseInventory != null)
                {
                    DateTime sDateTime     = sInventoryInfo.SDateTime;     //盘点时间
                    DateTime sAppendTime   = sInventoryInfo.SAppendTime;   //库存点
                    int      StorageID     = sInventoryInfo.StorageID;     //仓库编号
                    string   StorageStaff  = sInventoryInfo.StorageStaff;  //仓管员
                    string   StaffPhoneNum = sInventoryInfo.StaffPhoneNum; //联系电话
                    string   StaffAdress   = sInventoryInfo.StaffAdress;   //联系地址
                    string   InventoryName = sInventoryInfo.InventoryName; //盘点人
                    int      uerID         = sInventoryInfo.StaffID;       //操作员编号
                    string   userName      = sInventoryInfo.StaffName;     //操作员名称
                    string   StorageName   = sInventoryInfo.StorageName;   //仓库名称

                    btr.Append("declare @StockID int;");
                    btr.Append("insert into tbStocktakeInventoryInfo(StorageID,StorageStaff,StaffPhoneNum,StaffAdress,sAppendTime,sUpdateTime,InventoryName,StaffID,StorageName,StaffName)");
                    btr.Append(" values('" + StorageID + "','" + StorageStaff + "','" + StaffPhoneNum + "','" + StaffAdress + "','" + sDateTime + "','" + sAppendTime + "','" + InventoryName + "','" + uerID + "','" + StorageName + "','" + userName + "')");
                    btr.Append(";SET @StockID = SCOPE_IDENTITY();");
                    try
                    {
                        foreach (WarehouseInventory ol in sInventoryInfo.GetWarehouseDateJson.WarehouseInventory)
                        {
                            if (ol != null)
                            {
                                btr.Append("insert  into tbStocktakeInfo(StockID,ProductsID,StorageID,Quantity,sQuantity,sDateTime,sAppendTime,StaffID,sSteps)");
                                btr.Append(" values(@StockID,'" + ol.pid + "','" + StorageID + "','" + ol.pnum + "','" + ol.oQuantity + "','" + sDateTime + "','" + sAppendTime + "','" + uerID + "',0)");
                            }
                        }

                        DbHelper.ExecuteNonQuery(CommandType.Text, btr.ToString());
                        return(true);
                    }
                    catch
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        protected virtual void Page_Load(object sender, EventArgs e)
        {
            if (this.userid > 0)
            {
                if (CheckUserPopedoms("X") || CheckUserPopedoms("3-4-5"))
                {
                    if (Act == "Edit")
                    {
                        StocktakeID = Utils.StrToInt(HTTPRequest.GetString("sid"), 0);
                        si          = tbStockProductInfo.GetWarehouseInventoryInfoModel(StocktakeID);
                    }
                    if (ispost)
                    {
                        if (Act == "Edit")
                        {
                            si.Quantity    = Convert.ToDecimal(HTTPRequest.GetString("Quantity"));
                            si.StocktakeID = Utils.StrToInt(HTTPRequest.GetString("sid"), 0);

                            int state = tbStockProductInfo.UpdateStorageInventoryInfo(si);
                            if (state > 0)
                            {
                                AddMsgLine("更新数据成功!");
                                AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                            }
                            else
                            {
                                AddMsgLine("更新数据失败!");
                                AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                            }
                        }
                    }
                }
                else
                {
                    AddErrLine("权限不足!");
                    AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                }
            }
            else
            {
                AddErrLine("请先登录!");
                SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
                SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
            }
        }
示例#6
0
 public static int UpdateStorageInventoryInfo(WarehouseInventoryInfo pp)
 {
     return(DatabaseProvider.GetInstance().UpdateStorageInventoryInfo(pp));
 }
示例#7
0
 public static bool UpdateWarehouseList(WarehouseInventoryInfo sInventoryInfo)
 {
     return(DatabaseProvider.GetInstance().UpdateWarehouseList(sInventoryInfo));
 }
示例#8
0
        protected virtual void Page_Load(object sender, EventArgs e)
        {
            pagesize    = 20;
            PageBarHTML = "";
            if (this.userid > 0)
            {
                if (CheckUserPopedoms("X") || CheckUserPopedoms("3-4-1-2"))
                {
                    pagecode = Utils.GetRanDomCode().Trim();
                    UsersUtils.WriteCookie("OrderPageCode", pagecode);

                    if (HTTPRequest.GetString("page").Trim() != "" && Utils.IsInt(HTTPRequest.GetString("page").Trim()))
                    {
                        pageindex = int.Parse(HTTPRequest.GetString("page").Trim());
                    }
                    else
                    {
                        pageindex = 1;
                    }
                    if (Act == "Edit")
                    {
                        StockID = Utils.StrToInt(HTTPRequest.GetString("sid"), 0);
                        si      = tbStockProductInfo.GetInventoryInfoModel(StockID);

                        if (ispost)
                        {
                            DateTime sDate         = Utils.IsDateString(Utils.ChkSQL(HTTPRequest.GetString("dtime"))) ? DateTime.Parse(Utils.ChkSQL(HTTPRequest.GetString("dtime"))) : DateTime.Now;
                            string   InventoryName = Utils.ChkSQL(HTTPRequest.GetString("InventoryName")); //盘点人
                            string   ManagerName   = Utils.ChkSQL(HTTPRequest.GetString("ManagerName"));   //仓管员
                            string   sTel          = Utils.ChkSQL(HTTPRequest.GetString("sTel"));
                            string   sAddress      = Utils.ChkSQL(HTTPRequest.GetString("sAddress"));
                            string   reValue       = HTTPRequest.GetString("reValue");

                            si.SAppendTime   = sDate;
                            si.StorageStaff  = ManagerName;
                            si.StaffPhoneNum = sTel;
                            si.StaffAdress   = sAddress;
                            si.InventoryName = InventoryName;

                            si.GetWarehouseDateJson = (GetWarehouseDateJsonList)JavaScriptConvert.DeserializeObject(reValue, typeof(GetWarehouseDateJsonList));

                            bool state = tbStockProductInfo.UpdateWarehouseList(si);
                            if (state)
                            {
                                AddErrLine("修改数据成功!");
                                AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                            }
                            else
                            {
                                AddErrLine("修改数据失败!");
                                AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                            }
                        }
                        else
                        {
                            //ssi = tbStorageInfo.GetStorageInfoModel(si.StorageID);
                            dList       = tbStockProductInfo.getInventoryInfoList(si.StorageID, si.SDateTime);
                            PageBarHTML = Utils.TenPage(pageindex, pagetotal, 0);
                        }
                    }
                }
                else
                {
                    AddErrLine("权限不足! ");
                    AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                }
            }
            else
            {
                AddErrLine("请先登录!");
                SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
                SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
            }
        }
        /// <summary>
        /// 得到一个对象实体tbStocktakeInventoryInfo
        /// </summary>
        public WarehouseInventoryInfo GetInventoryInfoModel(int StockID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select top 1 StorageName,StorageID,StorageStaff,StaffPhoneNum,StaffAdress,sUpdateTime,sAppendTime,InventoryName,StaffID,StaffName from tbStocktakeInventoryInfo  ");
            strSql.Append(" where StockID=@StockID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@StockID", SqlDbType.Int, 4)
            };
            parameters[0].Value = StockID;

            WarehouseInventoryInfo model = new WarehouseInventoryInfo();
            DataSet ds = DbHelper.ExecuteDataset(CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                model.StockID = StockID;
                if (ds.Tables[0].Rows[0]["StorageName"].ToString() != "")
                {
                    model.StorageName = ds.Tables[0].Rows[0]["StorageName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["StorageID"].ToString() != "")
                {
                    model.StorageID = int.Parse(ds.Tables[0].Rows[0]["StorageID"].ToString());
                }
                //if (ds.Tables[0].Rows[0]["StorageStaff"].ToString() != "")
                {
                    model.StorageStaff = ds.Tables[0].Rows[0]["StorageStaff"].ToString();
                }
                // if (ds.Tables[0].Rows[0]["StaffPhoneNum"].ToString() != "")
                {
                    model.StaffPhoneNum = ds.Tables[0].Rows[0]["StaffPhoneNum"].ToString();
                }
                //  if (ds.Tables[0].Rows[0]["StaffAdress"].ToString() != "")
                {
                    model.StaffAdress = ds.Tables[0].Rows[0]["StaffAdress"].ToString();
                }
                if (ds.Tables[0].Rows[0]["sUpdateTime"].ToString() != "")
                {
                    model.SDateTime = DateTime.Parse(ds.Tables[0].Rows[0]["sUpdateTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["sAppendTime"].ToString() != "")
                {
                    model.SAppendTime = DateTime.Parse(ds.Tables[0].Rows[0]["sAppendTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["InventoryName"].ToString() != "")
                {
                    model.InventoryName = ds.Tables[0].Rows[0]["InventoryName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["StaffID"].ToString() != "")
                {
                    model.StaffID = int.Parse(ds.Tables[0].Rows[0]["StaffID"].ToString());
                }
                // if (ds.Tables[0].Rows[0]["StaffName"].ToString() != "")
                {
                    model.StaffName = ds.Tables[0].Rows[0]["StaffName"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }