Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.txtId.Value = WebUtil.Param("ordNumber");

            StockInHead head = null;
            using (ISession session = new Session())
            {
                IList <WHLocation> locations = session.CreateEntityQuery <WHLocation>()
                                               .Where(Magic.Framework.ORM.Query.Exp.Eq("Status", WHStatus.Enable))
                                               .OrderBy("LocationCode")
                                               .List <WHLocation>();
                this.drpLocation.Items.Clear();
                foreach (WHLocation loc in locations)
                {
                    this.drpLocation.Items.Add(new ListItem(loc.Name, loc.LocationCode));
                }

                head = StockInHead.Retrieve(session, this.OrderNumber);
                this.showInfo(session, head);
            }
            this.setView(head);
        }
    }
    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 != null && chk.Checked && chk.Value.Trim().Length > 0)
                    {
                        StockInHead.Delete(session, chk.Value.Trim());
                        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);
            }
        }
    }
Exemplo n.º 3
0
 protected void MagicItemCommand(object sender, MagicItemEventArgs e)
 {
     using (ISession session = new Session())
     {
         try
         {
             StockInHead head = StockInHead.Retrieve(session, this.OrderNumber);
             string      msg  = "";
             session.BeginTransaction();
             if (e.CommandName == "Save")
             {
                 this.Save(session, head);
                 msg = "保存成功";
             }
             else if (e.CommandName == "Release")
             {
                 this.Confirm(session, head);
                 msg = "入库价格审核完成";
             }
             session.Commit();
             this.QueryAndBindData(session, head);
             this.SetView(head);
             WebUtil.ShowMsg(this, msg);
         }
         catch (Exception er)
         {
             session.Rollback();
             WebUtil.ShowError(this, er);
         }
     }
 }
Exemplo n.º 4
0
    protected void cmdAddLines_Click(object sender, EventArgs e)
    {
        string[] linesArray = this.txtSkus.Value.Trim().Trim(';').Split(';');
        if (linesArray == null || linesArray.Length <= 0)
        {
            return;
        }

        using (ISession session = new Session())
        {
            StockInHead head = StockInHead.Retrieve(session, this.OrderNumber);
            if (head == null)
            {
                return;
            }
            try
            {
                session.BeginTransaction();
                head.AddLines(session, linesArray);
                session.Commit();
                this.QueryAndBindData(session, head);
            }
            catch (Exception er)
            {
                session.Rollback();
                WebUtil.ShowError(this, er);
            }
        }
    }
Exemplo n.º 5
0
    private void SetView(StockInHead head)
    {
        switch (head.Status)
        {
        case StockInStatus.New:
            this.cmdEdit1.Visible  = true;
            this.cmdEdit2.Visible  = true;
            this.cmdClose1.Visible = false;
            this.cmdClose2.Visible = false;
            break;

        case StockInStatus.Release:
            this.cmdEdit1.Visible  = false;
            this.cmdEdit2.Visible  = false;
            this.cmdClose1.Visible = false;
            this.cmdClose2.Visible = false;
            break;

        case StockInStatus.Open:
            this.cmdEdit1.Visible  = false;
            this.cmdEdit2.Visible  = false;
            this.cmdClose1.Visible = true;
            this.cmdClose2.Visible = true;
            break;

        case StockInStatus.Close:
            this.cmdEdit1.Visible  = false;
            this.cmdEdit2.Visible  = false;
            this.cmdClose1.Visible = false;
            this.cmdClose2.Visible = false;
            break;
        }
    }
Exemplo n.º 6
0
 private void Confirm(ISession session, StockInHead head)
 {
     if (head == null)
     {
         return;
     }
     head.Confirm(session);
 }
Exemplo n.º 7
0
 private void setView(StockInHead head)
 {
     WebUtil.DisableControl(this.txtNote);
     WebUtil.DisableControl(this.drpLocation);
     this.cmdDetail.Visible = true;
     this.cmdDetail["Detail"].NavigateUrl = "ProductInLine.aspx?ordNum=" + this.OrderNumber + "&return=" + WebUtil.escape(this.ReturnUrl);
     this.cmdReturn["Return"].NavigateUrl = this.ReturnUrl;
 }
Exemplo n.º 8
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")));
            }
        }
    }
Exemplo n.º 9
0
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName != "Save")
        {
            return;
        }

        using (ISession session = new Session())
        {
            try
            {
                IList <StockInLine> lines = new List <StockInLine>();
                StockInHead         head  = StockInHead.Retrieve(session, this.OrderNumber);
                foreach (RepeaterItem item in this.repeatControl.Items)
                {
                    TextBox text = item.FindControl("txtQty") as TextBox;
                    decimal qty  = Cast.Decimal(text.Text, 0M);
                    if (qty <= 0M)
                    {
                        continue;
                    }

                    HtmlInputCheckBox chk  = item.FindControl("checkbox") as HtmlInputCheckBox;
                    StockInLine       line = new StockInLine();
                    line.OrderNumber   = this.OrderNumber;
                    line.StockDetailID = Cast.Int(chk.Value);
                    line.LineNumber    = Cast.String(chk.Attributes["line"]);
                    line.Quantity      = qty;
                    line.Price         = 0M;
                    lines.Add(line);
                }
                if (lines.Count <= 0)
                {
                    log.Debug("Save - assist item req line: no lines need to be saved");
                    return;
                }

                session.BeginTransaction();
                head.CreateOrUpdateLines(session, lines);
                session.Commit();

                log.DebugFormat("Save - assist item req line: {0} lines were created or updated", lines.Count);
                WebUtil.ShowMsg(this, "辅料领用明细已经保存");
                this.QueryAndBindData(session, this.magicPagerMain.CurrentPageIndex, this.magicPagerMain.PageSize, true);
            }
            catch (Exception er)
            {
                log.Error("Save - to add assist item req line: ", er);
                session.Rollback();
                WebUtil.ShowError(this, er);
            }
        }
    }
Exemplo n.º 10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         this.txtOrderNumber.Value             = this.OrderNumber;
         this.cmdReturn1["Return"].NavigateUrl = this.cmdReturn2["Return"].NavigateUrl = WebUtil.Param("return");
         using (ISession session = new Session())
         {
             StockInHead head = StockInHead.Retrieve(session, this.OrderNumber);
             this.SetView(head);
             this.QueryAndBindData(session, head);
         }
     }
 }
Exemplo n.º 11
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_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, "保存成功");
            }
        }
    }
Exemplo n.º 12
0
    private void SetView(StockInHead head)
    {
        switch (head.Status)
        {
        case StockInStatus.Confirm:
            this.cmdEdit1.Visible = true;
            this.cmdEdit2.Visible = true;
            break;

        default:
            this.cmdEdit1.Visible = false;
            this.cmdEdit2.Visible = false;
            break;
        }
    }
Exemplo n.º 13
0
    private void showInfo(ISession session, StockInHead head)
    {
        User user;

        if (head != null)
        {
            this.txtOrderNumber.Text       = head.OrderNumber;
            this.txtNote.Text              = head.Note;
            this.drpLocation.SelectedValue = head.LocationCode;
            this.txtResponsible.Text       = head.Responsible;
            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;
        }
    }
Exemplo n.º 14
0
    private void QueryAndBindData(ISession session, int pageIndex, int pageSize, bool fetchRecordCount)
    {
        int         count = 0;
        StockInHead head  = StockInHead.Retrieve(session, this.OrderNumber);

        this.repeatControl.DataSource = StockInHead.QueryLine(session, true, this.OrderNumber, fetchRecordCount, out count
                                                              , head.LocationCode, "", this.txtItemCode.Text, this.txtItemName.Text, "", "", this.drpArea.SelectedValue, this.txtSection.Text
                                                              , pageIndex, pageSize);

        this.repeatControl.DataBind();
        if (fetchRecordCount)
        {
            this.magicPagerMain.RecordCount = this.magicPagerSub.RecordCount = count;
        }
        WebUtil.SetMagicPager(magicPagerMain, pageSize, pageIndex);
        WebUtil.SetMagicPager(magicPagerSub, pageSize, pageIndex);
    }
Exemplo n.º 15
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_OUT;
                    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.Responsible   = this.txtResponsible.Text.Trim();
                    head.LocationCode  = this.drpLocation.SelectedValue;
                    try
                    {
                        session.BeginTransaction();
                        head.OrderNumber = ERPUtil.NextOrderNumber(head.OrderTypeCode);
                        head.Create(session);
                        session.Commit();
                    }
                    catch (Exception er)
                    {
                        session.Rollback();
                        WebUtil.ShowError(this, er);
                    }

                    this.Response.Redirect("ProductOutNewLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape("ProductOutLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return"))));
                    return;
                }

                head              = StockInHead.Retrieve(session, this.OrderNumber);
                head.Responsible  = this.txtResponsible.Text.Trim();
                head.Note         = this.txtNote.Text.Trim();
                head.LocationCode = this.drpLocation.SelectedValue;
                head.Update(session, "Note", "LocationCode");
                this.Response.Redirect("ProductOutLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return")));
            }
        }
    }
Exemplo n.º 16
0
 private void setView(StockInHead head)
 {
     if (this.IsNew)
     {
         this.cmdDetail.Visible = false;
     }
     else
     {
         if (head != null && head.Status != StockInStatus.New)
         {
             WebUtil.DisableControl(this.txtNote);
             WebUtil.DisableControl(this.drpLocation);
             this.cmdEdit.Visible = false;
         }
         this.cmdDetail.Visible = true;
         this.cmdDetail["Detail"].NavigateUrl = "AssistItemOutLine.aspx?ordNum=" + this.OrderNumber + "&return=" + Microsoft.JScript.GlobalObject.escape(this.ReturnUrl);
     }
     this.cmdReturn["Return"].NavigateUrl = this.ReturnUrl;
 }
Exemplo n.º 17
0
    private void QueryAndBindData(ISession session, StockInHead head)
    {
        this.repeatControl.DataSource = session.CreateObjectQuery(@"
select l.LineNumber as LineNumber,s.BarCode as BarCode,m.ItemCode as ItemCode,m.ItemName as ItemName
    ,l.AreaCode as AreaCode,l.SectionCode as SectionCode,l.Quantity as Quantity,l.Price as Price
from StockInLine l
inner join ItemSpec s on l.SKUID=s.SKUID
inner join ItemMaster m on m.ItemID=s.ItemID
where l.OrderNumber=?ordNum
order by l.LineNumber")
                                        .Attach(typeof(StockInLine)).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;
    }
Exemplo n.º 18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.txtOrderNumber.Value             = this.OrderNumber;
            this.cmdReturn1["Return"].NavigateUrl = this.cmdReturn2["Return"].NavigateUrl = WebUtil.Param("return");
            using (ISession session = new Session())
            {
                OrderTypeDef typeDef = OrderTypeDef.Retrieve(session, StockInHead.ORD_TYPE_PRD_IN);
                if (typeDef != null)
                {
                    this.hidViewUrl.Value = typeDef.ViewURL;
                }

                StockInHead head = StockInHead.Retrieve(session, this.OrderNumber);
                this.SetView(head);
                this.QueryAndBindData(session, head);
            }
        }
    }
Exemplo n.º 19
0
 private void setView(StockInHead head)
 {
     if (this.IsNew)
     {
         this.cmdDetail.Visible = false;
     }
     else
     {
         if (head != null && head.Status != StockInStatus.New)
         {
             WebUtil.DisableControl(this.txtNote);
             WebUtil.DisableControl(this.drpLocation);
             WebUtil.DisableControl(this.txtResponsible);
             this.cmdEdit.Visible = false;
         }
         this.cmdDetail.Visible = true;
         this.cmdDetail["Detail"].NavigateUrl = "ProductOutLine.aspx?ordNum=" + this.OrderNumber + "&return=" + WebUtil.escape(this.ReturnUrl);
     }
     this.cmdReturn["Return"].NavigateUrl = this.ReturnUrl;
 }
Exemplo n.º 20
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);
         }
     }
 }
Exemplo n.º 21
0
    private void Save(ISession session, StockInHead head)
    {
        if (head == null)
        {
            return;
        }

        IList <StockInLine> linesToSave = new List <StockInLine>();

        foreach (RepeaterItem item in this.repeatControl.Items)
        {
            HtmlInputHidden txt = item.FindControl("hidLine") as HtmlInputHidden;
            TextBox         text;
            StockInLine     line = StockInLine.Retrieve(session, this.OrderNumber, txt.Value);
            text       = item.FindControl("txtPrice") as TextBox;
            line.Price = Cast.Decimal(text.Text, line.Price);
            linesToSave.Add(line);
        }

        head.UpdatePrice(session, linesToSave);
    }
Exemplo n.º 22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.txtOrderNumber.Value             = this.OrderNumber;
            this.cmdReturn1["Return"].NavigateUrl = this.cmdReturn2["Return"].NavigateUrl = WebUtil.Param("return");
            this.txtReturnUrl.Value = "AssistItemOutLine.aspx?ordNum=" + this.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return"));
            using (ISession session = new Session())
            {
                OrderTypeDef typeDef = OrderTypeDef.Retrieve(session, StockInHead.ORD_TYPE_ASSIST_OUT);
                if (typeDef != null)
                {
                    this.hidViewUrl.Value = typeDef.ViewURL;
                }

                StockInHead head = StockInHead.Retrieve(session, this.OrderNumber);
                this.SetView(head);
                this.QueryAndBindData(session, head);
            }
        }
    }
Exemplo n.º 23
0
        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));
        }
Exemplo n.º 24
0
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName == "Save")
        {
            #region 保存
            IList <StockInLine> linesToSave = new List <StockInLine>();
            foreach (RepeaterItem item in this.repeatControl.Items)
            {
                HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
                DropDownList      drp = item.FindControl("drpArea") as DropDownList;
                TextBox           text;
                StockInLine       line = new StockInLine();
                line.OrderNumber = this.OrderNumber;
                line.LineNumber  = chk.Value.Trim();
                line.AreaCode    = drp.SelectedValue;
                text             = item.FindControl("txtSection") as TextBox;
                line.SectionCode = text.Text.Trim();
                text             = item.FindControl("txtQualifiedQty") as TextBox;
                line.Quantity    = Cast.Decimal(text.Text.Trim());
                text             = item.FindControl("txtPrice") as TextBox;
                line.Price       = Cast.Decimal(text.Text.Trim());

                linesToSave.Add(line);
            }

            using (ISession session = new Session())
            {
                try
                {
                    //检查
                    StockInHead head = StockInHead.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())
            {
                try
                {
                    session.BeginTransaction();
                    foreach (RepeaterItem item in this.repeatControl.Items)
                    {
                        HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
                        if (chk.Checked)
                        {
                            StockInLine line = StockInLine.Retrieve(session, this.OrderNumber, chk.Value.Trim());
                            if (line != null)
                            {
                                line.Delete(session);
                            }
                        }
                    }
                    session.Commit();
                    this.QueryAndBindData(session, null);
                    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();
                    StockInHead head = StockInHead.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
                {
                    StockInHead head = StockInHead.Retrieve(session, this.OrderNumber);
                    if (head == null)
                    {
                        return;
                    }
                    session.BeginTransaction();
                    head.Close(session);
                    session.Commit();
                    WebUtil.ShowMsg(this, "辅料入库单" + head.OrderNumber + "已经完成");
                    this.QueryAndBindData(session, head);
                    this.SetView(head);
                }
                catch (Exception er)
                {
                    session.Rollback();
                    WebUtil.ShowError(this, er);
                }
            }
            #endregion
        }
    }
Exemplo n.º 25
0
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName == "Save")
        {
            #region 保存
            using (ISession session = new Session())
            {
                IList <StockInLine>       linesToSave = new List <StockInLine>();
                System.Text.StringBuilder error       = new System.Text.StringBuilder();
                foreach (RepeaterItem item in this.repeatControl.Items)
                {
                    HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
                    TextBox           text;
                    StockInLine       line = StockInLine.Retrieve(session, this.OrderNumber, chk.Value);
                    text             = item.FindControl("txtQty") as TextBox;
                    line.Quantity    = Cast.Decimal(text.Text.Trim());
                    text             = item.FindControl("txtSec") as TextBox;
                    line.SectionCode = text.Text.Trim();
                    DropDownList drp = item.FindControl("drpArea") as DropDownList;
                    line.AreaCode = drp.SelectedValue;

                    if (string.IsNullOrEmpty(line.AreaCode) || line.AreaCode.Trim().Length <= 0)
                    {
                        error.Append(chk.Attributes["sku"]).Append("未选择库位;");
                    }
                    else if (!string.IsNullOrEmpty(line.SectionCode) && line.SectionCode.Trim().Length > 0)
                    {
                        WHSection section = WHSection.Retrieve(session, line.AreaCode, line.SectionCode);
                        if (section == null)
                        {
                            error.Append(chk.Attributes["sku"])
                            .Append("库位").Append(line.AreaCode).Append("中不存在货架").Append(line.SectionCode).Append(";");
                        }
                    }

                    linesToSave.Add(line);
                }
                if (error.Length > 0)
                {
                    WebUtil.ShowError(this, error.ToString());
                    return;
                }

                try
                {
                    //检查
                    StockInHead head = StockInHead.Retrieve(session, this.OrderNumber);
                    if (head == null)
                    {
                        return;
                    }
                    session.BeginTransaction();
                    head.CreateOrUpdateLines(session, linesToSave);
                    session.Commit();
                    WebUtil.ShowMsg(this, "保存成功");
                }
                catch (Exception er)
                {
                    session.Rollback();
                    WebUtil.ShowError(this, er);
                }
            }
            #endregion
        }
        else if (e.CommandName == "Delete")
        {
            #region  除
            using (ISession session = new Session())
            {
                try
                {
                    session.BeginTransaction();
                    foreach (RepeaterItem item in this.repeatControl.Items)
                    {
                        HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
                        if (chk.Checked)
                        {
                            StockInLine line = StockInLine.Retrieve(session, this.OrderNumber, chk.Value.Trim());
                            if (line != null)
                            {
                                line.Delete(session);
                            }
                        }
                    }
                    session.Commit();
                    this.QueryAndBindData(session, null);
                    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
                {
                    StockInHead head = StockInHead.Retrieve(session, this.OrderNumber);
                    session.BeginTransaction();
                    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
                {
                    StockInHead head = StockInHead.Retrieve(session, this.OrderNumber);
                    if (head == null)
                    {
                        return;
                    }
                    session.BeginTransaction();
                    head.Close(session);
                    session.Commit();
                    WebUtil.ShowMsg(this, "产品入库单" + head.OrderNumber + "已经完成");
                    this.QueryAndBindData(session, head);
                    this.SetView(head);
                }
                catch (Exception er)
                {
                    session.Rollback();
                    WebUtil.ShowError(this, er);
                }
            }
            #endregion
        }
        else if (e.CommandName == "Add")
        {
            #region 添加明细
            using (ISession session = new Session())
            {
                ItemSpec sku = ItemSpec.Retrieve(session, this.txtSku.Text.Trim().ToUpper());
                if (sku == null)
                {
                    WebUtil.ShowError(this, "SKU: " + this.txtSku.Text.Trim() + "不存在");
                    return;
                }
                StockInHead head = StockInHead.Retrieve(session, this.OrderNumber);
                StockInLine line = new StockInLine();
                line.OrderNumber   = this.OrderNumber;
                line.LocationCode  = head.LocationCode;
                line.LineNumber    = head.NextLineNumber();
                line.AreaCode      = "";
                line.SectionCode   = "";
                line.Price         = sku.AvgMoveCost;
                line.Quantity      = 0M;
                line.RefQuantity   = 0M;
                line.SKUID         = sku.SKUID;
                line.StockDetailID = 0;
                line.UnitID        = 0;

                bool isError = false;
                try
                {
                    session.BeginTransaction();
                    line.Create(session);
                    head.Update(session, "CurrentLineNumber");
                    session.Commit();
                }
                catch (Exception er)
                {
                    session.Rollback();
                    WebUtil.ShowError(this, er);
                    isError = true;
                }

                if (!isError)
                {
                    this.txtSku.Text = "";
                    this.QueryAndBindData(session, head);
                    this.SetView(head);
                }
            }
            #endregion
        }
    }