/// <summary>
        /// 增加一条数据
        /// </summary>
        public bool AddOutStoreHouseDetails(OutStoreHouseDetailsModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_OutStoreHouseDetails(");
            strSql.Append("OutDetailsSN,GoodsID,OutStoreHouseID,OutQuantity,DeleteMark)");
            strSql.Append(" values (");
            strSql.Append("@OutDetailsSN,@GoodsID,@OutStoreHouseID,@OutQuantity,@DeleteMark)");

            SqlParameter[] parameters =
            {
                new SqlParameter("@OutDetailsSN",    SqlDbType.VarChar, 50),
                new SqlParameter("@GoodsID",         SqlDbType.Int,      4),
                new SqlParameter("@OutStoreHouseID", SqlDbType.Int,      4),
                new SqlParameter("@OutQuantity",     SqlDbType.Int,      4),
                new SqlParameter("@DeleteMark",      SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.OutDetailsSN;
            parameters[1].Value = model.GoodsID;
            parameters[2].Value = model.OutStoreHouseID;
            parameters[3].Value = model.OutQuantity;
            parameters[4].Value = model.DeleteMark;

            int rows = DriveMgr.Common.SqlHelper.ExecuteNonQuery(DriveMgr.Common.SqlHelper.financialMgrConn, CommandType.Text, strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        private OutStoreHouseDetailsModel DataRowToModel(DataRow row)
        {
            OutStoreHouseDetailsModel model = new OutStoreHouseDetailsModel();

            if (row != null)
            {
                if (row["Id"] != null && row["Id"].ToString() != "")
                {
                    model.Id = int.Parse(row["Id"].ToString());
                }
                if (row["OutDetailsSN"] != null)
                {
                    model.OutDetailsSN = row["OutDetailsSN"].ToString();
                }
                if (row["GoodsID"] != null && row["GoodsID"].ToString() != "")
                {
                    model.GoodsID = int.Parse(row["GoodsID"].ToString());
                }
                if (row["OutStoreHouseID"] != null && row["OutStoreHouseID"].ToString() != "")
                {
                    model.OutStoreHouseID = int.Parse(row["OutStoreHouseID"].ToString());
                }
                if (row["OutQuantity"] != null && row["OutQuantity"].ToString() != "")
                {
                    model.OutQuantity = int.Parse(row["OutQuantity"].ToString());
                }
                if (row["DeleteMark"] != null && row["DeleteMark"].ToString() != "")
                {
                    if ((row["DeleteMark"].ToString() == "1") || (row["DeleteMark"].ToString().ToLower() == "true"))
                    {
                        model.DeleteMark = true;
                    }
                    else
                    {
                        model.DeleteMark = false;
                    }
                }
            }
            return(model);
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool UpdateOutStoreHouseDetails(OutStoreHouseDetailsModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_OutStoreHouseDetails set ");
            strSql.Append("OutDetailsSN=@OutDetailsSN,");
            strSql.Append("GoodsID=@GoodsID,");
            strSql.Append("OutStoreHouseID=@OutStoreHouseID,");
            strSql.Append("OutQuantity=@OutQuantity,");
            strSql.Append("DeleteMark=@DeleteMark");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@OutDetailsSN",    SqlDbType.VarChar, 50),
                new SqlParameter("@GoodsID",         SqlDbType.Int,      4),
                new SqlParameter("@OutStoreHouseID", SqlDbType.Int,      4),
                new SqlParameter("@OutQuantity",     SqlDbType.Int,      4),
                new SqlParameter("@DeleteMark",      SqlDbType.Bit,      1),
                new SqlParameter("@Id",              SqlDbType.Int, 4)
            };
            parameters[0].Value = model.OutDetailsSN;
            parameters[1].Value = model.GoodsID;
            parameters[2].Value = model.OutStoreHouseID;
            parameters[3].Value = model.OutQuantity;
            parameters[4].Value = model.DeleteMark;
            parameters[5].Value = model.Id;

            object obj = DriveMgr.Common.SqlHelper.ExecuteNonQuery(DriveMgr.Common.SqlHelper.financialMgrConn, CommandType.Text, strSql.ToString(), parameters);

            if (Convert.ToInt32(obj) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void AddOutStoreHouseDetails(DriveMgr.Model.User userFromCookie, HttpContext context)
        {
            GoodsBLL         goodsBll         = new GoodsBLL();
            OutStoreHouseBLL outStoreHouseBLL = new OutStoreHouseBLL();

            string outDetailStr = "[" + context.Request.Params["outDetailStr"].Trim(',') + "]";
            JavaScriptSerializer             serializer = new JavaScriptSerializer();
            List <OutStoreHouseDetailsModel> outStoreHouseDetailsModelList = serializer.Deserialize <List <OutStoreHouseDetailsModel> >(outDetailStr);

            OutStoreHouseModel outStoreHouseAdd = new OutStoreHouseModel();

            outStoreHouseAdd.OutDate      = DateTime.Now;
            outStoreHouseAdd.HandlePerson = userFromCookie.UserId;
            outStoreHouseAdd.CreateDate   = DateTime.Now;
            outStoreHouseAdd.CreatePerson = userFromCookie.UserId;
            outStoreHouseAdd.UpdatePerson = userFromCookie.UserId;
            outStoreHouseAdd.UpdateDate   = DateTime.Now;
            outStoreHouseAdd.DeleteMark   = false;

            int outStoreHouseID = outStoreHouseBLL.AddOutStoreHouse(outStoreHouseAdd);

            foreach (OutStoreHouseDetailsModel model in outStoreHouseDetailsModelList)
            {
                OutStoreHouseDetailsModel newOutStoreHouseDetailsModel = new OutStoreHouseDetailsModel();
                newOutStoreHouseDetailsModel.GoodsID         = model.GoodsID;
                newOutStoreHouseDetailsModel.OutQuantity     = model.OutQuantity;
                newOutStoreHouseDetailsModel.OutStoreHouseID = outStoreHouseID;
                newOutStoreHouseDetailsModel.DeleteMark      = false;
                if (outStoreHouseDetailsBll.AddOutStoreHouseDetails(newOutStoreHouseDetailsModel))    //添加入库明细
                {
                    GoodsModel goodsModel = goodsBll.GetGoodsModel(newOutStoreHouseDetailsModel.GoodsID.Value);
                    goodsModel.RealQuantity -= newOutStoreHouseDetailsModel.OutQuantity;
                    goodsBll.UpdateGoods(goodsModel);    //更新物品数量
                }
            }

            context.Response.Write("{\"msg\":\"出库成功!\",\"success\":true}");
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public OutStoreHouseDetailsModel GetOutStoreHouseDetailsModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,OutDetailsSN,GoodsID,OutStoreHouseID,OutQuantity,DeleteMark from tb_OutStoreHouseDetails ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            OutStoreHouseDetailsModel model = new OutStoreHouseDetailsModel();
            DataSet ds = DriveMgr.Common.SqlHelper.GetDataset(DriveMgr.Common.SqlHelper.financialMgrConn, CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }