protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.txtRCVNumber.Value = this.OrderNumber; if (log.IsDebugEnabled) { log.Debug("PageLoad - rcv line: ordNum=" + this.OrderNumber + " return=" + WebUtil.Param("return")); log.Debug("url for scan to return: " + "PurchaseRCVLine.aspx?ordNum=" + this.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return"))); } this.txtReturnUrl.Value = "PurchaseRCVLine.aspx?ordNum=" + this.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return")); this.cmdReturn1["Return"].NavigateUrl = this.cmdReturn2["Return"].NavigateUrl = WebUtil.Param("return"); using (ISession session = new Session()) { RCVHead head = RCVHead.Retrieve(session, this.OrderNumber); this.txtStatus.Value = head.Status.ToString(); this.SetView(head); if (!string.IsNullOrEmpty(head.RefOrderNumber) && head.RefOrderNumber.Trim().Length > 0) { this.txtPONumber.Value = head.RefOrderNumber; } this.QueryAndBindData(session, head); } } }
private void showInfo(ISession session, RCVHead head) { User user; if (head != null) { this.txtOrderNumber.Text = head.OrderNumber; this.txtPONumber.Value = head.RefOrderNumber; if (head.ObjectID > 0) { Vendor ven = Vendor.Retrieve(session, head.ObjectID); if (ven != null) { this.lblVendor.Text = ven.ShortName; } } this.txtNote.Text = head.Note; OrderStatusDef statusDef = OrderStatusDef.Retrieve(session, head.OrderTypeCode, (int)head.Status); if (statusDef != null) { this.lblStatus.Text = statusDef.StatusText; } if (head.CreateUser > 0) { user = Magic.Sys.User.Retrieve(session, head.CreateUser); if (user != null) { this.lblUser.Text = user.FullName; } } this.lblCreateTime.Text = RenderUtil.FormatDatetime(head.CreateTime); this.lblApproveResult.Text = ERPUtil.EnumText <ApproveStatus>(head.ApproveResult); switch (head.ApproveResult) { case ApproveStatus.Reject: this.lblApproveResult.ForeColor = System.Drawing.Color.Red; break; case ApproveStatus.Approve: this.lblApproveResult.ForeColor = System.Drawing.Color.Blue; break; } if (head.ApproveResult == ApproveStatus.Approve || head.ApproveResult == ApproveStatus.Reject) { if (head.ApproveUser > 0) { user = Magic.Sys.User.Retrieve(session, head.ApproveUser); if (user != null) { this.lblApproveUser.Text = user.FullName; } } this.lblApproveTime.Text = RenderUtil.FormatDatetime(head.ApproveTime); } this.txtApproveNote.Text = head.ApproveNote; } }
protected void MagicItemCommand(object sender, MagicItemEventArgs e) { if (e.CommandName == "Save") { using (ISession session = new Session()) { RCVHead head = null; if (this.IsNew) { int lineCount = 0; try { session.BeginTransaction(); head = RCVHead.CreatePurchaseRCV(session, SecuritySession.CurrentUser.UserId, this.txtPONumber.Value, this.txtNote.Text); if (this.rdoAutoCreateLines.Checked) { lineCount = head.AddLinesFromRefOrder(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}创建成功{1}", head.OrderNumber, this.rdoAutoCreateLines.Checked ? ",自动创建了" + lineCount.ToString() + "个收货明细" : "")); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); } return; } head = RCVHead.Retrieve(session, this.OrderNumber); head.Note = this.txtNote.Text.Trim(); head.Update(session, "Note"); WebUtil.ShowMsg(this, "保存成功"); } } }
private void SetView(RCVHead head) { switch (head.Status) { case ReceiveStatus.New: this.cmdEdit1.Visible = true; this.cmdEdit2.Visible = true; this.cmdClose1.Visible = false; this.cmdClose2.Visible = false; this.cmdPrint1.Visible = false; this.cmdPrint2.Visible = false; break; case ReceiveStatus.Release: this.cmdEdit1.Visible = false; this.cmdEdit2.Visible = false; this.cmdClose1.Visible = false; this.cmdClose2.Visible = false; this.cmdPrint1.Visible = true; this.cmdPrint2.Visible = true; break; case ReceiveStatus.Open: this.cmdEdit1.Visible = false; this.cmdEdit2.Visible = false; this.cmdClose1.Visible = true; this.cmdClose2.Visible = true; this.cmdPrint1.Visible = true; this.cmdPrint2.Visible = true; break; case ReceiveStatus.Close: this.cmdEdit1.Visible = false; this.cmdEdit2.Visible = false; this.cmdClose1.Visible = false; this.cmdClose2.Visible = false; this.cmdPrint1.Visible = true; this.cmdPrint2.Visible = true; break; } }
protected void MagicItemCommand(object sender, MagicItemEventArgs e) { using (ISession session = new Session()) { bool deleted = false; try { session.BeginTransaction(); foreach (RepeaterItem item in this.repeatControl.Items) { HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox; if (chk.Checked && chk.Value.Trim().Length > 0) { RCVHead head = RCVHead.Retrieve(session, chk.Value.Trim()); if (head == null || head.Status != ReceiveStatus.New) { continue; } head.Delete(session); session.CreateEntityQuery <RCVLine>() .Where(Exp.Eq("OrderNumber", head.OrderNumber)) .Delete(); deleted = true; } } session.Commit(); if (deleted) { WebUtil.ShowMsg(this, "选择的收货单已经删除"); this.QueryAndBindData(session, this.magicPagerMain.CurrentPageIndex, this.magicPagerMain.PageSize, true); } } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); } } }
private void QueryAndBindData(ISession session, RCVHead head) { this.repeatControl.DataSource = session.CreateObjectQuery(@" select l.LineNumber as LineNumber,l.RefOrderLine as RefOrderLine ,s.BarCode as BarCode,m.ItemCode as ItemCode,m.ItemName as ItemName,s.ColorCode as ColorCode,color.ColorText as ColorText,s.SizeCode as SizeCode ,l.AreaCode as AreaCode,l.SectionCode as SectionCode,l.RCVTotalQty as RCVTotalQty,l.QualifiedQty as QualifiedQty from RCVLine l inner join ItemSpec s on l.SKUID=s.SKUID inner join ItemMaster m on m.ItemID=s.ItemID left join ItemColor color on color.ColorCode=s.ColorCode where l.OrderNumber=?ordNum order by l.LineNumber") .Attach(typeof(RCVLine)).Attach(typeof(ItemSpec)).Attach(typeof(ItemMaster)).Attach(typeof(ItemColor)) .SetValue("?ordNum", this.OrderNumber, "l.OrderNumber") .DataSet(); this._session = session; this._head = head; this.repeatControl.DataBind(); this._head = null; this._session = null; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.txtAction.Value = WebUtil.Param("mode"); this.txtId.Value = WebUtil.Param("ordNumber"); RCVHead head = null; using (ISession session = new Session()) { if (!this.IsNew) { head = RCVHead.Retrieve(session, this.OrderNumber); this.showInfo(session, head); } else { //this.rdoAutoCreateLines.Checked = true; } } this.setView(head); } }
private void setView(RCVHead head) { if (this.IsNew) { this.cmdDetail.Visible = false; } else { WebUtil.DisableControl(this.txtPONumber); this.cmdSelectPO.Visible = false; this.trAutoCreate.Visible = false; this.cmdDetail.Visible = true; this.cmdDetail["Detail"].NavigateUrl = "PurchaseRCVLine.aspx?ordNum=" + this.OrderNumber + "&return=" + Microsoft.JScript.GlobalObject.escape(this.ReturnUrl); if (head != null && head.Status != ReceiveStatus.New) { this.cmdEdit.Visible = false; WebUtil.DisableControl(this.txtNote); } } this.trAutoCreate.Visible = false; this.cmdReturn["Return"].NavigateUrl = this.ReturnUrl; }
//弹出选择框,手工选择采购订单明细进行收货的方式 //这种方式暂时废弃不用 protected void cmdAddLines_Click(object sender, EventArgs e) { string[] linesArray = this.txtPOLines.Value.Trim().Trim(';').Split(';'); if (linesArray == null || linesArray.Length <= 0) { return; } using (ISession session = new Session()) { RCVHead head = RCVHead.Retrieve(session, this.OrderNumber); try { session.BeginTransaction(); foreach (string s in linesArray) { POLine poLine = null; if (!string.IsNullOrEmpty(s) && s.Trim().Length > 0) { poLine = POLine.Retrieve(session, head.RefOrderNumber, s); } if (poLine != null) { head.AddLine(session, poLine); } } head.Update(session, "CurrentLineNumber"); session.Commit(); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); } this.QueryAndBindData(session, head); } }
internal static IApprovable GetApproveItem(ISession session, string orderType, string orderNumber) { switch (orderType) { case POHead.ORDER_TYPE: //采购订单 return(POHead.Retrieve(session, orderNumber)); case RCVHead.ORD_TYPE_PUR: //采购收货 return(RCVHead.Retrieve(session, orderNumber)); case POReturnHead.ORD_TYPE_CODE: //采购退货 return(POReturnHead.Retrieve(session, orderNumber)); case ICHead.ORDER_TYPE: //交接单 return(ICHead.Retrieve(session, orderNumber)); case INVCheckHead.ORDER_TYPE_ADJ: //库存调整单 case INVCheckHead.ORDER_TYPE_CHK: //库房盘点 return(INVCheckHead.Retrieve(session, orderNumber)); case StockInHead.ORD_TYPE_ASSIST_IN: //辅料入库 case StockInHead.ORD_TYPE_ASSIST_OUT: //辅料领用 case StockInHead.ORD_TYPE_PRD_IN: //产品入库 case StockInHead.ORD_TYPE_PRD_OUT: //产品领用 return(StockInHead.Retrieve(session, orderNumber)); case ReturnHead.ORDER_TYPE_MBR_RTN: //会员退货 case ReturnHead.ORDER_TYPE_LOGISTICS_RTN: //物流退货 case ReturnHead.ORDER_TYPE_INNER_RTN: //内部退货 case ReturnHead.ORDER_TYPE_EXCHANGE_RTN: //会员换货 return(ReturnHead.Retrieve(session, orderNumber)); case WHTransferHead.ORDER_TYPE_NORMAL: //移库单 return(WHTransferHead.Retrieve(session, orderNumber)); } throw new Exception(string.Format("Order type {0} is not a registered approvable item", orderType)); }
protected void MagicItemCommand(object sender, MagicItemEventArgs e) { if (e.CommandName == "Save") { #region 保存 //这个功能也暂时废弃不用,因为采用扫描入库方式,并且需要控制货架、库位容量 IList <RCVLine> linesToSave = new List <RCVLine>(); foreach (RepeaterItem item in this.repeatControl.Items) { HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox; TextBox text; RCVLine line = new RCVLine(); line.OrderNumber = this.OrderNumber; line.LineNumber = chk.Value.Trim(); text = item.FindControl("txtQualifiedQty") as TextBox; line.QualifiedQty = Cast.Decimal(text.Text.Trim()); line.RCVTotalQty = line.QualifiedQty; linesToSave.Add(line); } using (ISession session = new Session()) { try { //检查 RCVHead head = RCVHead.Retrieve(session, this.OrderNumber); if (head == null) { return; } head.UpdateLines(session, linesToSave); WebUtil.ShowMsg(this, "保存成功"); } catch (Exception er) { WebUtil.ShowError(this, er); } } #endregion } else if (e.CommandName == "Delete") { #region 除 using (ISession session = new Session()) { IList <RCVLine> linesToDelete = new List <RCVLine>(); foreach (RepeaterItem item in this.repeatControl.Items) { HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox; if (chk.Checked) { RCVLine line = RCVLine.Retrieve(session, this.OrderNumber, chk.Value.Trim()); if (line != null) { linesToDelete.Add(line); } } } try { //检查 RCVHead head = RCVHead.Retrieve(session, this.OrderNumber); if (head == null) { return; } session.BeginTransaction(); head.DeleteLines(session, linesToDelete); session.Commit(); this.QueryAndBindData(session, head); WebUtil.ShowMsg(this, "选择的明细已经删除"); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); } } #endregion } else if (e.CommandName == "Release") { #region 发布 using (ISession session = new Session()) { try { session.BeginTransaction(); RCVHead head = RCVHead.Retrieve(session, this.OrderNumber); head.Release(session); session.Commit(); WebUtil.ShowMsg(this, "发布成功"); this.QueryAndBindData(session, head); this.SetView(head); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); } } #endregion } else if (e.CommandName == "Close") { #region 关闭 using (ISession session = new Session()) { try { RCVHead head = RCVHead.Retrieve(session, this.OrderNumber); session.BeginTransaction(); head.Close(session, true); session.Commit(); WebUtil.ShowMsg(this, "发布成功"); this.QueryAndBindData(session, head); this.SetView(head); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); } } #endregion } }