//public string stockJson = string.Empty; protected void Page_Load(object sender, EventArgs e) { UserModel user = UserUtility.CurrentUser; ResultModel result = new ResultModel(); string redirectUrl = string.Format("{0}WareHouse/PreToRealList.aspx", DefaultValue.NftmSiteName); this.hidBDStyleId.Value = ((int)StyleEnum.报关状态).ToString(); if (!IsPostBack) { VerificationUtility ver = new VerificationUtility(); ver.JudgeOperate(this.Page, 129, new List<OperateEnum>() { OperateEnum.录入 }); this.navigation1.Routes.Add("预入库转正式库存列表", redirectUrl); this.navigation1.Routes.Add("预入库转正式库存新增", string.Empty); int stockId = 0; if (string.IsNullOrEmpty(Request.QueryString["id"]) || !int.TryParse(Request.QueryString["id"], out stockId) || stockId <= 0) Response.Redirect(redirectUrl); StockBLL stockBLL = new StockBLL(); result = stockBLL.Get(user, stockId); if (result.ResultStatus != 0) Response.Redirect(redirectUrl); stock = result.ReturnValue as Stock; if (stock == null) Response.Redirect(redirectUrl); StockNameBLL stockNameBLL = new StockNameBLL(); result = stockNameBLL.Get(user, stock.StockNameId); if (result.ResultStatus != 0) Response.Redirect(redirectUrl); stockName = result.ReturnValue as StockName; if (stockName == null) Response.Redirect(redirectUrl); //this.spStockStatus.InnerText = ((NFMT.WareHouse.StockStatusEnum)stock.StockStatus).ToString(); //System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); //this.stockJson = serializer.Serialize(stock); } }
public ResultModel RepoUpdateHandle(UserModel user, int repoId, string sids, string memo) { ResultModel result = new ResultModel(); DAL.RepoDetailDAL repoDetailDAL = new RepoDetailDAL(); NFMT.WareHouse.DAL.StockDAL stockDAL = new StockDAL(); NFMT.WareHouse.Model.Stock stock = new Stock(); NFMT.WareHouse.DAL.RepoApplyDetailDAL repoApplyDetailDAL = new RepoApplyDetailDAL(); try { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { result = repoDAL.Get(user, repoId); if (result.ResultStatus != 0) return result; Model.Repo repo = result.ReturnValue as Model.Repo; if (repo == null) { result.ResultStatus = -1; return result; } repo.Memo = memo; //更新回购 result = repoDAL.Update(user, repo); if (result.ResultStatus != 0) return result; //作废所有该回购下的明细 result = repoDetailDAL.InvalidAll(user, repoId); if (result.ResultStatus != 0) return result; string[] splits = sids.Split(','); if (splits != null && splits.Length > 0) { foreach (string str in splits) { //获取库存信息 result = stockDAL.Get(user, Convert.ToInt32(str)); if (result.ResultStatus != 0) return result; stock = result.ReturnValue as NFMT.WareHouse.Model.Stock; if (stock == null) { result.ResultStatus = -1; return result; } result = repoApplyDetailDAL.GetDetailId(user, repo.RepoApplyId, Convert.ToInt32(str)); if (result.ResultStatus != 0) return result; int detailId = (int)result.ReturnValue; //写入质押明细表 result = repoDetailDAL.Insert(user, new RepoDetail() { RepoId = repoId, RepoApplyDetailId = detailId, StockId = Convert.ToInt32(str), RepoWeight = stock.GrossAmount, Unit = stock.UintId }); if (result.ResultStatus != 0) return result; } scope.Complete(); } } } catch (Exception ex) { result.Message = ex.Message; } finally { if (result.ResultStatus != 0) log.ErrorFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue); else if (log.IsInfoEnabled) log.InfoFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue); } return result; }
public ResultModel UpdateStockStatus(UserModel user, Stock stock, StockOperateEnum operate) { ResultModel result = new ResultModel(); try { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { ResultModel stockResult = this.Get(user, stock.StockId); stock = stockResult.ReturnValue as Stock; if (stock == null || stock.StockId <= 0) { result.Message = "库存不存在"; result.ResultStatus = -1; return result; } switch (operate) { case StockOperateEnum.出库: if (stock.StockStatus != StockStatusEnum.在库正常) { result.Message = "非正常库存不能进行出库操作"; return result; } result = stockDAL.UpdateStockStatus(stock, StockStatusEnum.预售库存); break; case StockOperateEnum.入库: result = stockDAL.UpdateStockStatus(stock, StockStatusEnum.预入库存); break; case StockOperateEnum.质押: if (stock.StockStatus != StockStatusEnum.在库正常) { result.Message = "非正常库存不能进行质押操作"; return result; } result = stockDAL.UpdateStockStatus(stock, StockStatusEnum.预押库存); break; case StockOperateEnum.回购: if (stock.StockStatus != StockStatusEnum.质押库存) { result.Message = "非质押库存不能进行回购操作"; return result; } result = stockDAL.UpdateStockStatus(stock, StockStatusEnum.预回购库存); break; default: result.Message = "不存在库存操作类型"; result.ResultStatus = -1; break; } scope.Complete(); } } catch (Exception ex) { result.Message = ex.Message; } finally { if (result.ResultStatus != 0) log.ErrorFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue); else if (log.IsInfoEnabled) log.InfoFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue); } return result; }
public ResultModel UpdateStockStatusToPrevious(UserModel user, Stock stock) { ResultModel result = new ResultModel(); try { string sql = string.Format("update NFMT.dbo.St_Stock set StockStatus = PreStatus where StockId = {0}", stock.StockId); int i = NFMT.DBUtility.SqlHelper.ExecuteNonQuery(this.ConnectString, CommandType.Text, sql, null); if (i > 0) { result.ResultStatus = 0; result.Message = "更新成功"; result.AffectCount = i; } else { result.ResultStatus = -1; result.Message = "更新失败"; } } catch (Exception e) { result.Message = e.Message; result.ResultStatus = -1; } return result; }
public ResultModel UpdateStockStatus(Stock stock, StockStatusEnum stockStatus) { ResultModel result = new ResultModel(); try { string sql = string.Format("update dbo.St_Stock set PreStatus = StockStatus ,StockStatus = {0} where StockId = {1} ", (int)stockStatus, stock.StockId); int i = NFMT.DBUtility.SqlHelper.ExecuteNonQuery(this.ConnectString, CommandType.Text, sql, null); if (i > 0) { result.ResultStatus = 0; result.Message = "更新状态成功"; result.AffectCount = i; } else { result.ResultStatus = -1; result.Message = "更新状态失败"; result.AffectCount = i; } } catch (Exception e) { result.ResultStatus = -1; result.Message = string.Format("更新状态失败,{0}", e.Message); } return result; }
/// <summary> /// 数据撤返 /// </summary> /// <param name="user">当前操作用户</param> /// <param name="pledge">Pledge对象</param> /// <returns></returns> public ResultModel GoBack(UserModel user, int pledgeId) { ResultModel result = new ResultModel(); try { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { result = this.Get(user, pledgeId); if (result.ResultStatus != 0) return result; Model.Pledge pledge = result.ReturnValue as Pledge; if (pledge == null) { result.ResultStatus = -1; result.Message = "该数据不存在,不能撤返"; return result; } if (pledge.Status != StatusEnum.待审核 && pledge.Status != StatusEnum.已生效) { result.ResultStatus = -1; result.Message = "非待审核或已生效状态的数据不允许撤返"; return result; } //获取质押申请实体 DAL.PledgeApplyDAL pledgeApplyDAL = new PledgeApplyDAL(); result = pledgeApplyDAL.Get(user, pledge.PledgeApplyId); if (result.ResultStatus != 0) return result; Model.PledgeApply pledgeApply = result.ReturnValue as Model.PledgeApply; //获取申请实体 NFMT.Operate.DAL.ApplyDAL applyDAl = new Operate.DAL.ApplyDAL(); result = applyDAl.Get(user, pledgeApply.ApplyId); if (result.ResultStatus != 0) return result; NFMT.Operate.Model.Apply apply = result.ReturnValue as NFMT.Operate.Model.Apply; if (apply.Status == Common.StatusEnum.已关闭 || apply.Status == Common.StatusEnum.已完成) { result.ResultStatus = -1; result.Message = "质押对应的申请已完成或已关闭,不能进行撤返操作"; return result; } result = pledgeDAL.Goback(user, pledge); if (result.ResultStatus != 0) return result; if (pledge.Status == StatusEnum.待审核) { //同步工作流状态 NFMT.WorkFlow.BLL.DataSourceBLL dataSourceBLL = new WorkFlow.BLL.DataSourceBLL(); result = dataSourceBLL.SynchronousStatus(user, pledge); if (result.ResultStatus != 0) return result; } NFMT.WareHouse.DAL.PledgeDetialDAL pledgeDetialDAL = new DAL.PledgeDetialDAL(); result = pledgeDetialDAL.GetStockId(user, pledgeId); if (result.ResultStatus != 0) return result; if (!string.IsNullOrEmpty(result.ReturnValue.ToString())) { NFMT.WareHouse.DAL.StockDAL stockDAL = new StockDAL(); NFMT.WareHouse.DAL.StockNameDAL stockNameDAL = new StockNameDAL(); NFMT.WareHouse.DAL.StockLogDAL stockLogDAL = new StockLogDAL(); NFMT.WareHouse.Model.StockName stockName = new StockName(); NFMT.WareHouse.Model.Stock stock = new Stock(); NFMT.WareHouse.Model.StockLog stockLog = new StockLog(); foreach (string s in result.ReturnValue.ToString().Split(',')) { result = stockDAL.Get(user, Convert.ToInt32(s)); if (result.ResultStatus != 0) return result; stock = result.ReturnValue as Model.Stock; result = stockNameDAL.Get(user, stock.StockNameId); if (result.ResultStatus != 0) return result; stockName = result.ReturnValue as Model.StockName; ////创建stockLog对象 //stockLog = new StockLog() //{ // StockId = stock.StockId, // StockNameId = stock.StockNameId, // RefNo = stockName.RefNo, // //LogDirection = // LogType = LogEnum.质押冲销, // //ContractId = , // //SubContractId = , // LogDate = DateTime.Now, // OpPerson = user.EmpId, // Bundles = stock.Bundles, // GrossAmount = stock.GrossAmount, // NetAmount = stock.NetAmount, // MUId = stock.UintId, // BrandId = stock.BrandId, // DeliverPlaceId = stock.DeliverPlaceId, // PaperNo = stock.PaperNo, // PaperHolder = stock.PaperHolder, // CardNo = stock.CardNo, // Memo = stock.Memo, // LogStatus = StatusEnum.已生效, // LogSourceBase = "NFMT", // LogSource = "dbo.St_Pledge", // SourceId = pledgeId //}; //result = stockLogDAL.Insert(user, stockLog); //if (result.ResultStatus != 0) // return result; result = stockDAL.UpdateStockStatusToPrevious(user, stock); if (result.ResultStatus != 0) return result; } scope.Complete(); } } } catch (Exception ex) { result.Message = ex.Message; } finally { if (result.ResultStatus != 0) log.ErrorFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue); else if (log.IsInfoEnabled) log.InfoFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue); } return result; }
public override IModel CreateModel(SqlDataReader dr) { Stock stock = new Stock(); int indexStockId = dr.GetOrdinal("StockId"); stock.StockId = Convert.ToInt32(dr[indexStockId]); int indexStockNameId = dr.GetOrdinal("StockNameId"); if (dr["StockNameId"] != DBNull.Value) { stock.StockNameId = Convert.ToInt32(dr[indexStockNameId]); } int indexStockNo = dr.GetOrdinal("StockNo"); if (dr["StockNo"] != DBNull.Value) { stock.StockNo = Convert.ToString(dr[indexStockNo]); } int indexStockDate = dr.GetOrdinal("StockDate"); if (dr["StockDate"] != DBNull.Value) { stock.StockDate = Convert.ToDateTime(dr[indexStockDate]); } int indexAssetId = dr.GetOrdinal("AssetId"); if (dr["AssetId"] != DBNull.Value) { stock.AssetId = Convert.ToInt32(dr[indexAssetId]); } int indexBundles = dr.GetOrdinal("Bundles"); if (dr["Bundles"] != DBNull.Value) { stock.Bundles = Convert.ToInt32(dr[indexBundles]); } int indexGrossAmount = dr.GetOrdinal("GrossAmount"); if (dr["GrossAmount"] != DBNull.Value) { stock.GrossAmount = Convert.ToDecimal(dr[indexGrossAmount]); } int indexNetAmount = dr.GetOrdinal("NetAmount"); if (dr["NetAmount"] != DBNull.Value) { stock.NetAmount = Convert.ToDecimal(dr[indexNetAmount]); } int indexReceiptInGap = dr.GetOrdinal("ReceiptInGap"); if (dr["ReceiptInGap"] != DBNull.Value) { stock.ReceiptInGap = Convert.ToDecimal(dr[indexReceiptInGap]); } int indexReceiptOutGap = dr.GetOrdinal("ReceiptOutGap"); if (dr["ReceiptOutGap"] != DBNull.Value) { stock.ReceiptOutGap = Convert.ToDecimal(dr[indexReceiptOutGap]); } int indexCurGrossAmount = dr.GetOrdinal("CurGrossAmount"); if (dr["CurGrossAmount"] != DBNull.Value) { stock.CurGrossAmount = Convert.ToDecimal(dr[indexCurGrossAmount]); } int indexCurNetAmount = dr.GetOrdinal("CurNetAmount"); if (dr["CurNetAmount"] != DBNull.Value) { stock.CurNetAmount = Convert.ToDecimal(dr[indexCurNetAmount]); } int indexUintId = dr.GetOrdinal("UintId"); if (dr["UintId"] != DBNull.Value) { stock.UintId = Convert.ToInt32(dr[indexUintId]); } int indexDeliverPlaceId = dr.GetOrdinal("DeliverPlaceId"); if (dr["DeliverPlaceId"] != DBNull.Value) { stock.DeliverPlaceId = Convert.ToInt32(dr[indexDeliverPlaceId]); } int indexBrandId = dr.GetOrdinal("BrandId"); if (dr["BrandId"] != DBNull.Value) { stock.BrandId = Convert.ToInt32(dr[indexBrandId]); } int indexCustomsType = dr.GetOrdinal("CustomsType"); if (dr["CustomsType"] != DBNull.Value) { stock.CustomsType = Convert.ToInt32(dr[indexCustomsType]); } int indexGroupId = dr.GetOrdinal("GroupId"); if (dr["GroupId"] != DBNull.Value) { stock.GroupId = Convert.ToInt32(dr[indexGroupId]); } int indexCorpId = dr.GetOrdinal("CorpId"); if (dr["CorpId"] != DBNull.Value) { stock.CorpId = Convert.ToInt32(dr[indexCorpId]); } int indexDeptId = dr.GetOrdinal("DeptId"); if (dr["DeptId"] != DBNull.Value) { stock.DeptId = Convert.ToInt32(dr[indexDeptId]); } int indexProducerId = dr.GetOrdinal("ProducerId"); if (dr["ProducerId"] != DBNull.Value) { stock.ProducerId = Convert.ToInt32(dr[indexProducerId]); } int indexPaperNo = dr.GetOrdinal("PaperNo"); if (dr["PaperNo"] != DBNull.Value) { stock.PaperNo = Convert.ToString(dr[indexPaperNo]); } int indexPaperHolder = dr.GetOrdinal("PaperHolder"); if (dr["PaperHolder"] != DBNull.Value) { stock.PaperHolder = Convert.ToInt32(dr[indexPaperHolder]); } int indexFormat = dr.GetOrdinal("Format"); if (dr["Format"] != DBNull.Value) { stock.Format = Convert.ToString(dr[indexFormat]); } int indexOriginPlaceId = dr.GetOrdinal("OriginPlaceId"); if (dr["OriginPlaceId"] != DBNull.Value) { stock.OriginPlaceId = Convert.ToInt32(dr[indexOriginPlaceId]); } int indexOriginPlace = dr.GetOrdinal("OriginPlace"); if (dr["OriginPlace"] != DBNull.Value) { stock.OriginPlace = Convert.ToString(dr[indexOriginPlace]); } int indexPreStatus = dr.GetOrdinal("PreStatus"); if (dr["PreStatus"] != DBNull.Value) { stock.PreStatus = (StockStatusEnum)Convert.ToInt32(dr[indexPreStatus]); } int indexStockStatus = dr.GetOrdinal("StockStatus"); if (dr["StockStatus"] != DBNull.Value) { stock.StockStatus = (StockStatusEnum)Convert.ToInt32(dr[indexStockStatus]); } int indexCardNo = dr.GetOrdinal("CardNo"); if (dr["CardNo"] != DBNull.Value) { stock.CardNo = Convert.ToString(dr[indexCardNo]); } int indexMemo = dr.GetOrdinal("Memo"); if (dr["Memo"] != DBNull.Value) { stock.Memo = Convert.ToString(dr[indexMemo]); } int indexStockType = dr.GetOrdinal("StockType"); if (dr["StockType"] != DBNull.Value) { stock.StockType = Convert.ToInt32(dr[indexStockType]); } return stock; }