示例#1
0
    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)
                    {
                        POReturnHead.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);
            }
        }
    }
    private void SetView(POReturnHead head)
    {
        switch (head.Status)
        {
        case POReturnStatus.New:
            this.cmdEdit1.Visible  = true;
            this.cmdEdit2.Visible  = true;
            this.cmdClose1.Visible = false;
            this.cmdClose2.Visible = false;
            break;

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

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

        case POReturnStatus.Close:
            this.cmdEdit1.Visible  = false;
            this.cmdEdit2.Visible  = false;
            this.cmdClose1.Visible = false;
            this.cmdClose2.Visible = false;
            break;
        }
    }
 private void setView(POReturnHead head)
 {
     if (head != null && head.Status != POReturnStatus.New)
     {
         WebUtil.DisableControl(this.txtNote);
         WebUtil.DisableControl(this.drpLocation);
         WebUtil.DisableControl(this.drpVendor);
         this.cmdEdit.Visible = false;
     }
     this.cmdReturn["Return"].NavigateUrl = this.ReturnUrl;
 }
    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);
            }
        }
    }
    private void showInfo(ISession session, POReturnHead head)
    {
        User user;

        if (head != null)
        {
            this.txtOrderNumber.Text       = head.OrderNumber;
            this.txtNote.Text              = head.Note;
            this.drpLocation.SelectedValue = head.LocationCode;
            this.drpVendor.SelectedValue   = head.VendorID.ToString();
            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;
        }
    }
    private void QueryAndBindData(ISession session, POReturnHead head)
    {
        this.repeatControl.DataSource = session.CreateObjectQuery(@"
select l.LineNumber as LineNumber,l.PONumber as PONumber,l.POLine as POLine
    ,s.BarCode as BarCode,m.ItemCode as ItemCode,m.ItemName as ItemName
    ,s.ColorCode as ColorCode,s.SizeCode as SizeCode,color.ColorText as ColorText
    ,sto.AreaCode as AreaCode,sto.SectionCode as SectionCode,l.Quantity as Qty
from POReturnLine l
inner join ItemSpec s on l.SKUID=s.SKUID
inner join ItemMaster m on m.ItemID=s.ItemID
inner join StockDetail sto on sto.StockDetailID=l.StockDetailID
left join ItemColor color on color.ColorCode=s.ColorCode
where l.OrderNumber=?ordNum
order by l.LineNumber")
                                        .Attach(typeof(POReturnLine)).Attach(typeof(ItemSpec)).Attach(typeof(ItemMaster)).Attach(typeof(ItemColor))
                                        .Attach(typeof(StockDetail))
                                        .SetValue("?ordNum", this.OrderNumber, "l.OrderNumber")
                                        .DataSet();
        this._head = head;
        this.repeatControl.DataBind();
    }
示例#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");
            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);
            }
        }
    }
示例#11
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);
        }
    }
示例#12
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));
        }
示例#13
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
     }
 }