Esempio n. 1
0
    private void SaveSaleDeliver()
    {
        try
        {
            using (_session = new Session())
            {
                if (Magic.ERP.Orders.EDHead.Retrieve(_session, this.txtSaleDeliver.Text).Status != Magic.ERP.DeliverStatus.New)
                {
                    WebUtil.ShowMsg(this, "只有状态为新建的换货发货单才可以修改保存!");
                    return;
                }
            }

            List <Magic.ERP.Orders.SDLine> List = new List <Magic.ERP.Orders.SDLine>();
            for (int i = 0; i < this.rptSDLine.Items.Count; i++)
            {
                Magic.ERP.Orders.SDLine objLine = new Magic.ERP.Orders.SDLine();
                objLine.AreaCode    = (this.rptSDLine.Items[i].FindControl("ddlArea") as DropDownList).SelectedValue;
                objLine.SectionCode = (this.rptSDLine.Items[i].FindControl("ddlSection") as DropDownList).SelectedValue;
                objLine.OrderNumber = this.txtSaleDeliver.Text;
                objLine.LineNumber  = (this.rptSDLine.Items[i].FindControl("tdLineNumber") as System.Web.UI.HtmlControls.HtmlTableCell).InnerText.Replace("\r\n", "").Trim();
                if (objLine.AreaCode.Trim().Length == 0)
                {
                    WebUtil.ShowMsg(this, "发货单明细" + objLine.LineNumber + "的仓库区域不能为空,请重新输入!", "保存失败");
                    return;
                }
                List.Add(objLine);
            }

            using (_session = new Session())
            {
                _session.BeginTransaction();
                try
                {
                    for (int i = 0; i < List.Count; i++)
                    {
                        EntityManager.Update(_session, List[i], "AreaCode", "SectionCode");
                    }
                    _session.Commit();
                }
                catch (Exception ex)
                {
                    _session.Rollback();
                    throw ex;
                }
            }

            WebUtil.ShowMsg(this, "发货单保存成功", "操作成功");
        }
        catch (Exception ex)
        {
            logger.Info("保存发货单", ex);
            WebUtil.ShowMsg(this, "发生未处理的异常,请刷新页面重新操作,或者联系系统管理员");
        }
    }
    private void SaveSaleDeliver()
    {
        try
        {
            using (_session = new Session())
            {
                if (Magic.ERP.Orders.EDHead.Retrieve(_session, this.txtSaleDeliver.Text).Status != Magic.ERP.DeliverStatus.New)
                {
                    WebUtil.ShowMsg(this, "只有状态为新建的换货发货单才可以修改保存!");
                    return;
                }
            }

            List<Magic.ERP.Orders.SDLine> List = new List<Magic.ERP.Orders.SDLine>();
            for (int i = 0; i < this.rptSDLine.Items.Count; i++)
            {
                Magic.ERP.Orders.SDLine objLine = new Magic.ERP.Orders.SDLine();
                objLine.AreaCode = (this.rptSDLine.Items[i].FindControl("ddlArea") as DropDownList).SelectedValue;
                objLine.SectionCode = (this.rptSDLine.Items[i].FindControl("ddlSection") as DropDownList).SelectedValue;
                objLine.OrderNumber = this.txtSaleDeliver.Text;
                objLine.LineNumber = (this.rptSDLine.Items[i].FindControl("tdLineNumber") as System.Web.UI.HtmlControls.HtmlTableCell).InnerText.Replace("\r\n","").Trim();
                if (objLine.AreaCode.Trim().Length == 0)
                {
                    WebUtil.ShowMsg(this, "发货单明细"+objLine.LineNumber+"的仓库区域不能为空,请重新输入!", "保存失败");
                    return;
                }
                List.Add(objLine);
            }

            using (_session = new Session())
            {
                _session.BeginTransaction() ;
                try
                {
                    for (int i = 0; i < List.Count; i++)
                    {
                        EntityManager.Update(_session, List[i], "AreaCode", "SectionCode");
                    }
                    _session.Commit();
                }
                catch (Exception ex)
                {
                    _session.Rollback();
                    throw ex;
                }
            }

            WebUtil.ShowMsg(this, "发货单保存成功", "操作成功");
        }
        catch (Exception ex)
        {
            logger.Info("保存发货单", ex);
            WebUtil.ShowMsg(this, "发生未处理的异常,请刷新页面重新操作,或者联系系统管理员");
        }
    }