Esempio n. 1
0
    private void QueryAndBindData(ISession session, ReturnHead head)
    {
        this.repeatControl.DataSource = session.CreateObjectQuery(@"
select rtl.LineNumber as LineNumber
    ,s.BarCode as BarCode,m.ItemCode as ItemCode,m.ItemName as ItemName,s.ColorCode as ColorCode,color.ColorText as ColorText,s.SizeCode as SizeCode
    ,st.Name as SaleType,snl.Price as Price,snl.Quantity as ShippingQty
    ,rtl.Quantity as ReturnQty,rtl.AreaCode as AreaCode,rtl.SectionCode as SectionCode
from ReturnLine rtl
inner join CRMSNLine snl on rtl.RefOrderLineID=snl.ID
inner join ItemSpec s on s.SKUID=rtl.SKUID
inner join ItemMaster m on m.ItemID=s.ItemID
left join ItemColor color on color.ColorCode=s.ColorCode
left join CRMSaleType st on st.ID=snl.SellType
where rtl.OrderNumber=?ordNum
order by rtl.LineNumber")
                                        .Attach(typeof(ReturnLine)).Attach(typeof(ItemSpec)).Attach(typeof(ItemMaster)).Attach(typeof(ItemColor))
                                        .Attach(typeof(CRMSNLine)).Attach(typeof(CRMSaleType))
                                        .SetValue("?ordNum", this.OrderNumber, "rtl.OrderNumber")
                                        .DataSet();
        this._session = session;
        this._head    = head;
        this.repeatControl.DataBind();
        this._head    = null;
        this._session = null;
    }
Esempio n. 2
0
    private void QueryAndBindData(ISession session, ReturnHead head)
    {
        DataSet ds = session.CreateObjectQuery(@"
select snl.ID as SNDID,s.BarCode as BarCode,m.ItemCode as ItemCode,m.ItemName as ItemName
    ,s.ColorCode as ColorCode,color.ColorText as ColorText,s.SizeCode as SizeCode
    ,st.Name as SaleType,snl.Price as Price,snl.Quantity as ShippingQty,rtl.Quantity as ReturnQty
from ReturnHead rth
inner join CRMSNLine snl on rth.RefOrderID=snl.SNID
inner join ItemSpec s on s.SKUID=snl.SKUID
inner join ItemMaster m on m.ItemID=s.ItemID
left join ReturnLine rtl on rtl.OrderNumber=rth.OrderNumber and rtl.RefOrderLineID=snl.ID
left join ItemColor color on color.ColorCode=s.ColorCode
left join CRMSaleType st on st.ID=snl.SellType
where rth.OrderNumber=?ordNum
order by snl.ID")
                     .Attach(typeof(ReturnHead)).Attach(typeof(ReturnLine))
                     .Attach(typeof(ItemSpec)).Attach(typeof(ItemMaster)).Attach(typeof(ItemColor))
                     .Attach(typeof(CRMSNLine)).Attach(typeof(CRMSaleType))
                     .SetValue("?ordNum", this.OrderNumber, "rtl.OrderNumber")
                     .DataSet();

        ds.Tables[0].Columns.Add("INDEX", typeof(int));
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            ds.Tables[0].Rows[i]["INDEX"] = i + 1;
        }
        this.repeatControl.DataSource = ds;
        this.repeatControl.DataBind();
    }
Esempio n. 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.txtAction.Value = WebUtil.Param("mode");
            this.txtId.Value     = WebUtil.Param("ordNumber");

            ReturnHead head = null;
            using (ISession session = new Session())
            {
                IList <WHLocation> locations = WHLocation.EffectiveList(session);
                this.drpLocation.Items.Clear();
                foreach (WHLocation loc in locations)
                {
                    this.drpLocation.Items.Add(new ListItem(loc.Name, loc.LocationCode));
                }
                IList <ReturnReason> resons = ReturnReason.EffectiveList(session);
                this.drpReason.Items.Clear();
                this.drpReason.Items.Add(new ListItem(" ", "0"));
                foreach (ReturnReason rs in resons)
                {
                    this.drpReason.Items.Add(new ListItem(rs.ReasonText, rs.ReasonID.ToString()));
                }

                if (!this.IsNew)
                {
                    head = ReturnHead.Retrieve(session, this.OrderNumber);
                    this.showInfo(session, head);
                }
            }
            this.setView(head);
        }
    }
Esempio n. 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         this.txtOrderNumber.Value             = this.OrderNumber;
         this.cmdReturn1["Return"].NavigateUrl = this.cmdReturn2["Return"].NavigateUrl = this.ReturnUrl;
         using (ISession session = new Session())
         {
             ReturnHead head = ReturnHead.Retrieve(session, this.OrderNumber);
             if (head.OrderTypeCode == ReturnHead.ORDER_TYPE_EXCHANGE_RTN)
             {
                 if (head.Status == ReturnStatus.New)
                 {
                     this.spanMessage.Visible   = true;
                     this.spanMessage.InnerText = "该退货包裹类型为换货退回," + (head.HasScaned ? "已经完成扫描,确定入库库位后可以发布了" : "您还未扫描退回的商品");
                 }
                 else
                 {
                     this.spanMessage.Visible = false;
                 }
                 this.cmdScan1["New"].NavigateUrl = this.cmdScan2["New"].NavigateUrl = "ExchangeReturnScan.aspx?ordNum=" + this.OrderNumber + "&return=" + WebUtil.escape("MemberReturnLine.aspx?ordNum=" + this.OrderNumber + "&return=" + WebUtil.escape(this.ReturnUrl));
             }
             else
             {
                 this.spanMessage.Visible         = false;
                 this.cmdScan1["New"].NavigateUrl = this.cmdScan2["New"].NavigateUrl = "MemberReturnScan.aspx?ordNum=" + this.OrderNumber + "&return=" + WebUtil.escape("MemberReturnLine.aspx?ordNum=" + this.OrderNumber + "&return=" + WebUtil.escape(this.ReturnUrl));
             }
             this.snView.SNNumber = head.RefOrderNumber;
             this.SetView(head);
             this.QueryAndBindData(session, head);
         }
     }
 }
Esempio n. 5
0
    private void QueryAndBindData(ISession session, ReturnHead head)
    {
        DataSet ds = session.CreateObjectQuery(@"
select 
       sku.BarCode As BarCode,sku.SizeCode As SizeCode
       ,i.ItemCode As ItemCode,i.ItemName As ItemName,sku.ColorCode As ColorCode,c.Name As ColorText
       ,st.Name As SaleType,rl.Price As Price,rl.Quantity As ReturnQty
from ReturnHead rh
inner join ReturnLine rl on rh.OrderNumber=rl.OrderNumber
inner join ItemSpec sku on sku.SKUID=rl.SKUID
inner join ItemMaster i on i.ItemCode=sku.ItemCode
left join ItemColor c on c.ColorCode=sku.ColorCode
left join CRMSN sn on sn.ID=rh.RefOrderID
left join CRMSNLine snl on snl.SNID=sn.ID and snl.ID=rl.RefOrderLineID
left join CRMSaleType st on st.ID=snl.SellType
where rh.OrderNumber=?ordNum
order by rl.LineNumber")
                     .Attach(typeof(ReturnHead)).Attach(typeof(ReturnLine))
                     .Attach(typeof(ItemSpec)).Attach(typeof(ItemMaster)).Attach(typeof(ItemColor))
                     .Attach(typeof(CRMSN)).Attach(typeof(CRMSNLine)).Attach(typeof(CRMSaleType))
                     .SetValue("?ordNum", head.OrderNumber, "rh.OrderNumber")
                     .DataSet();

        ds.Tables[0].Columns.Add("INDEX", typeof(int));
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            ds.Tables[0].Rows[i]["INDEX"] = i + 1;
        }
        this.txtLineCount.Value       = ds.Tables[0].Rows.Count.ToString();
        this.repeatControl.DataSource = ds;
        this.repeatControl.DataBind();
    }
Esempio n. 6
0
    private void QueryAndBindData(ISession session, ReturnHead head)
    {
        DbSession  dbsession = session.DbSession as DbSession;
        IDbCommand cmd       = dbsession.CreateSqlStringCommand(@"
select /*+ ordered use_nl(snl s) use_nl(s m) use_nl(snl rth) index(rtl pk_ord_rtn_line) use_nl(color s) use_nl(st snl) */
       snl.Id As SNDID,s.ITM_BARCODE As BarCode
       ,m.ITM_CODE As ItemCode,m.ITM_NAME As ItemName,s.COLOR_CODE As ColorCode,color.Name As ColorText
       ,s.SIZE_CODE As SizeCode
       ,st.Name As SaleType,snl.PRICE As Price,snl.QUANTITY As ShippingQty
       ,sum(rtl.RTN_QTY) As ReturnQty 
from ORD_SHIPPINGNOTICE_LINES snl
inner join PRD_ITEM_SKU s on s.SKU_ID=snl.SKU_ID 
inner join PRD_ITEM m on m.itm_code=s.itm_code 
Left join ORD_RTN_HEAD rth  on rth.REF_ORD_ID=snl.SN_ID
left join ORD_RTN_LINE rtl on rtl.ORD_NUM=rth.ORD_NUM and rtl.REF_ORD_LINE_ID=snl.ID 
left join PRD_ITEM_COLOR color on color.CODE=s.COLOR_CODE 
Left join S_SELL_TYPE st on st.ID=snl.SELL_TYPE
where snl.sn_id=:snid
Group By snl.Id,s.ITM_BARCODE,m.ITM_CODE,m.ITM_NAME,s.COLOR_CODE,color.Name,s.SIZE_CODE
      ,st.Name,snl.PRICE,snl.QUANTITY
order by snl.Id");

        dbsession.AddParameter(cmd, ":snid", EntityManager.GetPropMapping(typeof(ReturnHead), "RefOrderID").DbTypeInfo, head.RefOrderID);
        DataSet ds = dbsession.ExecuteDataSet(cmd);

        ds.Tables[0].Columns.Add("INDEX", typeof(int));
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            ds.Tables[0].Rows[i]["INDEX"] = i + 1;
        }
        this.repeatControl.DataSource = ds;
        this.repeatControl.DataBind();
    }
Esempio n. 7
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)
                    {
                        ReturnHead.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);
            }
        }
    }
Esempio n. 8
0
    private void SetView(ReturnHead head)
    {
        switch (head.Status)
        {
        case ReturnStatus.New:
            this.cmdEdit1.Visible  = true;
            this.cmdEdit2.Visible  = true;
            this.cmdClose1.Visible = false;
            this.cmdClose2.Visible = false;
            break;

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

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

        case ReturnStatus.Close:
            this.cmdEdit1.Visible  = false;
            this.cmdEdit2.Visible  = false;
            this.cmdClose1.Visible = false;
            this.cmdClose2.Visible = false;
            break;
        }
    }
Esempio n. 9
0
 private void AddTestData1(ReturnHeadDbContext context)
 {
     var Customer1 = new Customer
     {
         Id="1205",
         CompanyName="Volvo IT AB",
         LastName="Roger",
         MiddleName="",
         FirstName="Federer",
         PersonTitle="Mr",
         Gender="Male",
         CareOfName="Melka",
         AddressLine1="Lexington Avenue",
         AddressLine2 = "Street212",
         AddressLine3 = "",
         PostCode="SWI1234",
         CityName="Paris",
         County = "",
         State = "Paris",
         Province = "",
         Country = "France",
         CustomerType = "Business",
         IkeaFamilyNumber = "8749484",
         TaxRegNo = "",
         TaxIdType = "",
         OrganisationNumber = "54000-12343",
         PassportNumber = "FRA3524244",
         TelephoneHome="8987555321",
         TelephoneWork = "",
         TelephoneMobile = "0000005888",
         Fax = "",
         Email="*****@*****.**",
         IdentityType="1205",
         IdentityNumber="",
         PreferedLanguage="FR",
         ContactType=""
     };
     context.CustomerDTOs.Add(Customer1);
     var lines = new List<Line>();
     lines.Add(new Line(){Id = "2345242",ItemId = "895554488",Quantity = 1,ReasonCode = "08",SubReasonCode = "05"});
     context.LineDTOs.Add(lines[0]);
     var returnHead = new ReturnHead
     {
         Id="EXPSE123456677",
         BuCode="703",
         TillNumber="12",
         Customer=Customer1,
         TransactionNumber = "1205",
         Lines=lines,
         Date = "21112018",
         OrderNumber = "7897653"
     };
     context.ReturnHeadDTOs.Add(returnHead);
     context.SaveChanges();
 }
Esempio n. 10
0
 private void setView(ReturnHead head)
 {
     if (!this.IsNew && head != null && head.Status != ReturnStatus.New)
     {
         WebUtil.DisableControl(this.txtNote);
         WebUtil.DisableControl(this.drpLocation);
         WebUtil.DisableControl(this.txtSNNumber);
         WebUtil.DisableControl(this.drpReason);
         WebUtil.DisableControl(this.chkIsMalicious);
         this.cmdEdit.Visible = false;
     }
     this.cmdReturn["Return"].NavigateUrl = this.ReturnUrl;
 }
Esempio n. 11
0
    private void showInfo(ISession session, ReturnHead head)
    {
        User user;

        if (head != null)
        {
            this.txtOrderNumber.Text       = head.OrderNumber;
            this.drpLocation.SelectedValue = head.LocationCode;
            this.txtSNNumber.Text          = head.RefOrderNumber;
            this.drpReason.SelectedValue   = head.ReasonID.ToString();
            this.chkIsMalicious.Checked    = head.IsMalicious;
            this.chkHasTransported.Checked = head.HasTransported;
            this.txtNote.Text = head.Note;
            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;
        }
    }
Esempio n. 12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         this.txtOrderNumber.Value             = this.OrderNumber;
         this.txtReturnUrl.Value               = "LogisReturnLine.aspx?ordNum=" + this.OrderNumber + "&return=" + WebUtil.escape(this.ReturnUrl);
         this.cmdReturn1["Return"].NavigateUrl = this.cmdReturn2["Return"].NavigateUrl = this.ReturnUrl;
         using (ISession session = new Session())
         {
             ReturnHead head = ReturnHead.Retrieve(session, this.OrderNumber);
             this.snView.SNNumber = head.RefOrderNumber;
             this.SetView(head);
             this.QueryAndBindData(session, head);
         }
     }
 }
Esempio n. 13
0
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName == "Save")
        {
            using (ISession session = new Session())
            {
                ReturnHead head = null;
                if (this.IsNew)
                {
                    head = new ReturnHead();
                    try
                    {
                        head.LogisReturn(session, this.drpLocation.SelectedValue, this.txtSNNumber.Text, Cast.Int(this.drpReason.SelectedValue, 0), this.chkIsMalicious.Checked, this.chkHasTransported.Checked, this.txtNote.Text.Trim(), SecuritySession.CurrentUser.UserId);
                        head.OrderNumber = ERPUtil.NextOrderNumber(head.OrderTypeCode);
                        session.BeginTransaction();
                        head.Create(session);
                        session.Commit();

                        this.Response.Redirect("LogisReturnScan.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape("LogisReturnLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(this.ReturnUrl)));
                    }
                    catch (Exception er)
                    {
                        session.Rollback();
                        WebUtil.ShowError(this, er);
                    }

                    return;
                }

                try
                {
                    head = ReturnHead.Retrieve(session, this.OrderNumber);
                    head.LogisReturn(session, this.drpLocation.SelectedValue, this.txtSNNumber.Text, Cast.Int(this.drpReason.SelectedValue, 0), this.chkIsMalicious.Checked, this.chkHasTransported.Checked, this.txtNote.Text.Trim(), SecuritySession.CurrentUser.UserId);
                    session.BeginTransaction();
                    head.Update(session, "Note", "LocationCode", "ReasonID", "ReasonText", "IsMalicious", "RefOrderID", "RefOrderNumber", "OrginalOrderNumber", "LogisticsName", "LogisticsID", "MemberName", "MemberID", "HasTransported");
                    session.Commit();
                    WebUtil.ShowMsg(this, "保存成功");
                }
                catch (Exception er2)
                {
                    session.Rollback();
                    WebUtil.ShowError(this, er2);
                }
            }
        }
    }
Esempio n. 14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         this.txtOrderNumber.Value = this.OrderNumber;
         this.txtReturnUrl.Value   = this.ReturnUrl;
         using (ISession session = new Session())
         {
             ReturnHead head = ReturnHead.Retrieve(session, this.OrderNumber);
             if (head != null)
             {
                 this.snView.SNNumber = head.RefOrderNumber;
             }
             this.QueryAndBindData(session, head);
         }
     }
 }
Esempio n. 15
0
    private void SetView(ReturnHead head)
    {
        switch (head.Status)
        {
        case ReturnStatus.New:
            this.cmdScan1.Visible  = true;
            this.cmdScan2.Visible  = true;
            this.cmdEdit1.Visible  = true;
            this.cmdEdit2.Visible  = true;
            this.cmdClose1.Visible = false;
            this.cmdClose2.Visible = false;
            break;

        case ReturnStatus.Release:
            this.cmdScan1.Visible  = false;
            this.cmdScan2.Visible  = false;
            this.cmdEdit1.Visible  = false;
            this.cmdEdit2.Visible  = false;
            this.cmdClose1.Visible = false;
            this.cmdClose2.Visible = false;
            break;

        case ReturnStatus.Open:
            this.cmdScan1.Visible  = false;
            this.cmdScan2.Visible  = false;
            this.cmdEdit1.Visible  = false;
            this.cmdEdit2.Visible  = false;
            this.cmdClose1.Visible = true;
            this.cmdClose2.Visible = true;
            break;

        case ReturnStatus.Close:
            this.cmdScan1.Visible  = false;
            this.cmdScan2.Visible  = false;
            this.cmdEdit1.Visible  = false;
            this.cmdEdit2.Visible  = false;
            this.cmdClose1.Visible = false;
            this.cmdClose2.Visible = false;
            break;
        }
        if (head.OrderTypeCode == ReturnHead.ORDER_TYPE_EXCHANGE_RTN && head.HasScaned)
        {
            this.cmdScan1.Visible = false;
            this.cmdScan2.Visible = false;
        }
    }
 private void setView(ReturnHead head)
 {
     if (!this.IsNew && head != null && head.Status != ReturnStatus.New)
     {
         WebUtil.DisableControl(this.txtNote);
         WebUtil.DisableControl(this.drpLocation);
         WebUtil.DisableControl(this.txtSNNumber);
         WebUtil.DisableControl(this.drpReason);
         WebUtil.DisableControl(this.chk);
         this.cmdEdit.Visible = false;
     }
     else if (head != null && head.OrderTypeCode == ReturnHead.ORDER_TYPE_EXCHANGE_RTN)
     {
         //换货退货单,不允许修改发货单号码
         WebUtil.DisableControl(this.txtSNNumber);
         WebUtil.DisableControl(this.chk);
     }
     this.cmdReturn["Return"].NavigateUrl = this.ReturnUrl;
 }
Esempio n. 17
0
    protected void cmdEdit1_ItemCommand(object sender, MagicItemEventArgs args)
    {
        if (args.CommandName == "Save")
        {
            HtmlInputText input = null;
            using (ISession session = new Session())
            {
                try
                {
                    IList <ReturnLine> lines = new List <ReturnLine>();
                    foreach (RepeaterItem item in this.repeatControl.Items)
                    {
                        input = item.FindControl("hidQty") as HtmlInputText;
                        int     sndid     = Cast.Int(input.Attributes["vv_sndid"]);
                        decimal returnQty = Cast.Decimal(input.Value);
                        if (sndid <= 0 || returnQty <= 0M)
                        {
                            continue;
                        }
                        ReturnLine line = new ReturnLine();
                        line.RefOrderLineID = sndid;
                        line.Quantity       = returnQty;
                        lines.Add(line);
                    }
                    if (lines.Count <= 0)
                    {
                        this.Response.Redirect(this.ReturnUrl);
                    }

                    ReturnHead head = ReturnHead.Retrieve(session, this.OrderNumber);
                    session.BeginTransaction();
                    head.UpdateOrCreateLines(session, lines);
                    session.Commit();
                    this.Response.Redirect(this.ReturnUrl);
                }
                catch (Exception er)
                {
                    session.Rollback();
                    WebUtil.ShowError(this, er);
                }
            }
        }
    }
Esempio n. 18
0
 protected void cmdEdit1_ItemCommand(object sender, MagicItemEventArgs args)
 {
     if (args.CommandName == "Save")
     {
         using (ISession session = new Session())
         {
             try
             {
                 ReturnHead head = ReturnHead.Retrieve(session, this.OrderNumber);
                 session.BeginTransaction();
                 head.ExchangeReturnScaned(session);
                 session.Commit();
                 this.Response.Redirect(this.ReturnUrl);
             }
             catch (Exception er)
             {
                 session.Rollback();
                 WebUtil.ShowError(this, er);
             }
         }
     }
 }
Esempio n. 19
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));
        }
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName == "Save")
        {
            using (ISession session = new Session())
            {
                ReturnHead head = null;
                #region 更新退货单的情况
                if (!this.IsNew)
                {
                    head = ReturnHead.Retrieve(session, this.txtOrderNumber.Text.Trim());
                    if (head == null)
                    {
                        WebUtil.ShowError(this, "退货单" + this.txtOrderNumber.Text.Trim() + "不存在");
                        return;
                    }
                    if (head.Status != ReturnStatus.New)
                    {
                        WebUtil.ShowError(this, "退货单" + head.OrderNumber + "不是新建状态,无法更新");
                        return;
                    }
                    try
                    {
                        session.BeginTransaction();
                        if (head.OrderTypeCode == ReturnHead.ORDER_TYPE_MBR_RTN)
                        {
                            head.MemberReturn(session, this.drpLocation.SelectedValue, this.txtSNNumber.Text, Cast.Int(this.drpReason.SelectedValue, 0), this.chk.Checked, this.txtNote.Text.Trim(), SecuritySession.CurrentUser.UserId);
                            head.Update(session, "Note", "LocationCode", "ReasonID", "ReasonText", "IsMalicious", "RefOrderID", "RefOrderNumber", "OrginalOrderNumber", "LogisticsName", "LogisticsID", "MemberName", "MemberID");
                        }
                        else
                        {
                            head.ExchangeReturn(session, this.drpLocation.SelectedValue, Cast.Int(this.drpReason.SelectedValue), this.txtNote.Text, 0);
                            head.Update(session, "Note", "LocationCode", "ReasonID", "ReasonText");
                        }
                        session.Commit();
                        WebUtil.ShowMsg(this, "保存成功");
                    }
                    catch (Exception er2)
                    {
                        session.Rollback();
                        WebUtil.ShowError(this, er2);
                    }
                    return;
                }
                #endregion
                //根据发货单查询是否存在退货单,2个作用
                //1. 换货的情况下,创建换货订单同时已经创建了换货退货单,这种情况要更新一下换货退货单资料(仓库、退货原因、备注)而不用新增
                //2. 目前不允许一个订单多次退货,即发货单如果已经用于创建退货单,则不再允许创建第2个了
                IList <ReturnHead> heads = ReturnHead.QueryBySNNumber(session, this.txtSNNumber.Text.Trim());
                #region 从来没有(会员退货、物流退货、内部退货),允许退货,以下代码创建新的会员退货单
                if (heads.Count <= 0)
                {
                    head = new ReturnHead();
                    try
                    {
                        head.MemberReturn(session, this.drpLocation.SelectedValue, this.txtSNNumber.Text, Cast.Int(this.drpReason.SelectedValue, 0), this.chk.Checked, this.txtNote.Text.Trim(), SecuritySession.CurrentUser.UserId);
                        head.OrderNumber = ERPUtil.NextOrderNumber(head.OrderTypeCode);
                        session.BeginTransaction();
                        head.Create(session);
                        session.Commit();

                        this.Response.Redirect("MemberReturnScan.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape("MemberReturnLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(this.ReturnUrl)));
                    }
                    catch (Exception er)
                    {
                        session.Rollback();
                        WebUtil.ShowError(this, er);
                    }

                    return;
                }
                #endregion
                int countOfNewChangeReturn = this.CountOfNewChangeReturn(heads);
                #region  新建状态的换货单,直接调出该换货单,更新其资料,更新完后跳转到退货扫描界面
                //如果已经部分退货过一次,下面的代码允许继续换货
                if (countOfNewChangeReturn > 0)
                {
                    foreach (ReturnHead h in heads)
                    {
                        if (h.Status == ReturnStatus.New && h.OrderTypeCode == ReturnHead.ORDER_TYPE_EXCHANGE_RTN)
                        {
                            head = h;
                            break;
                        }
                    }
                    if (head != null)
                    {
                        try
                        {
                            head.ExchangeReturn(session, this.drpLocation.SelectedValue, Cast.Int(this.drpReason.SelectedValue), this.txtNote.Text.Trim(), SecuritySession.CurrentUser.UserId);
                            session.BeginTransaction();
                            head.Update(session, "LocationCode", "ReasonID", "ReasonText", "Note");
                            session.Commit();
                            this.Response.Redirect("ExchangeReturnScan.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape("MemberReturnLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return"))));
                            return;
                        }
                        catch (Exception er5)
                        {
                            session.Rollback();
                            WebUtil.ShowError(this, er5);
                        }
                    }
                    return;
                }
                #endregion
                #region 如果有未完成的退货单,必须完成后才可以新建另外的退货
                foreach (ReturnHead h in heads)
                {
                    if (h.Status != ReturnStatus.Close)
                    {
                        WebUtil.ShowError(this, "与发货单" + h.RefOrderNumber + "相关的退货单" + h.OrderNumber + "还没有完成,无法创建另外的退货单");
                        return;
                    }
                }
                #endregion
                #region 如果没有创建过任何会员退货、物流退货、内部退货,则允许创建一个(这几种退货只能退一次)
                if (this.IsAllChangeReturn(heads))
                {
                    head = new ReturnHead();
                    try
                    {
                        head.MemberReturn(session, this.drpLocation.SelectedValue, this.txtSNNumber.Text, Cast.Int(this.drpReason.SelectedValue, 0), this.chk.Checked, this.txtNote.Text.Trim(), SecuritySession.CurrentUser.UserId);
                        head.OrderNumber = ERPUtil.NextOrderNumber(head.OrderTypeCode);
                        session.BeginTransaction();
                        head.Create(session);
                        session.Commit();

                        this.Response.Redirect("MemberReturnScan.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape("MemberReturnLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(this.ReturnUrl)));
                    }
                    catch (Exception er)
                    {
                        session.Rollback();
                        WebUtil.ShowError(this, er);
                    }

                    return;
                }
                #endregion
                #region 其它情况将无法再创建会员退货单
                if (this.IsNew)
                {
                    WebUtil.ShowError(this, "同一个订单(发货单)不允许多次退货,系统无法再创建退货单");
                    return;
                }
                #endregion
            }
        }
    }
Esempio n. 21
0
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName == "Save")
        {
            #region 保存
            IList <ReturnLine> linesToSave = new List <ReturnLine>();
            foreach (RepeaterItem item in this.repeatControl.Items)
            {
                HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
                DropDownList      drp = item.FindControl("drpArea") as DropDownList;
                TextBox           text;
                ReturnLine        line = new ReturnLine();
                line.OrderNumber = this.OrderNumber;
                line.LineNumber  = chk.Value.Trim();
                line.AreaCode    = drp.SelectedValue;
                text             = item.FindControl("txtSection") as TextBox;
                line.SectionCode = text.Text.Trim();

                linesToSave.Add(line);
            }

            using (ISession session = new Session())
            {
                try
                {
                    //检查
                    ReturnHead head = ReturnHead.Retrieve(session, this.OrderNumber);
                    if (head == null)
                    {
                        return;
                    }
                    session.BeginTransaction();
                    head.UpdateLines(session, linesToSave);
                    session.Commit();
                    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();
                    ReturnHead head = ReturnHead.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
                {
                    ReturnHead head = ReturnHead.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
        }
    }