Exemplo n.º 1
0
    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, "保存成功");
            }
        }
    }
Exemplo n.º 2
0
    //弹出选择框,手工选择采购订单明细进行收货的方式
    //这种方式暂时废弃不用
    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);
        }
    }