示例#1
0
        public void Release(ISession session)
        {
            if (this.Status != POStatus.New)
            {
                throw new Exception(string.Format("采购订单{0}不是新建状态,无法执行发布操作", this.OrderNumber));
            }
            IList <POLine> lines = session.CreateEntityQuery <POLine>()
                                   .Where(Exp.Eq("OrderNumber", this.OrderNumber))
                                   .List <POLine>();

            if (lines == null || lines.Count <= 0)
            {
                throw new Exception(string.Format("采购订单{0}没有明细,不能发布", this.OrderNumber));
            }
            System.Text.StringBuilder builder = new System.Text.StringBuilder();
            foreach (POLine line in lines)
            {
                if (line.PurchaseQty <= 0M || line.Price <= 0M)
                {
                    builder.Append("行").Append(line.LineNumber).Append("无效的数量或价格, ");
                }
            }
            if (builder.Length > 0)
            {
                throw new Exception(builder.ToString());
            }
            this.Status        = POStatus.Release;
            this.ApproveResult = ApproveStatus.UnApprove;
            this.Update(session, "Status", "ApproveResult");
            ERPUtil.ApproveThis(session, this); //送签单据
        }
示例#2
0
        public void Release(ISession session)
        {
            #region 检查
            if (this.OrderTypeCode == ORDER_TYPE_CHK && this._status != INVCheckStatus.Confirm)
            {
                throw new Exception("状态为确认的盘点单才可以执行发布操作");
            }
            if (this.OrderTypeCode == ORDER_TYPE_ADJ && this._status != INVCheckStatus.New)
            {
                throw new Exception("新建状态的库存调整单才可以执行发布操作");
            }
            if (session.CreateEntityQuery <INVCheckLine>()
                .Where(Exp.Eq("OrderNumber", this._orderNumber))
                .SetLastOffset(1)
                .Count() <= 0)
            {
                throw new Exception("没有明细,无法执行发布操作");
            }
            #endregion

            this._status        = INVCheckStatus.Release;
            this._approveResult = ApproveStatus.UnApprove;
            this.Update(session, "Status", "ApproveResult");
            ERPUtil.ApproveThis(session, this);
        }
示例#3
0
 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);
     }
 }
示例#4
0
    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, "保存成功");
            }
        }
    }
示例#5
0
 public void Close(ISession session)
 {
     if (this._status != INVCheckStatus.Release || this._approveResult != ApproveStatus.Approve)
     {
         throw new Exception("只有发布后的盘点单能够执行关闭操作");
     }
     ERPUtil.CommitWHTrans(session, this);
     this._status = INVCheckStatus.Close;
     this.Update(session, "Status");
 }
示例#6
0
 public void Close(ISession session)
 {
     if (this.Status != ReturnStatus.Open)
     {
         throw new Exception("退货单不是待入库状态,无法执行该操作");
     }
     this.Status = ReturnStatus.Close;
     this.Update(session, "Status");
     ERPUtil.CommitWHTrans(session, 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")));
            }
        }
    }
 public void Close(ISession session)
 {
     if (this.Status != WHTransferStatus.Open)
     {
         log.ErrorFormat("移库单{0}不是待移库状态,无法执行关闭操作", this.OrderNumber);
         throw new Exception(string.Format("移库单{0}不是待移库状态,无法执行关闭操作", this.OrderNumber));
     }
     this.Status = WHTransferStatus.Close;
     this.Update(session, "Status");
     ERPUtil.CommitWHTrans(session, this);
 }
示例#9
0
    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, "保存成功");
            }
        }
    }
示例#10
0
    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")));
            }
        }
    }
 private IList <WHArea> GetArea(ISession session)
 {
     if (session == null)
     {
         return(new List <WHArea>(0));
     }
     if (this._area == null)
     {
         this._area = ERPUtil.GetWHArea(session, WHTransferHead.ORDER_TYPE_NORMAL, "403", this._head.ToLocation);
     }
     return(this._area);
 }
示例#12
0
 private IList <WHArea> GetAreas()
 {
     if (this._session == null && this._areas == null)
     {
         return(new List <WHArea>());
     }
     if (this._areas == null)
     {
         this._areas = ERPUtil.GetWHArea(this._session, this._head == null ? "X" : this._head.OrderTypeCode, null);
     }
     return(this._areas);
 }
示例#13
0
    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;
        }
    }
示例#14
0
 private IList <WHArea> GetAreas()
 {
     if (this._session == null && this._areas == null)
     {
         return(new List <WHArea>());
     }
     if (this._areas == null)
     {
         this._areas = ERPUtil.GetWHArea(this._session, StockInHead.ORD_TYPE_ASSIST_IN, null);
     }
     return(this._areas);
 }
示例#15
0
    private void showInfo(ISession session, WHTransferHead head)
    {
        User user;

        if (head != null)
        {
            this.txtOrderNumber.Text = head.OrderNumber;
            this.txtNote.Text        = head.Note;
            if (!string.IsNullOrEmpty(head.FromLocation))
            {
                this.drpFromLocation.SelectedValue = head.FromLocation;
            }
            if (!string.IsNullOrEmpty(head.ToLocation))
            {
                this.drpToLocation.SelectedValue = head.ToLocation;
            }

            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;
        }
    }
 private IList <WHArea> GetAreas()
 {
     if (this._session == null && this._areas == null)
     {
         return(new List <WHArea>());
     }
     if (this._areas == null)
     {
         this._areas = ERPUtil.GetWHArea(this._session, POReturnHead.ORD_TYPE_CODE, null);
     }
     return(this._areas);
 }
示例#17
0
    private void SetView(ISession session, INVCheckHead head)
    {
        if (!this.IsNew)
        {
            WebUtil.DisableControl(this.drpLocation);
        }
        if (head != null)
        {
            if (!string.IsNullOrEmpty(head.LocationCode) && head.LocationCode.Trim().Length > 0)
            {
                WHLocation location = WHLocation.Retrieve(session, head.LocationCode);
                this.drpLocation.Items.Clear();
                this.drpLocation.Items.Add(new ListItem(location.Name, location.LocationCode));
            }
            this.drpCheckType.SelectedValue = head.CheckType.ToString();
            this.txtMemo.Text = head.Note;
            OrderStatusDef statusDef = OrderStatusDef.Retrieve(session, INVCheckHead.ORDER_TYPE_CHK, (int)head.Status);
            if (statusDef != null)
            {
                this.lblStatus.Text = statusDef.StatusText;
            }
            Magic.Sys.User user = null;
            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);
            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;

            if (head.Status != INVCheckStatus.New)
            {
                WebUtil.DisableControl(this.txtMemo);
                WebUtil.DisableControl(this.drpCheckType);
                this.cmdSave.Visible = false;
            }
        }
    }
示例#18
0
        public void Close(ISession session, bool throwException)
        {
            if (this._status != ReceiveStatus.Open)
            {
                log.ErrorFormat("收货单{0}不是待发货状态,无法执行关闭操作", this._orderNumber);
                if (throwException)
                {
                    throw new Exception(string.Format("收货单{0}不是待发货状态,无法执行关闭操作", this._orderNumber));
                }
                return;
            }

            //签核完成后会调用这个方法,尝试将收货单自动关闭,如果这个方法发生异常,签核处理正常完成,需要手工来关闭这个单据
            //签核完成的关闭动作将新开一个session来完成,确保关闭时的异常不会影响签核操作的结束;手工关闭时由界面开session来执行这个方法
            try
            {
                //库存交易
                ERPUtil.CommitWHTrans(session, this);
                //更新PO行的冗余字段值
                if (this._orderTypeCode == RCVHead.ORD_TYPE_PUR &&
                    !string.IsNullOrEmpty(this._refOrderNumber) && this._refOrderNumber.Trim().Length > 0)
                {
                    IList <RCVLine> rcvLines = session.CreateEntityQuery <RCVLine>()
                                               .Where(Exp.Eq("OrderNumber", this._orderNumber))
                                               .OrderBy("LineNumber")
                                               .List <RCVLine>();
                    foreach (RCVLine rcv in rcvLines)
                    {
                        if (!string.IsNullOrEmpty(rcv.RefOrderLine) && rcv.RefOrderLine.Trim().Length > 0)
                        {
                            POLine poLine = POLine.Retrieve(session, this._refOrderNumber, rcv.RefOrderLine);
                            if (poLine != null)
                            {
                                poLine.ReceiveFinish(session, rcv.RCVTotalQty, rcv.QualifiedQty);
                            }
                        }
                    }
                }
                //更新本身状态
                this._status = ReceiveStatus.Close;
                this.Update(session, "Status");
            }
            catch (Exception er)
            {
                log.Error(string.Format("收货单{0}关闭时发生异常", this._orderNumber), er);
                if (throwException)
                {
                    throw er;
                }
            }
        }
示例#19
0
        public void WHTransactionDo(ISession session)
        {
            SOHead saleOrder = SOHead.Retrieve(session, this._saleOrderID);

            if (saleOrder.OrderType == SaleOrderType.Exchange)
            {
                this._orderTypeCode = ORDER_TYPE_CODE_ED;
            }
            else
            {
                this._orderTypeCode = ORDER_TYPE_CODE_SD;
            }
            ERPUtil.CommitWHTrans(session, this);
        }
示例#20
0
    private void showInfo(ISession session, ReturnHead head)
    {
        User user;

        if (head != null)
        {
            this.txtOrderNumber.Text       = head.OrderNumber;
            this.drpLocation.SelectedValue = head.LocationCode;
            this.txtSNNumber.Text          = head.RefOrderNumber;
            this.drpReason.SelectedValue   = head.ReasonID.ToString();
            this.chkIsMalicious.Checked    = head.IsMalicious;
            this.chkHasTransported.Checked = head.HasTransported;
            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())
            {
                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, "保存成功");
            }
        }
    }
示例#22
0
 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;
 }
示例#23
0
        public void Confirm(ISession session)
        {
            if (this._status != StockInStatus.Confirm)
            {
                throw new Exception("单据不是发布状态,无法审批入库价格");
            }

            if (this.OrderTypeCode != StockInHead.ORD_TYPE_PRD_IN)
            {
                throw new Exception(this.OrderNumber + "不是产品入库单");
            }
            this._status = StockInStatus.Release;
            this.Update(session, "Status");
            ERPUtil.ApproveThis(session, this);
        }
示例#24
0
        public void Release(ISession session)
        {
            #region 检查
            if (this._status != StockInStatus.New)
            {
                throw new Exception("单据不是新建状态,无法发布");
            }
            IList <StockInLine> lines = session.CreateEntityQuery <StockInLine>()
                                        .Where(Exp.Eq("OrderNumber", this._orderNumber))
                                        .OrderBy("LineNumber")
                                        .List <StockInLine>();
            System.Text.StringBuilder builder = new System.Text.StringBuilder();
            if (lines.Count <= 0)
            {
                builder.Append("单据").Append(this._orderNumber).Append("没有明细,无法发布");
            }
            else
            {
                foreach (StockInLine line in lines)
                {
                    if (string.IsNullOrEmpty(line.AreaCode) || line.AreaCode.Trim().Length <= 0)
                    {
                        builder.Append("行号").Append(line.LineNumber).Append("仓库无效; ");
                    }
                    if (line.Quantity <= 0)
                    {
                        builder.Append("行号").Append(line.LineNumber).Append("数量无效; ");
                    }
                }
            }
            if (builder.Length > 0)
            {
                throw new Exception(builder.ToString());
            }
            #endregion

            if (this.OrderTypeCode != StockInHead.ORD_TYPE_PRD_IN)
            {
                this._status = StockInStatus.Release;
                ERPUtil.ApproveThis(session, this);
            }
            //产品入库单,发布后需要填写价格再走签核、入库处理流程
            else
            {
                this._status = StockInStatus.Confirm;
            }
            this.Update(session, "Status");
        }
    protected void rptSDHead_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        System.Data.DataRowView drv = e.Item.DataItem as System.Data.DataRowView;
        if (drv == null)
        {
            return;
        }
        INVCheckStatus status = Cast.Enum <INVCheckStatus>(drv["Status"]);

        if (status != INVCheckStatus.New)
        {
            HtmlInputCheckBox chk = e.Item.FindControl("checkbox") as HtmlInputCheckBox;
            if (chk == null)
            {
                return;
            }
            chk.Visible = false;
        }
        HtmlAnchor cmd = e.Item.FindControl("cmdDetail") as HtmlAnchor;

        if (status == INVCheckStatus.New)
        {
            cmd.Visible = false;
        }
        else
        {
            cmd.HRef = "javascript:ondetail('" + Cast.String(drv["OrderNumber"]) + "');";
        }
        Label         lblApprStatus = e.Item.FindControl("lblApprStatus") as Label;
        ApproveStatus apprStatus    = Cast.Enum <ApproveStatus>(drv["ApproveResult"]);

        lblApprStatus.Text = ERPUtil.EnumText <ApproveStatus>(apprStatus);
        switch (apprStatus)
        {
        case ApproveStatus.UnApprove:
            lblApprStatus.Text = "";
            break;

        case ApproveStatus.Approve:
            lblApprStatus.ForeColor = System.Drawing.Color.Blue;
            break;

        case ApproveStatus.Reject:
            lblApprStatus.ForeColor = System.Drawing.Color.Red;
            break;
        }
    }
示例#26
0
    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);
                }
            }
        }
    }
示例#27
0
 public void Release(ISession session)
 {
     if (this._status != InterchangeStatus.New)
     {
         throw new Exception("交接单" + this._orderNumber + "不是新建状态,无法发布");
     }
     if (session.CreateEntityQuery <ICLine>()
         .Where(Exp.Eq("OrderNumber", this._orderNumber))
         .Count() <= 0)
     {
         throw new Exception("交接单没有明细,无法发布");
     }
     this._status        = InterchangeStatus.Release;
     this._approveResult = ApproveStatus.UnApprove;
     this.Update(session, "Status", "ApproveResult");
     ERPUtil.ApproveThis(session, this);
 }
示例#28
0
        public void Release(ISession session)
        {
            if (this.Status != POReturnStatus.New)
            {
                throw new Exception("退货单不是新建状态,无法发布");
            }
            int count = session.CreateEntityQuery <POReturnLine>()
                        .Where(Exp.Eq("OrderNumber", this.OrderNumber))
                        .Count();

            if (count <= 0)
            {
                throw new Exception("退货单没有退货明细,无法发布");
            }
            this.Status = POReturnStatus.Release;
            this.Update(session, "Status");
            ERPUtil.ApproveThis(session, this);
        }
        public void Release(ISession session)
        {
            if (this.Status != WHTransferStatus.New)
            {
                log.WarnFormat("移库单{0}不是新建状态,无法执行发布操作", this.OrderNumber);
                throw new Exception(string.Format("移库单{0}不是新建状态,无法执行发布操作", this.OrderNumber));
            }
            IList <WHTransferLine> lines = session.CreateEntityQuery <WHTransferLine>()
                                           .Where(Exp.Eq("OrderNumber", this.OrderNumber))
                                           .List <WHTransferLine>();

            if (lines.Count <= 0)
            {
                log.ErrorFormat("移库单{0}没有明细,无法执行发布操作", this.OrderNumber);
                throw new Exception(string.Format("移库单{0}没有明细,无法执行发布操作", this.OrderNumber));
            }
            this.Status = WHTransferStatus.Release;
            this.Update(session, "Status");
            ERPUtil.ApproveThis(session, this);
        }
示例#30
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         log.DebugFormat("PageLoad - to add assist item req line: ordNum={0}, return={1}", this.OrderNumber, WebUtil.Param("return"));
         this.toolbarTop["Return"].NavigateUrl = this.toolbarBottom["Return"].NavigateUrl = WebUtil.Param("return");
         using (ISession session = new Session())
         {
             StockInHead head = StockInHead.Retrieve(session, this.OrderNumber);
             this.drpArea.Items.Clear();
             this.drpArea.Items.Add(new ListItem("", ""));
             IList <WHArea> areas = ERPUtil.GetWHArea(session, StockInHead.ORD_TYPE_ASSIST_OUT, null, head.LocationCode);
             foreach (WHArea area in areas)
             {
                 this.drpArea.Items.Add(new ListItem(area.AreaCode, area.AreaCode));
             }
             this.QueryAndBindData(session, 1, this.magicPagerMain.PageSize, true);
         }
     }
 }