JS 打印报表

  <script type="text/javascript">

        window.print(); 

    </script>

前台页面:

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Maxuni.Entity.VOutProceExel>>" %>



<!DOCTYPE html>

<html>

<head id="Head1" runat="server">

    <title>打印外协发出订单</title>

    <style type="text/css">

        .table1

        {

            border-bottom-color: Black;

            border-left-color: Black;

            border-right-color: Black;

            border-collapse: collapse;

            background-color: #FFFFFF;

            width: 100%;

        }

        .td1

        {

            border-bottom-color: Black;

            border-left-color: Black;

            border-right-color: Black;

            border-collapse: collapse;

            border-top-color: Black;

        }

    </style>

    <script type="text/javascript">

        window.print(); 

    </script>

</head>

<body>

    <div style="text-align: center; vertical-align: middle; width: 100%;" layouth="116"

        id="order_panel">

        <table style="width: 100%; text-align: left">

            <tr>

                <td colspan="2" style="width: 70%;">

                    <div style="float: left;">

                        <img alt="" src="../../../../Content/images/Maxuni_logo_2.jpg" style="float: left;

                            margin: 15px 0px 0px 10px" />

                    </div>

                    <br />

                    <br />

                    <br />

                    <div style="font-size: 18px; font-weight: bold">

                        <%=ViewData["companyname"] %></div>

                    <div style="font-size: 13px; font-family: 宋体">

                        工厂地址:<%=ViewData["address"]%><br />

                        电话:<%=ViewData["tel"]%>

                        <br />

                        传真:<%=ViewData["fax"]%><br />

                        网址:<%=ViewData["homepage"]%><br />

                        Email:<%=ViewData["email"]%>

                    </div>

                </td>

                <td style="width: 30%">

                    <table class="table1" cellpadding="0" cellspacing="0" border="1" bordercolorlight="#000000"

                        style="text-align: center; font-size: 13px; font-family: 宋体">

                        <tr style="height: 30px">

                            <td class="td1">

                                &nbsp;外&nbsp;协&nbsp;订&nbsp;单

                            </td>

                        </tr>

                        <tr style="height: 30px">

                            <td class="td1">

                                <%=ViewData["OrderNo"] %>

                            </td>

                        </tr>

                    </table>

                </td>

            </tr>

        </table>

        <table width="100%" style="text-align: left; font-size: 13px; font-family: 宋体">

            <tr>

                <td style="width: 20%">

                 

                </td>

                <td style="width: 30%">

                </td>

                <td style="width: 30%">

                </td>

                <td style="width: 20%">

                    日期:<%=DateTime.Now.ToString("yyyy-MM-dd") %>

                </td>

            </tr>

        </table>

        <table class="table1" cellpadding="0" cellspacing="0" border="1" bordercolorlight="#000000"

            style="text-align: left; font-size: 13px; font-family: 宋体">

            <tr>

                <td style="width: 40%" class="td1">

                    厂商:<%=ViewData["strsupplierName"]%>

                </td>

                <td style="width: 20%" class="td1">

                    联系人:<%=ViewData["strcontactperson1"] %>

                </td>

                <td style="width: 20%" class="td1">

                    电话:<%=ViewData["strtel"] %>

                </td>

                <td style="width: 20%" class="td1">

                    传真:<%=ViewData["strfax"]%>

                </td>

            </tr>

        </table>

        <table width="100%" style="text-align: left; font-size: 13px; font-family: 宋体">

            <tr>

                <td>

                    兹向贵公司订购以下货品如下表列,请在即日起,当天之内签回副本 !

                </td>

            </tr>

        </table>

        <table class="table1" cellpadding="0" cellspacing="0" border="1" bordercolorlight="#000000"

            style="font-size: 14px; font-family: 宋体">

            <thead>

                <tr>

                

                  <th class="td1">

                       序号

                    </th>

                  <th class="td1">

                        模具编号

                    </th>

                    <th class="td1">

                        零件名称

                    </th>

                    <th class="td1">

                        零件编号

                    </th>

                    <th class="td1">

                        加工内容/要求

                    </th>

                    <th class="td1">

                        件数

                    </th>

                    <th class="td1">

                       规格加工备注

                    </th>

                    <th class="td1">

                        单价

                    </th>

                    <th class="td1">

                        总价

                    </th>

                    <th class="td1">

                        交期

                    </th>                    

                </tr>

            </thead>

            <tbody>

                <% int i = 1; %>

                <% foreach (var item in Model)

                   { %><tr>

                       <td class="td1">

                           <%:   i++ %>

                       </td>

                       <td class="td1">

                           <%: item.mouldNo %>

                       </td>

                       <td class="td1">

                           <%: item.partName %>

                       </td>

                       <td class="td1">

                           <%: item.drawingNo %>

                       </td>

                       <td class="td1">

                           <%: item.OutTypeName %>

                       </td>

                       <td class="td1">

                           <%: item.qty %>

                       </td>

                       <td class="td1">

                           <%: item.processRequire %>

                       </td>

                       <td class="td1">

                           <%:  item.Price%>

                       </td>

                       <td class="td1">

                           <%: item.TotaPricel %>

                       </td>

                       <td class="td1">

                           <%: item.oendDate.Value.ToString("yyyy-MM-dd") %>

                       </td>                      

                   </tr>

                <% } %>

                <tr>

                    <td colspan="8" align="right" class="td1">

                        合计(RMB)

                    </td>

                    <td class="td1">

                        <%=ViewData["TotalPrice"]%>

                    </td>

                    <td  class="td1">

                    折扣:<%=ViewData["discount"]%>%

                    </td>

                </tr>

            </tbody>

        </table>

        <table width="100%" style="text-align: left; font-size: 13px; font-family: 宋体">

            <% foreach (var item in ViewData["allcond"] as IList<Maxuni.Entity.OrderCond>)

               { %><tr>

                   <td class="td1">

                       (<%:  item.SortId%>)

                       <%:  item.CondContent%>

                   </td>

               </tr>

            <%} %>

        </table>

        <br />

        <table class="table1" cellpadding="0" cellspacing="0" border="1" bordercolorlight="#000000"

            style="font-size: 13px; font-family: 宋体; text-align: center">

            <tr>

                <td style="width: 25%;" class="td1">

                    经办人

                </td>

                <td style="width: 25%;" class="td1">

                    甲方审查

                </td>

                <td style="width: 25%;" class="td1">

                    甲方批准

                </td>

                <td style="width: 25%;" class="td1">

                    卖方确认(供应商)

                </td>

            </tr>

            <tr>

                <td style="width: 25%;" class="td1">

                    &nbsp;<%=ViewData["currentuser"]%>

                </td>

                <td style="width: 25%;" class="td1">

                    &nbsp;

                </td>

                <td style="width: 25%;" class="td1">

                    &nbsp;

                </td>

                <td style="width: 25%;" class="td1">

                    &nbsp;

                </td>

            </tr>

            <tr>

                <td style="width: 25%;" class="td1">&nbsp;&nbsp;&nbsp;&nbsp;月&nbsp;&nbsp;&nbsp;&nbsp;日

                </td>

                <td style="width: 25%;" class="td1">&nbsp;&nbsp;&nbsp;&nbsp;月&nbsp;&nbsp;&nbsp;&nbsp;日

                </td>

                <td style="width: 25%;" class="td1">&nbsp;&nbsp;&nbsp;&nbsp;月&nbsp;&nbsp;&nbsp;&nbsp;日

                </td>

                <td style="width: 25%;" class="td1">&nbsp;&nbsp;&nbsp;&nbsp;月&nbsp;&nbsp;&nbsp;&nbsp;日

                </td>

            </tr>

        </table>

    </div>

</body>

</html>
View Code

后台信息:

using System.Linq;

using System.Web.Mvc;

using Maxuni.Entity;

using Maxuni.Repository;

using System.Collections.Generic;



namespace MaxuniWeb.Areas.outProcessGL

{

    public class VOutProceExelController : BaseController<VOutProceExel>

    {

        VOutProceExelRepository objVOutProceExelRepository = new VOutProceExelRepository();

        CompayRepository objCompayRepositoryRepository = new CompayRepository();

        OrderCondRepository objOrderCondRepository = new OrderCondRepository();

        SupplierRepository objSupplierRepository = new SupplierRepository();

        OProcessRequisitionRepository objOProcessRequisitionRepository = new OProcessRequisitionRepository();



        public VOutProceExelController()

        {

            //写查询条件,比如:base.strConditions = " RoleName like '%{0}%' and 1=1 "; 

            base.strConditions = " 1=1 ";

            base.objBaseRepository = this.objVOutProceExelRepository;



        }

        [MaxuniAuthAttribute(Roles = "sysroles")]

        public ActionResult PrintIndex(string id)

        {



            var obj = objOProcessRequisitionRepository.GetOneRecord(id);

            string strWhere = " from VOutProceExel where OProcessRequisitionId='" + obj.Id + "'";           

            var objlist = objBaseRepository.GetAll(strWhere);

            GetSupplierCompanyInfo(id);

            ViewData["TotalPrice"] = obj.discountPrice;

            ViewData["currentuser"] = CurrentUser.Username;

            ViewData["discount"] = obj.discount;

            return View(objlist);

        }

       



        private void GetSupplierCompanyInfo(string id)

        {

            string suppliercontactperson1 = "";

            string supplierName = "";

            string supplierpaymentType = "";

            string suppliertel = "";

            string supplierfax = "";

            string supplierOrderNo = "";

            GetSupplierinfo(id, out  suppliercontactperson1, out  supplierName, out  supplierpaymentType, out  suppliertel, out  supplierfax, out  supplierOrderNo);



            string CompayName = "";

            string address = "";

            string tel = "";

            string fax = "";

            string homepage = "";

            string email = "";

            GetCompanyAddres(out  CompayName, out  address, out  tel, out  fax, out  homepage, out  email);

        }



        #region 从数据库获取合约的信息条款

        private void GetSupplierinfo(string id, out string suppliercontactperson1, out string supplierName, out string supplierpaymentType, out string suppliertel, out string supplierfax, out string supplierOrderNo)

        {

            OProcessRequisition objOrderApply = objOProcessRequisitionRepository.GetOneRecord(id);

            string strSupplierid = objOrderApply.supplierID;

            Supplier objsupplier = new Supplier();

            if (!string.IsNullOrEmpty(strSupplierid))

                objsupplier = objSupplierRepository.GetOneRecord(strSupplierid);



            suppliercontactperson1 = objsupplier.contactperson1;

            supplierName = objsupplier.supplierName;

            supplierpaymentType = objsupplier.paymentType + ";税率:" + objsupplier.taxRate;

            suppliertel = objsupplier.tel;

            supplierfax = objsupplier.fax;

            supplierOrderNo = objOrderApply.contractNO;



            ViewData["strcontactperson1"] = objsupplier.contactperson1;

            ViewData["strsupplierName"] = objsupplier.supplierName;

            ViewData["paymentType"] = objsupplier.paymentType;

            ViewData["strtel"] = objsupplier.tel;

            ViewData["strfax"] = objsupplier.fax;

            ViewData["OrderNo"] = objOrderApply.contractNO;



            IList<OrderCond> objordercond = objOrderCondRepository.GetAll(" from OrderCond where  TypeNo=1").OrderBy(o => o.SortId).ToList();

            var objplaymenthod = objordercond.FirstOrDefault(o => o.SortId ==12);          

            var obj = objplaymenthod;

            objordercond.Remove(objplaymenthod);            

            obj.CondContent = objplaymenthod.CondContent.Replace(":", "").Replace("", "") + ":" + objsupplier.paymentType + ";税率:" + objsupplier.taxRate;

            objordercond.Insert(11, obj);

            ViewData["allcond"] = objordercond;

        }

        #endregion



        #region 获取供应商的详细信息

        private void GetCompanyAddres(out string CompayName, out string address, out string tel, out string fax, out string homepage, out string email)

        {

            var model = objCompayRepositoryRepository.GetAll();

            CompayName = "";

            address = "";

            tel = "";

            fax = "";

            homepage = "";

            email = "";

            if (model.Count > 0)

            {

                CompayName = model[0].CompayName;

                address = model[0].address;

                tel = model[0].tel;

                fax = model[0].fax;

                homepage = model[0].homepage;

                email = model[0].email;

                ViewData["companyname"] = model[0].CompayName;

                ViewData["address"] = model[0].address;

                ViewData["tel"] = model[0].tel;

                ViewData["fax"] = model[0].fax;

                ViewData["homepage"] = model[0].homepage;

                ViewData["email"] = model[0].email;

            }

        }

        #endregion



    }

}
View Code

 

你可能感兴趣的:(js)