コード例 #1
0
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        try
        {
            if (e.CommandName == "Add" && !string.IsNullOrEmpty(this.drpArea.SelectedValue))
            {
                #region 添加库位
                using (ISession session = new Session())
                {
                    INVCheckHead head = INVCheckHead.Retrieve(session, this.OrderNumber);
                    try
                    {
                        session.BeginTransaction();
                        head.AddArea(session, this.drpArea.SelectedValue);
                        session.Commit();

                        this.BindArea(session, head);
                        this.QueryAndBindData(session, head);
                    }
                    catch (Exception er1)
                    {
                        session.Rollback();
                        WebUtil.ShowError(this, er1);
                        return;
                    }
                }
                #endregion
            }
            else if (e.CommandName == "Confirm")
            {
                #region 确定开始盘点作业
                bool success = false;
                using (ISession session = new Session())
                {
                    INVCheckHead head = INVCheckHead.Retrieve(session, this.OrderNumber);
                    try
                    {
                        session.BeginTransaction();
                        head.ConfirmCheckOrder(session);
                        session.Commit();
                        success = true;
                    }
                    catch (Exception er1)
                    {
                        session.Rollback();
                        WebUtil.ShowError(this, er1);
                        return;
                    }
                }
                #endregion
                if (success)
                {
                    this.Response.Redirect("InventoryCheckDetail.aspx?ordNum=" + this.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return")));
                }
            }
        }
        catch (Exception er)
        {
            WebUtil.ShowError(this, er);
        }
    }