/// <summary> /// 为单个经销商创建PDF文档 /// </summary> /// <param name="folderPath"></param> /// <param name="fileName"></param> /// <param name="client"></param> /// <param name="dateBegin"></param> /// <param name="dateEnd"></param> public void CreateClientPDF(string folderPath, string fileName, CM_Client client, DateTime dateBegin, DateTime dateEnd) { Document doc = GetOrCreatePDF(fileName, folderPath); //文档期间项 string documentDate = dateBegin.ToString("yyyy年第MM期") + "至" + dateEnd.ToString("yyyy年第MM期"); doc = ReceiveBillPDF(doc, client, documentDate, dateBegin, dateEnd); doc.Add(Chunk.NEXTPAGE); doc = RangLiDetailPDF(doc, client, documentDate, dateBegin, dateEnd); doc.Add(Chunk.NEXTPAGE); doc = TransferDetailPDF(doc, client, documentDate, dateBegin, dateEnd); doc.Add(Chunk.NEXTPAGE); dateBegin = dateBegin.AddMonths(1); DisposePdf(doc); }
/// <summary> /// 创建转账明细表 /// </summary> /// <param name="document"></param> /// <param name="client"></param> /// <param name="documentDate"></param> /// <param name="year"></param> /// <param name="month"></param> /// <returns></returns> private Document TransferDetailPDF(Document document, CM_Client client, string documentDate, DateTime dateBegin, DateTime dateEnd) { if (!document.IsOpen()) { return null; } document = this.GetDocumentHeader(document, "转账明细表", documentDate, client); document.Add(Chunk.NEWLINE); string procName = "JD.AIS_YSL.dbo.STKD_DDFYREPORT02_CXCAI";//代垫费用余额(让利明细表)存储过程名 DataTable dt = new DataTable(); while (DateTime.Compare(dateBegin, dateEnd) <= 0) { //文档期间项 int year = dateBegin.Year; int month = dateBegin.Month; DataTable dtTemp = new CM_ClientBLL().GetStatement(procName, year, month, client.Code); dt.Merge(dtTemp); dateBegin = dateBegin.AddMonths(1); } dt.Columns.RemoveAt(1);//去除“期间”列 //dt.Columns[1].SetOrdinal(0); List<string> tableHeaders = new List<string>(5); //tableHeaders.Add("期间"); tableHeaders.Add("日期"); tableHeaders.Add("摘要"); tableHeaders.Add("转账金额"); tableHeaders.Add("市场费用投入"); tableHeaders.Add("期末余额"); for (int i = 0; i < dt.Columns.Count; i++) { dt.Columns[i].ColumnName = tableHeaders[i]; } PdfPTable ptable = TableToPDFTable(dt); //ptable.TotalWidth = 520f; //ptable.LockedWidth = true; float[] widths = new float[] { 1f, 2f, 1f, 1f, 1f }; ptable.SetWidths(widths); document.Add(ptable); document = this.GetDocumentNotice(document); document.Add(Chunk.NEWLINE); this.GetDocumentSign(document); return document; }
/// <summary> /// 创建客户对账单 /// </summary> /// <param name="document"></param> /// <param name="client"></param> /// <param name="documentDate"></param> /// <param name="year"></param> /// <param name="month"></param> /// <returns></returns> private Document ReceiveBillPDF(Document document, CM_Client client, string documentDate, DateTime dateBegin, DateTime dateEnd) { if (!document.IsOpen()) { return null; } document = this.GetDocumentHeader(document, "客户对账单", documentDate, client); document.Add(Chunk.NEWLINE); string procName = "KD.AIS20140109134912.dbo.STKD_ARREPORT_CXCAI";//应收账款存储过程名 DataTable dt = new DataTable(); while (DateTime.Compare(dateBegin, dateEnd) <= 0) { //文档期间项 int year = dateBegin.Year; int month = dateBegin.Month; DataTable dtTemp = new CM_ClientBLL().GetStatement(procName, year, month, client.Code); dt.Merge(dtTemp); dateBegin = dateBegin.AddMonths(1); } //DataColumn col = new DataColumn("dateStr"); //col.DefaultValue = ViewState["dateStr"].ToString(); //dt.Columns.Add(col); //dt.Columns["dateStr"].SetOrdinal(0); List<string> tableHeaders = new List<string>(5); tableHeaders.Add("单据日期"); tableHeaders.Add("单据类型"); tableHeaders.Add("单据编号"); tableHeaders.Add("摘要"); tableHeaders.Add("本期应收"); tableHeaders.Add("本期实收"); tableHeaders.Add("期末余额"); for (int i = 0; i < dt.Columns.Count; i++) { dt.Columns[i].ColumnName = tableHeaders[i]; } PdfPTable ptable = TableToPDFTable(dt); float[] widths = new float[] { 1f, 1.5f, 1f, 2f, 1f, 1f, 1f }; ptable.SetWidths(widths); Paragraph paragraph = new Paragraph(); paragraph.Add(ptable); paragraph.Alignment = Element.PTABLE; document.Add(paragraph); document.Add(Chunk.NEWLINE); this.GetDocumentSign(document); return document; }
/// <summary> /// 获取单据头 /// </summary> /// <param name="document"></param> /// <param name="documentTitle"></param> /// <param name="documentDate"></param> /// <param name="client"></param> /// <returns></returns> public Document GetDocumentHeader(Document document, string documentTitle, string documentDate, CM_Client client) { Font font = GetPdfFont(); Paragraph paragraph = null; paragraph = new Paragraph(documentTitle, new Font(GetPdfBaseFont(), 16)); paragraph.Alignment = iTextSharp.text.Element.TITLE; document.Add(paragraph); paragraph.Clear(); paragraph.Font = GetPdfFont(); string str1 = "经销商:"; str1 += client == null || string.IsNullOrEmpty(client.Code) ? string.Empty : " [" + client.Code + "] " + client.FullName; str1 += " 期间项:" + documentDate; Chunk chunk1 = new Chunk(str1, font); paragraph.Add(chunk1); paragraph.Alignment = Element.ALIGN_LEFT; document.Add(paragraph); paragraph.Clear(); string str2 = "打印时间:" + DateTime.Now.ToString("yyyy-MM-dd") + " 币别:人民币"; paragraph.Add(new Chunk(str2, font)); document.Add(paragraph); return document; }
protected void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 if (!Page.IsPostBack) { int ClientID = Request.QueryString["ClientID"] != null && int.TryParse(Request.QueryString["ClientID"].ToString(), out ClientID) ? ClientID : 0; ViewState["ClientID"] = ClientID; BindDropDown(); if ((int)ViewState["ClientID"] > 0) { BindData(); } else { #region 新增门店时的初始值 CM_Client tdp = new CM_ClientBLL((int)Session["OwnerClient"]).Model; if (tdp == null) { Response.Redirect("RetailerList.aspx"); return; } CM_Client m = new CM_Client(); m.OfficialCity = tdp.OfficialCity; m.PostCode = tdp.PostCode; CM_ClientSupplierInfo supplierinfo = new CM_ClientSupplierInfo(); supplierinfo.State = 1; supplierinfo.BeginDate = DateTime.Today; supplierinfo.StandardPrice = PDT_StandardPriceBLL.GetDefaultPrice(tdp.ID); pl_detail.BindData(m); pl_detail.BindData(supplierinfo); bt_Map.Visible = false; bt_AddLinkMan.Visible = false; tr_LinkMan.Visible = false; #region 新增客户时,首要联系人字段不可编辑 DropDownList ddl_ChiefLinkMan = (DropDownList)pl_detail.FindControl("CM_Client_ChiefLinkMan"); try { if (ddl_ChiefLinkMan != null) { ddl_ChiefLinkMan.Items.Clear(); ddl_ChiefLinkMan.Enabled = false; } } catch { } #endregion #endregion } } #region 给活跃标志加事件 //DropDownList ddl_ActiveFlag_1 = (DropDownList)pl_detail.FindControl("CM_Client_ActiveFlag"); //ddl_ActiveFlag_1.AutoPostBack = true; //ddl_ActiveFlag_1.SelectedIndexChanged += new EventHandler(ddl_ActiveFlag_SelectedIndexChanged); #endregion #region 注册弹出窗口脚本 string script = "function Pop_MapShow(id){\r\n"; script += "var tempid = Math.random() * 10000; \r\n window.showModalDialog('" + Page.ResolveClientUrl("~/SubModule/CM/Map/ClientInMap.aspx") + "?ClientID=' + id + '&tempid='+tempid, window, 'dialogWidth:800px;DialogHeight=550px;status:yes;resizable=yes');}"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "PopShow", script, true); #endregion }
private void FillClientInfo(CM_Client m, int TDP) { if (m == null) return; CM_ClientBLL ClientBLL = new CM_ClientBLL(m.ID); if (ClientBLL.Model == null) return; #region 绑定基本资料 ID = m.ID; Code = m.Code; FullName = m.FullName == "" ? m.ShortName : m.FullName; ShortName = m.ShortName; OfficialCity = m.OfficialCity; Address = m.Address; ClientType = m.ClientType; LinkManName = m.LinkManName; TeleNum = m.TeleNum; Mobile = m.Mobile == "" ? m.TeleNum : m.Mobile; OfficialCityName = TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OfficialCity", m.OfficialCity).Replace("->", " "); #endregion #region 绑定供货信息 CM_ClientSupplierInfo SupplierInfo = ClientBLL.GetSupplierInfo(TDP); if (SupplierInfo != null) { CodeBySupplier = SupplierInfo.Code; Supplier = SupplierInfo.Supplier; StandardPrice = SupplierInfo.StandardPrice; TDPChannel = SupplierInfo.TDPChannel; TDPSalesArea = SupplierInfo.TDPSalesArea; VisitRoute = SupplierInfo.VisitRoute; VisitSequence = SupplierInfo.VisitSequence; VisitTemplate = SupplierInfo.VisitTemplate; #region 获取供货商名称 CM_Client s = new CM_ClientBLL(Supplier).Model; if (s != null) { SupplierName = s.ShortName == "" ? s.ShortName : s.FullName; } #endregion #region 获取价表名称 if (StandardPrice != 0) { PDT_StandardPrice price = new PDT_StandardPriceBLL(StandardPrice).Model; if (price != null) { StandardPriceName = price.Name; } } #endregion #region 获取渠道名称 if (TDPChannel > 0) { CM_RTChannel_TDP channel = new CM_RTChannel_TDPBLL(TDPChannel).Model; if (channel != null) TDPChannelName = channel.Name; } #endregion #region 获取区域名称 if (TDPSalesArea > 0) { CM_RTSalesArea_TDP area = new CM_RTSalesArea_TDPBLL(TDPSalesArea).Model; if (area != null) TDPSalesAreaName = area.Name; } #endregion #region 获取路线及拜访模板名称 if (VisitRoute != 0) { VST_Route r = new VST_RouteBLL(VisitRoute).Model; if (r != null) VisitRouteName = r.Name; } if (VisitTemplate != 0) { VST_VisitTemplate t = new VST_VisitTemplateBLL(VisitTemplate).Model; if (t != null) VisitTemplateName = t.Name; } #endregion #region 获取销售员名称 if (Salesman != 0) { Org_Staff staff = new Org_StaffBLL(Salesman).Model; if (staff != null) SalesmanName = staff.RealName; } #endregion } #endregion #region 绑定厂商管理信息 int manufacturer = 0; //归属厂商 if (m.ClientType == 3) { //门店的归属厂商为当前TDP所归属的厂商 CM_Client supplier = new CM_ClientBLL(TDP).Model; if (supplier != null) manufacturer = supplier.OwnerClient; } else if (m.ClientType == 2) { //TDP经销商的归属厂商 manufacturer = m.OwnerClient; } CM_ClientManufactInfo ManufactInfo = ClientBLL.GetManufactInfo(manufacturer); if (ManufactInfo != null) { CodeByManufaturer = ManufactInfo.Code; } #endregion #region 绑定客户定位信息 CM_ClientGeoInfo geo = CM_ClientGeoInfoBLL.GetGeoInfoByClient(m.ID); if (geo != null) { Latitude = (float)geo.Latitude; Longitude = (float)geo.Longitude; } #endregion #region 绑定客户供货产品目录 ClientProductLists = new List<ProductList>(); foreach (CM_ClientProductList item in CM_ClientProductListBLL.GetModelList ("Client=" + m.ID.ToString() + (TDP == 0 ? "" : " AND Supplier=" + TDP.ToString()))) { ClientProductLists.Add(new ProductList(item)); } #endregion #region 查询预收款余额 AC_CurrentAccount ac = AC_CurrentAccountBLL.GetByTradeClient(TDP, m.ID); if (ac != null) ARBalance = ac.PreReceivedAmount - ac.AR; #endregion #region 获取附件明细 IList<ATMT_Attachment> atts = ATMT_AttachmentBLL.GetAttachmentList(30, m.ID, DateTime.Today.AddMonths(-3), new DateTime(2100, 1, 1)); Atts = new List<Attachment>(atts.Count); foreach (ATMT_Attachment item in atts.OrderByDescending(p => p.UploadTime)) { Atts.Add(new Attachment(item)); } #endregion }
public ClientInfo(CM_Client m, int TDP) { FillClientInfo(m, TDP); }