Example #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string snNumber = WebUtil.Param("ordNum");

        if (string.IsNullOrEmpty(snNumber))
        {
            return;
        }

        ExcelTemplate template             = null;
        IDictionary <string, string> items = new Dictionary <string, string>();

        #region 获取数据
        //所有要替换的标签先初始化为空值
        items["$RecipientName$"]    = "";
        items["$RecipientCity$"]    = "";
        items["$RecipientArea$"]    = "";
        items["$RecipientAddress$"] = "";
        items["$RecipientPhone$"]   = "";
        items["$RecipientMobile$"]  = "";
        items["$RecipientZipCode$"] = "";
        items["$AgencyAmt$"]        = "";
        items["$PaidAmt$"]          = "";
        items["$Remark$"]           = "";
        items["$Weight$"]           = "";
        items["$PackageCount$"]     = "";
        using (ISession session = new Session())
        {
            CRMSN sn = CRMSN.Retrieve(session, snNumber);
            if (sn == null)
            {
                return;
            }
            Member mbr = Member.Retrieve(session, sn.MemberID);
            template = ExcelTemplate.Retrieve(session, WebUtil.ParamInt("tid", 0));
            if (template == null)
            {
                return;
            }

            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("(<br.*?>)|(</br>)", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
            items["$RecipientName$"]    = sn.Contact;
            items["$RecipientCity$"]    = sn.City;
            items["$RecipientArea$"]    = Cast.String(sn.Province) + " " + Cast.String(sn.City); //省市区,缺少区
            items["$RecipientAddress$"] = sn.Address;
            items["$RecipientCompany$"] = "";
            items["$RecipientPhone$"]   = "'" + sn.Phone;
            items["$RecipientMobile$"]  = "'" + (string.IsNullOrEmpty(sn.Mobile) || sn.Mobile.Trim().Length <= 0 ? mbr.Mobile : sn.Mobile);
            items["$RecipientZipCode$"] = "'" + sn.PostCode;
            items["$AgencyAmt$"]        = RenderUtil.FormatNumber(sn.AgentAmt, "#0.##", "");
            items["$PaidAmt$"]          = "'" + RenderUtil.FormatNumber(sn.PaidAmt, "#0.##", "");
            items["$Remark$"]           = "'" + regex.Replace(Cast.String(sn.Remark), "\r\n");
            items["$Weight$"]           = sn.PackageWeight <= 0 ? "" : ("'" + sn.PackageWeight.ToString("#0.##"));
            items["$PackageCount$"]     = "'" + RenderUtil.FormatNumber(sn.PackageCount, "#0.##", "");
        }
        #endregion

        this.Response.Redirect(DownloadUtil.DownloadXls("SN_" + snNumber + ".xls", "SN", Server.MapPath(template.FileVirtualPath), items));
    }
Example #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.cmdReturn1["Return"].NavigateUrl = WebUtil.Param("return");
            this.cmdReturn2["Return"].NavigateUrl = WebUtil.Param("return");
            this.snView.SNNumber = WebUtil.Param("ordNum");

            using (ISession session = new Session())
            {
                CRMSN sn = CRMSN.Retrieve(session, WebUtil.Param("ordNum"));
                Response.Write(sn.ToJSon(session).ToJsonString());
                this.QueryAndBindData(session);
            }
        }
    }
Example #3
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 = "";
            }
        }
    }