public POHead SavePOHead() { using (ISession session = new Session()) { try { POHead poHead = null; if (this.IsNew) { //新增 poHead = new POHead(); poHead.OrderNumber = ERPUtil.NextOrderNumber(POHead.ORDER_TYPE); this.txtOrderNumber.Text = poHead.OrderNumber; poHead.CompanyID = -1; poHead.LocationCode = this.drpLocationCode.SelectedValue; poHead.PurchGroupCode = this.drpPurchGroupCode.SelectedValue; poHead.VendorID = Cast.Int(this.drpVendorID.SelectedValue, 0); poHead.Status = POStatus.New; poHead.TaxAmt = 0M; poHead.TaxExclusiveAmt = 0M; poHead.TaxInclusiveAmt = 0M; poHead.ShippingAddress = this.txtShippingAddress.Text.Trim(); poHead.CreateUser = Magic.Security.SecuritySession.CurrentUser.UserId; poHead.CreateTime = DateTime.Now; poHead.ApproveResult = ApproveStatus.UnApprove; poHead.ApproveTime = new DateTime(1900, 1, 1); poHead.ApproveUser = 0; poHead.ApproveNote = " "; poHead.CurrentLineNumber = "0000"; poHead.Note = this.txtNote.Text.Trim(); poHead.DefaultPlanDate = Cast.DateTime(this.txtDemandDate.Text, DateTime.Now); poHead.Create(session); WebUtil.ShowMsg(this, "采购订单保存成功", "操作成功"); return(poHead); } else { //编辑 poHead = POHead.Retrieve(session, this.txtOrderNumber.Text.Trim()); poHead.LocationCode = this.drpLocationCode.SelectedValue; poHead.PurchGroupCode = this.drpPurchGroupCode.SelectedValue; poHead.VendorID = Cast.Int(this.drpVendorID.SelectedValue, 0); poHead.ShippingAddress = this.txtShippingAddress.Text.Trim(); poHead.Note = this.txtNote.Text.Trim(); poHead.DefaultPlanDate = Cast.DateTime(this.txtDemandDate.Text, poHead.DefaultPlanDate); poHead.Update(session, "PurchGroupCode", "LocationCode", "VendorID", "ShippingAddress", "Note", "DefaultPlanDate"); WebUtil.ShowMsg(this, "采购订单保存成功", "操作成功"); return(poHead); } } catch (Exception ex) { //throw; logger.Info("保存POHead", ex); WebUtil.ShowMsg(this, "发生未处理的异常,请刷新页面重新操作,或者联系系统管理员"); } return(null); } }
protected void MagicItemCommand(object sender, MagicItemEventArgs e) { if (e.CommandName == "Save") { using (ISession session = new Session()) { ICHead head = null; bool created = false; if (this.IsNew) { head = new ICHead(); head.OrderTypeCode = ICHead.ORDER_TYPE; head.Status = InterchangeStatus.New; head.ApproveResult = ApproveStatus.UnApprove; head.ApproveUser = 0; head.ApproveTime = new DateTime(1900, 1, 1); head.CreateUser = SecuritySession.CurrentUser.UserId; head.CreateTime = DateTime.Now; head.CompanyUser = head.CreateUser; head.InterchangeTime = DateTime.Now; head.LogisticUser = this.txtLogisticsUser.Text.Trim(); head.Note = this.txtNote.Text.Trim(); head.LogisticCompID = Magic.Framework.Utils.Cast.Int(this.drpLogistic.SelectedValue); try { session.BeginTransaction(); head.OrderNumber = ERPUtil.NextOrderNumber(head.OrderTypeCode); head.Create(session); head.AutoGenerateDetail(session); session.Commit(); created = true; //this.txtAction.Value = "edit"; //this.txtId.Value = head.OrderNumber; //this.showInfo(session, head); //this.setView(head); //WebUtil.ShowMsg(this, string.Format("交接单{0}创建成功", head.OrderNumber)); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); } } if (created) { this.Response.Redirect("InterchangeLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return"))); } head = ICHead.Retrieve(session, this.OrderNumber); head.Note = this.txtNote.Text.Trim(); head.LogisticCompID = Magic.Framework.Utils.Cast.Int(this.drpLogistic.SelectedValue); head.LogisticUser = this.txtLogisticsUser.Text.Trim(); head.Update(session, "Note", "LogisticCompID", "LogisticUser", "BoxNum"); WebUtil.ShowMsg(this, "保存成功"); } } }
protected void MagicItemCommand(object sender, MagicItemEventArgs e) { if (e.CommandName == "Save") { using (ISession session = new Session()) { POReturnHead head = null; if (this.IsNew) { head = new POReturnHead(); head.Status = POReturnStatus.New; head.ApproveResult = ApproveStatus.UnApprove; head.ApproveUser = 0; head.ApproveTime = new DateTime(1900, 1, 1); head.CreateUser = SecuritySession.CurrentUser.UserId; head.CreateTime = DateTime.Now; head.Note = this.txtNote.Text.Trim(); head.LocationCode = this.drpLocation.SelectedValue; head.VendorID = Cast.Int(this.drpVendor.SelectedValue); try { session.BeginTransaction(); head.OrderNumber = ERPUtil.NextOrderNumber(head.OrderTypeCode); head.Create(session); session.Commit(); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); return; } this.Response.Redirect("POReturnLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return"))); return; } head = POReturnHead.Retrieve(session, this.OrderNumber); try { session.BeginTransaction(); head.Update(session, Cast.Int(this.drpVendor.SelectedValue), this.drpLocation.SelectedValue, this.txtNote.Text.Trim()); session.Commit(); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); return; } this.Response.Redirect("POReturnLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return"))); } } }
protected void MagicItemCommand(object sender, MagicItemEventArgs e) { if (e.CommandName == "Save") { using (ISession session = new Session()) { StockInHead head = null; if (this.IsNew) { head = new StockInHead(); head.OrderTypeCode = StockInHead.ORD_TYPE_PRD_IN; head.Status = StockInStatus.New; head.ApproveResult = ApproveStatus.UnApprove; head.ApproveUser = 0; head.ApproveTime = new DateTime(1900, 1, 1); head.CreateUser = SecuritySession.CurrentUser.UserId; head.CreateTime = DateTime.Now; head.Note = this.txtNote.Text.Trim(); head.LocationCode = this.drpLocation.SelectedValue; head.RefOrdNum = this.txtRefOrdNum.Text.Trim().ToUpper(); try { session.BeginTransaction(); head.OrderNumber = ERPUtil.NextOrderNumber(head.OrderTypeCode); head.Create(session); head.AddPrdOutDetail2ThisOrder(session); session.Commit(); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); } this.Response.Redirect("ProductInLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return"))); return; } head = StockInHead.Retrieve(session, this.OrderNumber); head.Note = this.txtNote.Text.Trim(); head.LocationCode = this.drpLocation.SelectedValue; head.RefOrdNum = this.txtRefOrdNum.Text.Trim().ToUpper(); head.Update(session, "Note", "LocationCode", "RefOrdNum"); //没有明细时,才考虑将库存领用明细添加进来 if (session.CreateEntityQuery <StockInLine>() .Where(Magic.Framework.ORM.Query.Exp.Eq("OrderNumber", head.OrderNumber)) .Count() <= 0) { head.AddPrdOutDetail2ThisOrder(session); } this.Response.Redirect("ProductInLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return"))); } } }
protected void MagicItemCommand(object sender, MagicItemEventArgs e) { if (e.CommandName == "Save") { using (ISession session = new Session()) { WHTransferHead head = null; if (this.IsNew) { head = new WHTransferHead(); head.OrderNumber = ERPUtil.NextOrderNumber(WHTransferHead.ORDER_TYPE_NORMAL); head.Note = this.txtNote.Text.Trim(); head.FromLocation = this.drpFromLocation.SelectedValue; head.ToLocation = this.drpToLocation.SelectedValue; head.Status = WHTransferStatus.New; head.OrderTypeCode = WHTransferHead.ORDER_TYPE_NORMAL; head.CreateTime = DateTime.Now; head.CreateUser = SecuritySession.CurrentUser.UserId; head.Create(session); log.DebugFormat("Create - 移库单: {0}", head.OrderNumber); System.Text.StringBuilder url = new System.Text.StringBuilder(); url.Append("TransferNewLine.aspx?ordNum=").Append(head.OrderNumber); url.Append("&return="); //保存后跳转到添加明细页面 //下面的返回url设置用途: //1. 从添加明细页面点击返回按钮,将跳转到明细维护界面 //2. 明细维护界面再点击返回按钮,跳转到移库单主档维护页面,并且保留下从移库单主档维护页面进入新增页面时的查询条件 url.Append(WebUtil.escape("TransferLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return")))); if (log.IsDebugEnabled) { log.DebugFormat("Redirect - to添加移库明细: url={0}", url.ToString()); log.DebugFormat("返回移库明细页地址: url={0}", "TransferLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return"))); } this.Response.Redirect(url.ToString()); } head = WHTransferHead.Retrieve(session, this.OrderNumber); if (head.Status != WHTransferStatus.New) { log.WarnFormat("Warn - 保存移库单: 移库单{0}状态为{1},无法保存", head.OrderNumber, head.Status.ToString()); WebUtil.ShowMsg(this, "只有状态为新建的移库单可以修改保存!"); return; } head.Note = this.txtNote.Text.Trim(); head.FromLocation = this.drpFromLocation.SelectedValue; head.ToLocation = this.drpToLocation.SelectedValue; head.Update(session, "Note", "FromLocation", "ToLocation"); log.DebugFormat("Update - 移库单: {0}", head.OrderNumber); WebUtil.ShowMsg(this, "保存成功"); } } }
protected void MagicItemCommand(object sender, MagicItemEventArgs e) { if (e.CommandName == "Save") { using (ISession session = new Session()) { StockInHead head = null; if (this.IsNew) { head = new StockInHead(); head.OrderTypeCode = StockInHead.ORD_TYPE_ASSIST_IN; head.Status = StockInStatus.New; head.ApproveResult = ApproveStatus.UnApprove; head.ApproveUser = 0; head.ApproveTime = new DateTime(1900, 1, 1); head.CreateUser = SecuritySession.CurrentUser.UserId; head.CreateTime = DateTime.Now; head.Note = this.txtNote.Text.Trim(); head.LocationCode = this.drpLocation.SelectedValue; try { session.BeginTransaction(); head.OrderNumber = ERPUtil.NextOrderNumber(head.OrderTypeCode); head.Create(session); session.Commit(); this.txtAction.Value = "edit"; this.txtId.Value = head.OrderNumber; this.showInfo(session, head); this.setView(head); WebUtil.ShowMsg(this, string.Format("入库单{0}创建成功", head.OrderNumber)); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); } return; } head = StockInHead.Retrieve(session, this.OrderNumber); head.Note = this.txtNote.Text.Trim(); head.LocationCode = this.drpLocation.SelectedValue; head.Update(session, "Note", "LocationCode"); WebUtil.ShowMsg(this, "保存成功"); } } }
public INVCheckHead(string location, INVCheckType type, string note, int createUser) { this._orderNumber = ERPUtil.NextOrderNumber(ORDER_TYPE_CHK); this._orderTypeCode = ORDER_TYPE_CHK; this._locationCode = location; this._checkType = type; this._note = note; this._createUser = createUser; this._createTime = DateTime.Now; this._approveResult = ApproveStatus.UnApprove; this._approveUser = 0; this._approveTime = new DateTime(1900, 1, 1); this._currentLineNumber = "0000"; this._status = INVCheckStatus.New; }
protected void MagicItemCommand(object sender, MagicItemEventArgs e) { if (e.CommandName == "Save") { using (ISession session = new Session()) { ReturnHead head = null; if (this.IsNew) { head = new ReturnHead(); try { head.LogisReturn(session, this.drpLocation.SelectedValue, this.txtSNNumber.Text, Cast.Int(this.drpReason.SelectedValue, 0), this.chkIsMalicious.Checked, this.chkHasTransported.Checked, this.txtNote.Text.Trim(), SecuritySession.CurrentUser.UserId); head.OrderNumber = ERPUtil.NextOrderNumber(head.OrderTypeCode); session.BeginTransaction(); head.Create(session); session.Commit(); this.Response.Redirect("LogisReturnScan.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape("LogisReturnLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(this.ReturnUrl))); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); } return; } try { head = ReturnHead.Retrieve(session, this.OrderNumber); head.LogisReturn(session, this.drpLocation.SelectedValue, this.txtSNNumber.Text, Cast.Int(this.drpReason.SelectedValue, 0), this.chkIsMalicious.Checked, this.chkHasTransported.Checked, this.txtNote.Text.Trim(), SecuritySession.CurrentUser.UserId); session.BeginTransaction(); head.Update(session, "Note", "LocationCode", "ReasonID", "ReasonText", "IsMalicious", "RefOrderID", "RefOrderNumber", "OrginalOrderNumber", "LogisticsName", "LogisticsID", "MemberName", "MemberID", "HasTransported"); session.Commit(); WebUtil.ShowMsg(this, "保存成功"); } catch (Exception er2) { session.Rollback(); WebUtil.ShowError(this, er2); } } } }
public static RCVHead CreatePurchaseRCV(ISession session, int userId, string poNumber, string note) { RCVHead head = new RCVHead(); head._refOrderType = head._originalOrderType = POHead.ORDER_TYPE; head._refOrderNumber = head._orginalOrderNumber = poNumber.Trim().ToUpper(); #region 检查 //暂时不允许采购收货,但不引用采购订单的方式 if (string.IsNullOrEmpty(head._refOrderNumber)) { throw new Exception("采购订单为空"); } POHead po = POHead.Retrieve(session, head._refOrderNumber); if (po == null) { throw new Exception(string.Format("采购订单{0}不存在", head._refOrderNumber)); } if (po.Status != POStatus.Release) { throw new Exception(string.Format("采购订单{0}不是发布状态,不可以进行收货作业", head._refOrderNumber)); } if (po.ApproveResult != ApproveStatus.Approve) { throw new Exception(string.Format("采购订单{0}还没有完成签核,不可以进行收货作业", head._refOrderNumber)); } #endregion head._orderTypeCode = RCVHead.ORD_TYPE_PUR; head._orderNumber = ERPUtil.NextOrderNumber(head._orderTypeCode); head._objectID = po.VendorID; head._locationCode = po.LocationCode; head._createUser = userId; head._note = note.Trim(); EntityManager.Create(session, head); return(head); }
protected void MagicItemCommand(object sender, MagicItemEventArgs e) { if (e.CommandName == "Save") { using (ISession session = new Session()) { ReturnHead head = null; #region 更新退货单的情况 if (!this.IsNew) { head = ReturnHead.Retrieve(session, this.txtOrderNumber.Text.Trim()); if (head == null) { WebUtil.ShowError(this, "退货单" + this.txtOrderNumber.Text.Trim() + "不存在"); return; } if (head.Status != ReturnStatus.New) { WebUtil.ShowError(this, "退货单" + head.OrderNumber + "不是新建状态,无法更新"); return; } try { session.BeginTransaction(); if (head.OrderTypeCode == ReturnHead.ORDER_TYPE_MBR_RTN) { head.MemberReturn(session, this.drpLocation.SelectedValue, this.txtSNNumber.Text, Cast.Int(this.drpReason.SelectedValue, 0), this.chk.Checked, this.txtNote.Text.Trim(), SecuritySession.CurrentUser.UserId); head.Update(session, "Note", "LocationCode", "ReasonID", "ReasonText", "IsMalicious", "RefOrderID", "RefOrderNumber", "OrginalOrderNumber", "LogisticsName", "LogisticsID", "MemberName", "MemberID"); } else { head.ExchangeReturn(session, this.drpLocation.SelectedValue, Cast.Int(this.drpReason.SelectedValue), this.txtNote.Text, 0); head.Update(session, "Note", "LocationCode", "ReasonID", "ReasonText"); } session.Commit(); WebUtil.ShowMsg(this, "保存成功"); } catch (Exception er2) { session.Rollback(); WebUtil.ShowError(this, er2); } return; } #endregion //根据发货单查询是否存在退货单,2个作用 //1. 换货的情况下,创建换货订单同时已经创建了换货退货单,这种情况要更新一下换货退货单资料(仓库、退货原因、备注)而不用新增 //2. 目前不允许一个订单多次退货,即发货单如果已经用于创建退货单,则不再允许创建第2个了 IList <ReturnHead> heads = ReturnHead.QueryBySNNumber(session, this.txtSNNumber.Text.Trim()); #region 从来没有(会员退货、物流退货、内部退货),允许退货,以下代码创建新的会员退货单 if (heads.Count <= 0) { head = new ReturnHead(); try { head.MemberReturn(session, this.drpLocation.SelectedValue, this.txtSNNumber.Text, Cast.Int(this.drpReason.SelectedValue, 0), this.chk.Checked, this.txtNote.Text.Trim(), SecuritySession.CurrentUser.UserId); head.OrderNumber = ERPUtil.NextOrderNumber(head.OrderTypeCode); session.BeginTransaction(); head.Create(session); session.Commit(); this.Response.Redirect("MemberReturnScan.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape("MemberReturnLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(this.ReturnUrl))); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); } return; } #endregion int countOfNewChangeReturn = this.CountOfNewChangeReturn(heads); #region 新建状态的换货单,直接调出该换货单,更新其资料,更新完后跳转到退货扫描界面 //如果已经部分退货过一次,下面的代码允许继续换货 if (countOfNewChangeReturn > 0) { foreach (ReturnHead h in heads) { if (h.Status == ReturnStatus.New && h.OrderTypeCode == ReturnHead.ORDER_TYPE_EXCHANGE_RTN) { head = h; break; } } if (head != null) { try { head.ExchangeReturn(session, this.drpLocation.SelectedValue, Cast.Int(this.drpReason.SelectedValue), this.txtNote.Text.Trim(), SecuritySession.CurrentUser.UserId); session.BeginTransaction(); head.Update(session, "LocationCode", "ReasonID", "ReasonText", "Note"); session.Commit(); this.Response.Redirect("ExchangeReturnScan.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape("MemberReturnLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return")))); return; } catch (Exception er5) { session.Rollback(); WebUtil.ShowError(this, er5); } } return; } #endregion #region 如果有未完成的退货单,必须完成后才可以新建另外的退货 foreach (ReturnHead h in heads) { if (h.Status != ReturnStatus.Close) { WebUtil.ShowError(this, "与发货单" + h.RefOrderNumber + "相关的退货单" + h.OrderNumber + "还没有完成,无法创建另外的退货单"); return; } } #endregion #region 如果没有创建过任何会员退货、物流退货、内部退货,则允许创建一个(这几种退货只能退一次) if (this.IsAllChangeReturn(heads)) { head = new ReturnHead(); try { head.MemberReturn(session, this.drpLocation.SelectedValue, this.txtSNNumber.Text, Cast.Int(this.drpReason.SelectedValue, 0), this.chk.Checked, this.txtNote.Text.Trim(), SecuritySession.CurrentUser.UserId); head.OrderNumber = ERPUtil.NextOrderNumber(head.OrderTypeCode); session.BeginTransaction(); head.Create(session); session.Commit(); this.Response.Redirect("MemberReturnScan.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape("MemberReturnLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(this.ReturnUrl))); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); } return; } #endregion #region 其它情况将无法再创建会员退货单 if (this.IsNew) { WebUtil.ShowError(this, "同一个订单(发货单)不允许多次退货,系统无法再创建退货单"); return; } #endregion } } }