public string ExportExcelPR(System.Int32 id) { //接收需要导出的数据 T_CKD ckdinfo = new T_CKD(); List <T_CKD> list = T_CKDDomain.GetInstance().GetListModelById(id); if (list.Count > 0) { ckdinfo = list[0]; } int xsqyid = ckdinfo.T_XSD.KHID ?? 0; T_CusQY cusqy = T_CusQYDomain.GetInstance().GetModelById(xsqyid); //客户企业名称 string xsqyName = cusqy.CusMC; List <T_CKMX> ckmxList = T_CKMXDomain.GetInstance().GetListModelById(id); //命名导出表格的StringBuilder变量 StringBuilder sHtml = new StringBuilder(string.Empty); //打印表头 sHtml.Append("<table border=\"0\" width=\"100%\">"); sHtml.Append("<tr height=\"40\"><td colspan=\"10\" align=\"center\" style='font-size:24px'><b>出库单" + "</b></td></tr>"); sHtml.Append("<tr height=\"40\"><td colspan=\"8\" align=\"left\">购买单位:" + xsqyName + "</td><td align=\"right\">日期:" + DateTime.Now.ToString("yyyy-MM-dd") + "</td><td align=\"right\">单据编号:" + DateTime.Now.ToString("yyyyMMddHHmmssffff") + "</td></tr>"); sHtml.Append("</table>"); sHtml.Append("<table border=\"1\" width=\"100%\">"); //sHtml.Append("<tr height=\"40\"><td colspan=\"10\" align=\"center\" style='font-size:24px'><b>出库单" + "</b></td></tr>"); //sHtml.Append("<tr height=\"40\"><td colspan=\"8\" align=\"left\"> 购买单位:" + xsqyName + "</td><td align=\"right\">日期:" + DateTime.Now.ToString("yyyy-MM-dd") + "</td><td align=\"right\">单据编号:" + DateTime.Now.ToString("yyyyMMddHHmmssffff") + "</td></tr>"); //打印列名 sHtml.Append("<tr height=\"30\" align=\"center\" ><td>商品名称</td><td>规格</td><td>生产厂家</td><td>单位</td><td>数量</td><td>单价</td>" + "<td>金额</td><td>批号</td><td>生产日期</td><td>注册证号</td></tr>"); //合计 double total = 0.0; for (int i = 0; i < ckmxList.Count; i++) { T_CKMX ckmx = ckmxList[i]; //产品名称 string cpName = ckmx.T_YLCP.CPMC; //规格 string cpGg = ckmx.T_YLCP.CPGG ?? ""; //单位 string cpDw = ckmx.T_YLCP.CPDW ?? ""; //数量 double cpDj = ckmx.CPNUM ?? 0; //生成批号 string scPh = ckmx.T_YLCP.CPPH ?? ""; //生产日期 string scRq = ""; if (ckmx.T_YLCP.CPSCSJ != null) { scRq = ckmx.T_YLCP.CPSCSJ.Value.ToLongDateString(); } //生产企业 string cpScqy = ckmx.T_YLCP.CPSCQY ?? ""; //单价 double cpPrice = ckmx.T_YLCP.CPPrice ?? 0.0; //产品总价 double rowTotal = cpDj * cpPrice; total = total + rowTotal; //注册证号 string cpzczh = ckmx.T_YLCP.CPZCZ; sHtml.Append("<tr height=\"30\" align=\"center\"><td>" + cpName + "</td><td>" + cpGg + "</td><td>" + cpScqy + "</td><td>" + cpDw + "</td><td>" + cpDj.ToString() + "</td><td>" + cpPrice.ToString() + "</td><td>" + rowTotal.ToString() + "</td><td>" + scPh + "</td><td>" + scRq + "</td><td>" + cpzczh + "</td></tr>"); } //循环读取List集合 for (int i = 0; i < list.Count; i++) { } //打印表尾 sHtml.Append("<tr height=\"40\" align=\"center\"><td>合计:</td><td colspan=\"9\">" + total + "</td></tr>"); sHtml.Append("</table>"); sHtml.Append("<table border=\"0\" width=\"100%\">"); sHtml.Append("<tr height=\"40\" align=\"center\"><td colspan=\"7\" align=\"left\">制单人:  </td><td align=\"right\">审核人:  </td><td align=\"right\">发货人:  </td><td align=\"center\">销售员:  </td></tr>"); sHtml.Append("</table>"); //调用输出Excel表的方法 return(sHtml.ToString()); //ExportToExcel("application/vnd.ms-excel", "出库单.xls", sHtml.ToString()); }
public string ExportExcelPR2(System.Int32 id) { //获取需要打印的数据 T_CKD ckdinfo = new T_CKD(); List <T_CKD> list = T_CKDDomain.GetInstance().GetListModelById(id); if (list.Count > 0) { ckdinfo = list[0]; } int xsqyid = 0; if (ckdinfo.T_XSD != null && ckdinfo.T_XSD.KHID.HasValue) { xsqyid = ckdinfo.T_XSD.KHID.Value; } T_CusQY cusqy = T_CusQYDomain.GetInstance().GetModelById(xsqyid); //购货企业名称 string xsqyName = (cusqy != null && !string.IsNullOrEmpty(cusqy.CusMC)) ? cusqy.CusMC : ""; string xsqyKFDZ = (cusqy != null) ? cusqy.CusKFDZ : ""; //库房地址 List <T_CKMX> ckmxList = T_CKMXDomain.GetInstance().GetListModelById(id); T_WhsQY qy = new T_WhsQY(); Expression <Func <T_WhsQY, bool> > where = PredicateBuilder.True <T_WhsQY>(); var lst = T_WhsQYDomain.GetInstance().GetAllModels <int>(where); if (lst != null && lst.Count > 0) { qy = lst[0]; } //命名导出表格的StringBuilder变量 StringBuilder sHtml = new StringBuilder(string.Empty); //打印表头 sHtml.Append("<table style='border-collapse:collapse;' rull='all'>"); sHtml.Append("<tr height=\"40\"><td colspan=\"12\" align=\"center\" style='font-size:24px;border:0px;'>" + qy.WhsMC + "销售复核出库单" + "</td></tr>"); sHtml.Append("<tr height=\"40\"><td colspan=\"5\" align=\"left\" style='border:0px;'>购货单位:" + xsqyName + "</td><td align=\"left\" colspan=\"3\" style='border:0px;'>日 期:" + DateTime.Now.ToString("yyyy-MM-dd") + "</td><td align=\"center\" colspan=\"4\" style='border:0px;'>单据编号:" + DateTime.Now.ToString("yyyyMMddHHmmss") + "</td></tr>"); sHtml.Append("<tr><td colspan=\"12\" height=\"30\" style='border:0px;'>地址:" + xsqyKFDZ + "</td></tr>"); sHtml.Append("<tr align=\"center\" ><td style='width: 100px;' >产品名称</td><td style='width: 40px;' >规格</td><td style='width: 40px;' >型号</td><td style='width:128px;' >生产企业</td><td style='width: 35px;' >单位</td><td style='width: 35px;' >数量</td><td style='width: 70px;' >产品批号</td><td style='width: 65px;'>生产日期\r\n--------\r\n失效日期</td><td style='width: 65px;' >生产/经营\r\n许可证号</td><td style='width: 60px;' >注册证号</td><td style='width: 35px;' >储运条件</td><td style='width: 32px;border-right: thin solid black;' >备注</td></tr>"); //合计 double total = 0.0; double NumCpNum = 0.0; for (int i = 0; i < ckmxList.Count; i++) { T_CKMX ckmx = ckmxList[i]; //产品名称 string cpName = ckmx.T_YLCP.CPMC; //规格 string cpGg = ckmx.T_YLCP.CPGG ?? ""; var cpxh = ckmx.T_YLCP.CPXH ?? ""; //单位 string cpDw = ckmx.T_YLCP.CPDW ?? ""; //数量 double cpDj = ckmx.CPNUM ?? 0; //产品批号 string scPh = ckmx.CPPH ?? ""; //产品有效期 string scRq = ""; if (ckmx.CPYXQ != null) { scRq = ckmx.CPYXQ.Value.ToString("yyyyMMdd"); } var scrq = ""; if (ckmx.CPSCRQ != null) { scrq = ckmx.CPSCRQ.Value.ToString("yyyyMMdd"); } //生产企业 string cpScqy = ""; if (ckmx.T_YLCP != null && ckmx.T_YLCP.T_SupQY1 != null && !string.IsNullOrEmpty(ckmx.T_YLCP.T_SupQY1.SupMC)) { cpScqy = ckmx.T_YLCP.T_SupQY1.SupMC; } //单价 double cpPrice = Math.Round(ckmx.CPPRICE ?? 0.0, 2); //产品总价 double rowTotal = Math.Round(cpDj * cpPrice, 2); total = total + rowTotal; NumCpNum = NumCpNum + cpDj; //经营许可证号 string xkzbh = ""; if (ckmx.T_YLCP != null && ckmx.T_YLCP.T_SupQY1 != null && !string.IsNullOrEmpty(ckmx.T_YLCP.T_SupQY1.SupXKZBH)) { xkzbh = ckmx.T_YLCP.T_SupQY1.SupXKZBH; } //注册证号 string cpzczh = ckmx.T_YLCP.CPZCZ; var cytj = ckmx.CYTJ; sHtml.Append("<tr align=\"center\"><td >" + cpName + "</td><td style='vnd.ms-excel.numberformat:@' >" + cpGg + "</td><td style='vnd.ms-excel.numberformat:@' >" + cpxh + "</td><td >" + cpScqy + "</td><td >" + cpDw + "</td><td style='vnd.ms-excel.numberformat:@' >" + cpDj.ToString("") + "</td><td style='vnd.ms-excel.numberformat:@' >" + scPh + "</td><td style='vnd.ms-excel.numberformat:@'>" + scrq + "\r\n" + "--------" + "\r\n" + scRq + " </td>" + "<td style='vnd.ms-excel.numberformat:@' >" + xkzbh + "</td><td style='vnd.ms-excel.numberformat:@' >" + cpzczh + "</td><td >" + cytj + "</td><td style='border-right: thin solid black;' ></td></tr>"); } //打印表尾 sHtml.Append("<tr id='trtotal' height=\"40\" align=\"center\"><td colspan=\"7\" style='border-bottom: thin solid black;font-size:16px;'>合计金额:(大写)" + RmbHelper.CmycurD(total.ToString()) + "</td><td colspan=\"5\" style='border-bottom: thin solid black;border-right: thin solid black;font-size:16px;'>(小写)" + total.ToString("0.00") + "</td></tr>"); var xsry = ckdinfo.T_XSD == null ? "" : ckdinfo.T_XSD.XSRY; sHtml.Append("<tr height=\"40\" align=\"center\"><td colspan=\"3\" align=\"left\" style='border:0px;'>销售员: " + xsry + "</td><td align=\"center\" colspan=\"3\" style='border:0px;'>复核员: " + ckdinfo.FHR + "</td ><td align =\"center\" colspan=\"3\" style='border:0px;'>出库员: " + ckdinfo.CKCHR + "</td ><td align =\"center\" colspan=\"3\" style='border:0px;'>收货人: </td></tr>"); sHtml.Append("<tr><td colspan=\"12\" style='border:0px;'>公司地址:" + qy.WhsZCDZ + "</td></tr>"); sHtml.Append("</table>"); return(sHtml.ToString()); }
public ActionResult Index(T_XSDModels evalModel) { SysUser UserModel = Session["UserModel"] as SysUser; try { ViewData["shUserId"] = UserModel.UserId; evalModel.currentPage = int.Parse(Request["pageNum"].ToString()); } catch { } string order = ""; try { order = Request["orderField"].ToString(); } catch { } if (order.Trim() == "${param.orderField}") { order = ""; } int pagesize = Convert.ToInt32(evalModel.pageSize); int pagecount = Convert.ToInt32(evalModel.pagecount); int currentPage = Convert.ToInt32(evalModel.currentPage); evalModel.DataModel = evalModel.DataModel ?? new T_XSD(); string strCUSQY = "请选择"; if (Request["strXSDH"] != null) { string str = Request["strXSDH"].ToString(); if (!String.IsNullOrEmpty(str)) { evalModel.DataModel.XSDH = str; } } if (Request["strXSDMC"] != null) { string str = Request["strXSDMC"].ToString(); if (!String.IsNullOrEmpty(str)) { evalModel.DataModel.XSMC = str; } } if (Request["strCUSQY"] != null) { strCUSQY = Request["strCUSQY"].ToString(); if (!String.IsNullOrEmpty(strCUSQY)) { evalModel.DataModel.KHID = Convert.ToInt16(strCUSQY); } } var strXSPerson = ""; if (Request["strXSPerson"] != null) { strXSPerson = Request["strXSPerson"].ToString(); if (!String.IsNullOrEmpty(strXSPerson)) { evalModel.DataModel.XSRY = strXSPerson; } } ViewData["strXSPerson"] = strXSPerson; var cpId = 0; if (Request["strXSCPMC"] != null) { string str = Request["strXSCPMC"].ToString(); if (!String.IsNullOrEmpty(str)) { cpId = Convert.ToInt32(str); } ViewData["strXSCPMC"] = str; } var cusId = 0; if (Request["strXSCusQY"] != null) { string str = Request["strXSCusQY"].ToString(); if (!String.IsNullOrEmpty(str)) { cusId = Convert.ToInt32(str); } ViewData["strXSCusQY"] = str; } //购货企业列表 T_CusQY cusqy = new T_CusQY(); ViewBag.CUSQY = new SelectList(T_CusQYDomain.GetInstance().GetAllT_CusQY(cusqy).Where(p => p.CusStatus == 1).ToList(), "CusID", "CusMC"); ViewData["strCUSQY"] = strCUSQY; //获取本企业下的人员列表 T_Person person = new T_Person(); person.PsQYID = (int)UserModel.UserCompanyID; ViewBag.Persons = new SelectList(T_PersonDomain.GetInstance().GetAllT_Person(person), "PsMZ", "PsMZ"); T_SupQYModels supmode = new T_SupQYModels(); supmode.DataModel = supmode.DataModel ?? new T_SupQY(); supmode.DataList = T_SupQYDomain.GetInstance().GetAllT_SupQY(supmode.DataModel).Where(p => p.SupStatus == 1).ToList(); ViewData["SupQYList"] = new SelectList(supmode.DataList, "SupID", "SupMC"); T_YLCPModels ylcpQymode = new T_YLCPModels(); ylcpQymode.DataModel = ylcpQymode.DataModel ?? new T_YLCP(); ylcpQymode.DataList = T_YLCPDomain.GetInstance().GetAllT_YLCP(ylcpQymode.DataModel).Where(p => p.CPStatus == 1).ToList(); ViewData["YLCP"] = new SelectList(ylcpQymode.DataList, "CPID", "CPMC"); evalModel.DataList = T_XSDDomain.GetInstance().PageT_XSD(evalModel.DataModel, evalModel.StartTime, evalModel.EndTime, currentPage, pagesize, cpId, cusId, out pagecount, out resultCount); evalModel.resultCount = resultCount; return(View("~/Views/T_XSD/Index.cshtml", evalModel)); }
public ActionResult Index(T_CKDModels evalModel) { try { evalModel.currentPage = int.Parse(Request["pageNum"].ToString()); } catch { } string order = ""; try { order = Request["orderField"].ToString(); } catch { } if (order.Trim() == "${param.orderField}") { order = ""; } int pagesize = Convert.ToInt32(evalModel.pageSize); int pagecount = Convert.ToInt32(evalModel.pagecount); int currentPage = Convert.ToInt32(evalModel.currentPage); evalModel.DataModel = evalModel.DataModel ?? new T_CKD(); if (Request["strCKDName"] != null) //出库单号 { string str = Request["strCKDName"].ToString(); if (!String.IsNullOrEmpty(str)) { evalModel.DataModel.CKDH = str.Trim(); } ViewData["strCKDName"] = str; } if (Request["strCKDMC"] != null) //出库单名称 { string str = Request["strCKDMC"].ToString(); if (!String.IsNullOrEmpty(str)) { evalModel.DataModel.CKMC = str.Trim(); } } var ghId = 0; if (Request["strCKDGHQY"] != null) { var str = Request["strCKDGHQY"].ToString(); if (!string.IsNullOrEmpty(str)) { ghId = Convert.ToInt32(str); } ViewData["strCKDGHQY"] = str; } var cpId = 0; //产品名称 if (Request["strCKDCPMC"] != null) { string str = Request["strCKDCPMC"].ToString(); if (!String.IsNullOrEmpty(str)) { cpId = Convert.ToInt32(str); } ViewData["strCKDCPMC"] = str; } var scId = 0; //生产企业ID if (Request["strCKDSCQY"] != null) { string str = Request["strCKDSCQY"].ToString(); if (!String.IsNullOrEmpty(str)) { scId = Convert.ToInt32(str); } ViewData["strCKDSCQY"] = str; } //购货企业列表 T_CusQY cusqy = new T_CusQY(); ViewBag.CUSQY = new SelectList(T_CusQYDomain.GetInstance().GetAllT_CusQY(cusqy).Where(p => p.CusStatus == 1).ToList(), "CusID", "CusMC"); T_SupQYModels supmode = new T_SupQYModels(); supmode.DataModel = supmode.DataModel ?? new T_SupQY(); supmode.DataList = T_SupQYDomain.GetInstance().GetAllT_SupQY(supmode.DataModel).Where(p => p.SupStatus == 1).ToList(); ViewData["SupQYList"] = new SelectList(supmode.DataList, "SupID", "SupMC"); T_YLCPModels ylcpQymode = new T_YLCPModels(); ylcpQymode.DataModel = ylcpQymode.DataModel ?? new T_YLCP(); ylcpQymode.DataList = T_YLCPDomain.GetInstance().GetAllT_YLCP(ylcpQymode.DataModel).Where(p => p.CPStatus == 1).ToList(); ViewData["YLCP"] = new SelectList(ylcpQymode.DataList, "CPID", "CPMC"); evalModel.DataList = T_CKDDomain.GetInstance().PageT_CKD(evalModel.DataModel, evalModel.StartTime, evalModel.EndTime, currentPage, pagesize, cpId, scId, ghId, out pagecount, out resultCount); evalModel.resultCount = resultCount; return(View("~/Views/T_CKD/Index.cshtml", evalModel)); }