Exemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int AddOutStoreHouse(OutStoreHouseModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_OutStoreHouse(");
            strSql.Append("OutSN,OutDate,HandlePerson,Remark,CreatePerson,CreateDate,UpdatePerson,UpdateDate,DeleteMark)");
            strSql.Append(" values (");
            strSql.Append("@OutSN,@OutDate,@HandlePerson,@Remark,@CreatePerson,@CreateDate,@UpdatePerson,@UpdateDate,@DeleteMark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@OutSN",        SqlDbType.VarChar,    50),
                new SqlParameter("@OutDate",      SqlDbType.DateTime),
                new SqlParameter("@HandlePerson", SqlDbType.VarChar,    50),
                new SqlParameter("@Remark",       SqlDbType.VarChar,   100),
                new SqlParameter("@CreatePerson", SqlDbType.VarChar,    50),
                new SqlParameter("@CreateDate",   SqlDbType.DateTime),
                new SqlParameter("@UpdatePerson", SqlDbType.VarChar,    50),
                new SqlParameter("@UpdateDate",   SqlDbType.DateTime),
                new SqlParameter("@DeleteMark",   SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.OutSN;
            parameters[1].Value = model.OutDate;
            parameters[2].Value = model.HandlePerson;
            parameters[3].Value = model.Remark;
            parameters[4].Value = model.CreatePerson;
            parameters[5].Value = model.CreateDate;
            parameters[6].Value = model.UpdatePerson;
            parameters[7].Value = model.UpdateDate;
            parameters[8].Value = model.DeleteMark;

            return(Convert.ToInt32(DriveMgr.Common.SqlHelper.ExecuteScalar(DriveMgr.Common.SqlHelper.financialMgrConn, CommandType.Text, strSql.ToString(), parameters)));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        private OutStoreHouseModel DataRowToModel(DataRow row)
        {
            OutStoreHouseModel model = new OutStoreHouseModel();

            if (row != null)
            {
                if (row["Id"] != null && row["Id"].ToString() != "")
                {
                    model.Id = int.Parse(row["Id"].ToString());
                }
                if (row["OutSN"] != null)
                {
                    model.OutSN = row["OutSN"].ToString();
                }
                if (row["OutDate"] != null && row["OutDate"].ToString() != "")
                {
                    model.OutDate = DateTime.Parse(row["OutDate"].ToString());
                }
                if (row["HandlePerson"] != null)
                {
                    model.HandlePerson = row["HandlePerson"].ToString();
                }
                if (row["Remark"] != null)
                {
                    model.Remark = row["Remark"].ToString();
                }
                if (row["CreatePerson"] != null)
                {
                    model.CreatePerson = row["CreatePerson"].ToString();
                }
                if (row["CreateDate"] != null && row["CreateDate"].ToString() != "")
                {
                    model.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                }
                if (row["UpdatePerson"] != null)
                {
                    model.UpdatePerson = row["UpdatePerson"].ToString();
                }
                if (row["UpdateDate"] != null && row["UpdateDate"].ToString() != "")
                {
                    model.UpdateDate = DateTime.Parse(row["UpdateDate"].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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool UpdateOutStoreHouse(OutStoreHouseModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_OutStoreHouse set ");
            strSql.Append("OutSN=@OutSN,");
            strSql.Append("OutDate=@OutDate,");
            strSql.Append("HandlePerson=@HandlePerson,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("CreatePerson=@CreatePerson,");
            strSql.Append("CreateDate=@CreateDate,");
            strSql.Append("UpdatePerson=@UpdatePerson,");
            strSql.Append("UpdateDate=@UpdateDate,");
            strSql.Append("DeleteMark=@DeleteMark");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@OutSN",        SqlDbType.VarChar,    50),
                new SqlParameter("@OutDate",      SqlDbType.DateTime),
                new SqlParameter("@HandlePerson", SqlDbType.VarChar,    50),
                new SqlParameter("@Remark",       SqlDbType.VarChar,   100),
                new SqlParameter("@CreatePerson", SqlDbType.VarChar,    50),
                new SqlParameter("@CreateDate",   SqlDbType.DateTime),
                new SqlParameter("@UpdatePerson", SqlDbType.VarChar,    50),
                new SqlParameter("@UpdateDate",   SqlDbType.DateTime),
                new SqlParameter("@DeleteMark",   SqlDbType.Bit,         1),
                new SqlParameter("@Id",           SqlDbType.Int, 4)
            };
            parameters[0].Value = model.OutSN;
            parameters[1].Value = model.OutDate;
            parameters[2].Value = model.HandlePerson;
            parameters[3].Value = model.Remark;
            parameters[4].Value = model.CreatePerson;
            parameters[5].Value = model.CreateDate;
            parameters[6].Value = model.UpdatePerson;
            parameters[7].Value = model.UpdateDate;
            parameters[8].Value = model.DeleteMark;
            parameters[9].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}");
        }
Exemplo n.º 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public OutStoreHouseModel GetOutStoreHouseModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,OutSN,OutDate,HandlePerson,Remark,CreatePerson,CreateDate,UpdatePerson,UpdateDate,DeleteMark from tb_OutStoreHouse ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            OutStoreHouseModel model = new OutStoreHouseModel();
            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);
            }
        }