Beispiel #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)
                    {
                        ICHead.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);
            }
        }
    }
Beispiel #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.txtAction.Value = WebUtil.Param("mode");
            this.txtId.Value     = WebUtil.Param("ordNumber");

            ICHead head = null;
            using (ISession session = new Session())
            {
                IList <Logistics> companies = session.CreateEntityQuery <Logistics>()
                                              .Where(Magic.Framework.ORM.Query.Exp.Eq("Status", LogisticsStatus.Enable))
                                              .OrderBy("ShortName")
                                              .List <Logistics>();
                this.drpLogistic.Items.Clear();
                foreach (Logistics lg in companies)
                {
                    this.drpLogistic.Items.Add(new ListItem(lg.ShortName, lg.LogisticCompID.ToString()));
                }

                if (!this.IsNew)
                {
                    head = ICHead.Retrieve(session, this.OrderNumber);
                    this.showInfo(session, head);
                }
            }
            this.setView(head);
        }
    }
Beispiel #3
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())
        {
            ICHead head = ICHead.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);
            }
        }
    }
Beispiel #4
0
 private void setView(ICHead head)
 {
     if (this.IsNew)
     {
         this.cmdDetail.Visible   = false;
         this.cmdScanLine.Visible = false;
     }
     else
     {
         if (head != null && head.Status != InterchangeStatus.New)
         {
             WebUtil.DisableControl(this.txtNote);
             WebUtil.DisableControl(this.drpLogistic);
             WebUtil.DisableControl(this.txtLogisticsUser);
             this.cmdEdit.Visible     = false;
             this.cmdScanLine.Visible = false;
         }
         else if (head != null)
         {
             this.cmdScanLine.Visible = true;
             this.cmdScanLine["ScanLine"].NavigateUrl = "InterchangeLineScan.aspx?ordNumber=" + this.OrderNumber + "&return=" + Microsoft.JScript.GlobalObject.escape(this.ReturnUrl);
         }
         this.cmdDetail.Visible = true;
         this.cmdDetail["Detail"].NavigateUrl = "InterchangeLine.aspx?ordNum=" + this.OrderNumber + "&return=" + Microsoft.JScript.GlobalObject.escape(this.ReturnUrl);
     }
     this.cmdReturn["Return"].NavigateUrl = this.ReturnUrl;
 }
Beispiel #5
0
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName == "Save")
        {
            using (ISession session = new Session())
            {
                ICHead head    = null;
                bool   created = false;
                if (this.IsNew)
                {
                    head = new ICHead();
                    head.OrderTypeCode   = ICHead.ORDER_TYPE;
                    head.Status          = InterchangeStatus.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.CompanyUser     = head.CreateUser;
                    head.InterchangeTime = DateTime.Now;
                    head.LogisticUser    = this.txtLogisticsUser.Text.Trim();
                    head.Note            = this.txtNote.Text.Trim();
                    head.LogisticCompID  = Magic.Framework.Utils.Cast.Int(this.drpLogistic.SelectedValue);
                    try
                    {
                        session.BeginTransaction();
                        head.OrderNumber = ERPUtil.NextOrderNumber(head.OrderTypeCode);
                        head.Create(session);
                        head.AutoGenerateDetail(session);
                        session.Commit();
                        created = true;
                        //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);
                    }
                }
                if (created)
                {
                    this.Response.Redirect("InterchangeLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return")));
                }

                head                = ICHead.Retrieve(session, this.OrderNumber);
                head.Note           = this.txtNote.Text.Trim();
                head.LogisticCompID = Magic.Framework.Utils.Cast.Int(this.drpLogistic.SelectedValue);
                head.LogisticUser   = this.txtLogisticsUser.Text.Trim();
                head.Update(session, "Note", "LogisticCompID", "LogisticUser", "BoxNum");
                WebUtil.ShowMsg(this, "保存成功");
            }
        }
    }
Beispiel #6
0
    private void QueryAndBindData(ISession session, ICHead head)
    {
        this.repeatControl.DataSource = session.CreateObjectQuery(@"
select il.LineNumber as LineNumber,il.OrderNumber as OrderNumber,sn.OrderNumber as SNNumber,sn.SaleOrderNumber as SONumber,sn.ShippingNumber as ShippingNumber
    ,m.Name as Name,sn.Contact as Contact,sn.Phone as Phone,sn.Address as Address,sn.Province as Province,sn.City as City
from ICLine il
inner join CRMSN sn on il.RefOrderNumber=sn.OrderNumber
left join Member m on m.MemberID=sn.MemberID
where il.OrderNumber=?ordNum
order by il.LineNumber")
                                        .Attach(typeof(ICLine)).Attach(typeof(CRMSN)).Attach(typeof(Member))
                                        .SetValue("?ordNum", this.OrderNumber, "il.OrderNumber")
                                        .DataSet();
        this._head = head;
        this.repeatControl.DataBind();
        this._head = null;
    }
Beispiel #7
0
    private void showInfo(ISession session, ICHead head)
    {
        User user;

        if (head != null)
        {
            this.txtOrderNumber.Text       = head.OrderNumber;
            this.txtNote.Text              = head.Note;
            this.drpLogistic.SelectedValue = head.LogisticCompID.ToString();
            this.txtLogisticsUser.Text     = head.LogisticUser;
            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;
        }
    }
Beispiel #8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         this.txtOrderNumber.Value             = this.OrderNumber;
         this.txtReturnUrl.Value               = WebUtil.Param("return");
         this.cmdReturn1["Return"].NavigateUrl = this.cmdReturn2["Return"].NavigateUrl = WebUtil.Param("return");
         using (ISession session = new Session())
         {
             ICHead head = ICHead.Retrieve(session, this.OrderNumber);
             this.SetView(head);
             this.QueryAndBindData(session, head);
         }
     }
     else
     {
         this.frameDownload.Attributes["src"] = "about:blank;";
     }
 }
Beispiel #9
0
    private void SetView(ICHead head)
    {
        switch (head.Status)
        {
        case InterchangeStatus.New:
            this.cmdEdit1.Visible  = true;
            this.cmdEdit2.Visible  = true;
            this.cmdClose1.Visible = false;
            this.cmdClose2.Visible = false;
            this.cmdPrint1.Visible = false;
            this.cmdPrint2.Visible = false;
            break;

        case InterchangeStatus.Release:
            this.cmdEdit1.Visible  = false;
            this.cmdEdit2.Visible  = false;
            this.cmdClose1.Visible = false;
            this.cmdClose2.Visible = false;
            this.cmdPrint1.Visible = true;
            this.cmdPrint2.Visible = true;
            break;

        case InterchangeStatus.Open:
            this.cmdEdit1.Visible  = false;
            this.cmdEdit2.Visible  = false;
            this.cmdClose1.Visible = true;
            this.cmdClose2.Visible = true;
            this.cmdPrint1.Visible = true;
            this.cmdPrint2.Visible = true;
            break;

        case InterchangeStatus.Close:
            this.cmdEdit1.Visible  = false;
            this.cmdEdit2.Visible  = false;
            this.cmdClose1.Visible = false;
            this.cmdClose2.Visible = false;
            this.cmdPrint1.Visible = true;
            this.cmdPrint2.Visible = true;
            break;
        }
    }
Beispiel #10
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));
        }
Beispiel #11
0
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName != "Confirm" && e.CommandName != "Save")
        {
            return;
        }
        string snnumber = this.txtSNNumber.Text.Trim();

        if (snnumber.Length <= 0)
        {
            this.lblInfo.InnerText = "发货单号码为空";
            return;
        }

        using (ISession session = new Session())
        {
            CRMSN sn = CRMSN.Retrieve(session, snnumber);
            if (sn == null)
            {
                this.lblInfo.InnerText = "发货单" + snnumber + "不存在";
                return;
            }
            if (sn.Status != CRMSNStatus.Checked && sn.Status != CRMSNStatus.Packaged)
            {
                this.lblInfo.InnerText = "发货单" + (sn.Status == CRMSNStatus.Interchanged ? "已经完成交接" : "状态为" + sn.Status.ToString()) + ",不可以进行调整";
                return;
            }
            ICHead ic = ICHead.Query(session, sn.OrderNumber);
            if (ic != null)
            {
                this.lblInfo.InnerText = sn.OrderNumber + "已经被加入到交接单" + ic.OrderNumber + "中,请先从交接单中删除该发货单后再进行修改";
                return;
            }

            this.hidSnNumber.Value = snnumber;
            if (e.CommandName == "Confirm")
            {
                this.snView.SNNumber = sn.OrderNumber;
                if (sn.LogisticsID > 0)
                {
                    this.drpLogis.SelectedValue = sn.LogisticsID.ToString();
                }
                else
                {
                    this.drpLogis.SelectedValue = "0";
                }
                this.txtInvoice.Value        = sn.InvoiceNumber;
                this.txtPackageCount.Value   = sn.PackageCount.ToString();
                this.txtPackageWeight.Value  = RenderUtil.FormatNumber(sn.PackageWeight, "##0.#0");
                this.txtShippingNumber.Value = sn.ShippingNumber;
            }
            else if (e.CommandName == "Save")
            {
                if (Cast.Int(this.drpLogis.SelectedValue, 0) <= 0)
                {
                    this.lblInfo.InnerText = "请选择物流公司";
                    return;
                }
                sn.ShippingNumber = this.txtShippingNumber.Value.Trim();
                sn.InvoiceNumber  = this.txtInvoice.Value.Trim();
                sn.PackageWeight  = Cast.Decimal(this.txtPackageWeight.Value, sn.PackageWeight);
                sn.PackageCount   = Cast.Int(this.txtPackageCount.Value, sn.PackageCount);
                sn.LogisticsID    = Cast.Int(this.drpLogis.SelectedValue, 0);
                sn.Update(session, "ShippingNumber", "InvoiceNumber", "PackageWeight", "PackageCount", "LogisticsID");
                this.lblInfo.InnerText       = "发货单" + sn.OrderNumber + "包装信息修改成功";
                this.txtSNNumber.Text        = "";
                this.snView.SNNumber         = "";
                this.txtInvoice.Value        = "";
                this.txtPackageCount.Value   = "";
                this.txtPackageWeight.Value  = "";
                this.txtShippingNumber.Value = "";
            }
        }
    }
Beispiel #12
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)
                        {
                            ICLine line = ICLine.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();
                    ICHead head = ICHead.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
                {
                    ICHead head = ICHead.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 == "Download")
        {
            #region  载
            DataSet ds = null;
            IDictionary <string, string> dic = new Dictionary <string, string>();
            #region 初始化dic
            dic["$LogisName$"]    = "";
            dic["$LogisAddress$"] = "";
            dic["$LogisContact$"] = "";
            dic["$LogisPhone$"]   = "";
            dic["$LogisZipCode$"] = "";
            dic["$LogisFax$"]     = "";
            dic["$ICNumber$"]     = "";
            dic["$ICUser$"]       = "";
            dic["$AgentAmt$"]     = "";
            dic["$Note$"]         = "";
            dic["$Status$"]       = "";
            dic["$ICTime$"]       = "";
            dic["$ICBoxCount$"]   = "";
            #endregion
            IList <DownloadFormat> format = new List <DownloadFormat>()
            {
                new DownloadFormat(DataType.NumberText, "", "OrderNumber"),
                new DownloadFormat(DataType.NumberText, "", "ShippingNumber"),
                new DownloadFormat(DataType.NumberText, "", "SaleOrderNumber"),
                new DownloadFormat(DataType.NumberText, "", "InvoiceNumber"),
                new DownloadFormat(DataType.Number, "", "PackageWeight"),
                new DownloadFormat(DataType.Number, "", "PackageCount"),
                new DownloadFormat(DataType.Text, "", "Contact"),
                new DownloadFormat(DataType.Text, "", "Province", "City"), //省市2区县待完善
                new DownloadFormat(DataType.NumberText, "", "PostCode"),
                new DownloadFormat(DataType.Text, "", "Address"),
                new DownloadFormat(DataType.NumberText, "", "Phone"),
                new DownloadFormat(DataType.NumberText, "", "Mobile"),
                new DownloadFormat(DataType.Number, "", "AgentAmt"),
                new DownloadFormat(DataType.Text, "", "Remark")
            };
            using (ISession session = new Session())
            {
                ds = session.CreateObjectQuery(@"
SELECT 
    A.OrderNumber AS OrderNumber,A.ShippingNumber as ShippingNumber,A.SaleOrderNumber AS SaleOrderNumber
    ,A.InvoiceNumber as InvoiceNumber,A.PackageWeight as PackageWeight,A.PackageCount as PackageCount
    ,A.Contact as Contact,A.Province as Province,A.City as City,A.Address as Address,A.Mobile as Mobile,A.Phone as Phone
    ,A.AgentAmt as AgentAmt,A.Remark as Remark,A.PostCode as PostCode
FROM ICLine L
inner JOIN CRMSN A ON L.RefOrderNumber=A.OrderNumber
LEFT JOIN Member E ON A.MemberID= E.MemberID
order by L.LineNumber")
                     .Attach(typeof(Magic.ERP.Orders.ICLine))
                     .Attach(typeof(Magic.ERP.Orders.CRMSN))
                     .Attach(typeof(Magic.Basis.Member))
                     .And(Magic.Framework.ORM.Query.Exp.Eq("L.OrderNumber", this.OrderNumber))
                     .DataSet();

                decimal totalAmt = 0M;
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    totalAmt += Cast.Decimal("AgentAmt");
                }

                ICHead head = ICHead.Retrieve(session, this.OrderNumber);
                if (head == null)
                {
                    WebUtil.ShowError(this, "交接单" + this.OrderNumber + "不存在");
                    return;
                }
                dic["$ICNumber$"]   = "'" + head.OrderNumber;
                dic["$AgentAmt$"]   = totalAmt.ToString("#0.#0");
                dic["$Note$"]       = "'" + head.Note;
                dic["$Status$"]     = ERPUtil.StatusText(session, CRMSN.ORDER_TYPE_CODE_SD, head.Status);
                dic["$ICTime$"]     = "'" + head.CreateTime.ToString("yyyy-MM-dd");
                dic["$ICBoxCount$"] = "'" + head.TotalPackageCount(session).ToString();
                Logistics logis = Logistics.Retrieve(session, head.LogisticCompID);
                if (logis != null)
                {
                    dic["$LogisName$"]    = logis.ShortName;
                    dic["$LogisAddress$"] = logis.Address;
                    dic["$LogisContact$"] = logis.Contact;
                    dic["$LogisPhone$"]   = "'" + logis.Phone;
                    dic["$LogisZipCode$"] = "'" + logis.ZipCode;
                    dic["$LogisFax$"]     = "'" + logis.Fax;
                }
                if (head.CreateUser > 0)
                {
                    Magic.Sys.User user = Magic.Sys.User.Retrieve(session, head.CreateUser);
                    if (user != null)
                    {
                        dic["$ICUser$"] = user.FullName;
                    }
                }
            }
            if (ds == null)
            {
                WebUtil.ShowError(this, "没有数据下载或者下载出错了");
                return;
            }

            string fileName = DownloadUtil.DownloadXls("IC_" + this.OrderNumber + ".xls", "IC", Server.MapPath("/Template/IC_Download.xls"), dic, 7, format, ds);
            this.frameDownload.Attributes["src"] = fileName;
            #endregion
        }
    }