Exemplo n.º 1
0
    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")));
            }
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         this.txtDateFrom.Text = DateTime.Now.AddMonths(-2).ToString("yyyy-MM-dd");
         this.txtDateTo.Text   = DateTime.Now.ToString("yyyy-MM-dd");
         log.DebugFormat("PageLoad - to add prd 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())
         {
             POReturnHead head = POReturnHead.Retrieve(session, this.OrderNumber);
             this.QueryAndBindData(session, 1, this.magicPagerMain.PageSize, true);
         }
     }
 }
    private void QueryAndBindData(ISession session, int pageIndex, int pageSize, bool fetchRecordCount)
    {
        POReturnHead head  = POReturnHead.Retrieve(session, this.OrderNumber);
        int          count = 0;

        this.repeatControl.DataSource = head.QueryNewLine(session, Cast.DateTime(this.txtDateFrom.Text), Cast.DateTime(this.txtDateTo.Text), this.txtPO.Text, this.txtSku.Text, pageIndex, pageSize, fetchRecordCount, ref count);
        this._session = session;
        this.repeatControl.DataBind();
        if (fetchRecordCount)
        {
            this.magicPagerMain.RecordCount = this.magicPagerSub.RecordCount = count;
        }
        WebUtil.SetMagicPager(magicPagerMain, pageSize, pageIndex);
        WebUtil.SetMagicPager(magicPagerSub, pageSize, pageIndex);
        this._session = null;
    }
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName != "Save")
        {
            return;
        }

        using (ISession session = new Session())
        {
            try
            {
                POReturnHead head = POReturnHead.Retrieve(session, this.OrderNumber);

                session.BeginTransaction();
                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;
                    text = item.FindControl("txtSec") as TextBox;
                    DropDownList drp = item.FindControl("drpArea") as DropDownList;
                    if (string.IsNullOrEmpty(drp.SelectedValue))
                    {
                        throw new Exception(chk.Attributes["po"] + "行" + chk.Attributes["poline"] + "没有选择库位");
                    }

                    head.AddLine(session, chk.Attributes["po"], chk.Attributes["poline"], drp.SelectedValue.Trim().ToUpper(), text.Text.Trim().ToUpper(), qty);
                }
                head.Update(session, "CurrentLineNumber");
                session.Commit();

                WebUtil.ShowMsg(this, "指定的退货信息已经保存");
                this.QueryAndBindData(session, this.magicPagerMain.CurrentPageIndex, this.magicPagerMain.PageSize, true);
            }
            catch (Exception er)
            {
                log.Error("Save - to add purchase return line: ", er);
                session.Rollback();
                WebUtil.ShowError(this, er);
            }
        }
    }
Exemplo n.º 5
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 = "POReturnLine.aspx?ordNum=" + this.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return"));
            using (ISession session = new Session())
            {
                OrderTypeDef typeDef = OrderTypeDef.Retrieve(session, POReturnHead.ORD_TYPE_CODE);
                if (typeDef != null)
                {
                    this.hidViewUrl.Value = typeDef.ViewURL;
                }

                POReturnHead head = POReturnHead.Retrieve(session, this.OrderNumber);
                this.SetView(head);
                this.QueryAndBindData(session, head);
            }
        }
    }
Exemplo n.º 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.txtAction.Value = WebUtil.Param("mode");
            this.txtId.Value     = WebUtil.Param("ordNumber");

            POReturnHead 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));
                }

                IList <Vendor> vendors = session.CreateEntityQuery <Vendor>()
                                         .OrderBy("ShortName")
                                         .List <Vendor>();
                this.drpVendor.Items.Clear();
                this.drpVendor.Items.Add(new ListItem("", "0"));
                foreach (Vendor v in vendors)
                {
                    this.drpVendor.Items.Add(new ListItem(v.ShortName, v.VendorID.ToString()));
                }

                if (!this.IsNew)
                {
                    head = POReturnHead.Retrieve(session, this.OrderNumber);
                    this.showInfo(session, head);
                }
            }
            this.setView(head);
        }
    }
Exemplo n.º 7
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.º 8
0
 protected void MagicItemCommand(object sender, MagicItemEventArgs e)
 {
     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)
                     {
                         POReturnLine line = POReturnLine.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
             {
                 POReturnHead head = POReturnHead.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
             {
                 POReturnHead head = POReturnHead.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
     }
 }