zoukankan      html  css  js  c++  java
  • ERP采购申请管理(三十九)

    获取当前表单在流程中的状态:

             /// <summary>
            /// 获取当前表单在流程表中的状态
            /// </summary>
            /// <param name="listid"></param>
            /// <returns></returns>
            public static String getAuditingSateByCondition(string listid)
            {
                object obj = SqlComm.GetObjectByCondition("TaskListRecord", " TOP 1 AuditingSate ", " ListID=" + listid + " ORDER BY ListID desc");
                if (obj != null)
                {
                    return obj.ToString();
                }
                else
                {
                    return null;
                }
            }
    

    判断选中的状态:

     //根据表单单号在流程表中查询历史审批记录绑定信息
                this.lbRemarks.Text= SqlComm.getTaskListRecordsMindsByCondition(taskid, ((int)TaskNavigateEmun.ProPurchase).ToString());
                if (SqlComm.getAuditingSateByCondition("listid") == "2")
                {
                    this.cb_Stock.Checked = true;
                }
    

    商品采购审核单详细信息查看:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ProPurchaseShow.aspx.cs"
        Inherits="BioErpWeb.WholeSaleSystem.ProPurchase.ProPurchaseShow" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <link href="../../Styles/ERPBaseStyle.css" rel="stylesheet" type="text/css" />
        <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
        <script src="../../Scripts/jquery.validate.js" type="text/javascript"></script>
        <script src="../../Scripts/validateExtender.js" type="text/javascript"></script>
        <script src="../../Scripts/ValidateMessage_ZW.js" type="text/javascript"></script>
        <script src="../../Scripts/jquery.metadata.js" type="text/javascript"></script>
        <link href="../../Styles/InputStyle1.css" rel="stylesheet" type="text/css" />
        <script src="../../JS/CheckDepartMent.js" type="text/javascript"></script>
        <link href="../../Styles/CalenderStyle.css" rel="stylesheet" type="text/css" />
        <script src="../../Scripts/cld.js" type="text/javascript"></script>
        <script src="../../JS/CheckUserName.js" type="text/javascript"></script>
        <script src="../../JS/CustomerName.js" type="text/javascript"></script>
        <script src="../../JS/ProNameChoose.js" type="text/javascript"></script>
        <script src="../../Scripts/Comm.js" type="text/javascript"></script>
         <style type="text/css">
            #pricetable
            {
                border: none;
                 99%;
            }
            #pricetable td
            {
                border: none;
            }
            #divprobatch
            {
                 99%;
                border: none;
            }
            #divprobatch table
            {
                 100%;
                border: none;
            }
            #divprobatch table td
            {
                border: none;
                padding-right: 2px;
                 
            }
            .grayborder{ border:solid 1px #ccc;}
            .bordernone{ border-left:none; border-top:none; border-right:none; border-bottom:none;}
        </style>
    
        <script type="text/javascript">
            var tri = 0;
            $(document).ready(function () {
                $("#form1").validate();
                $(document).find("input[type='text']").each(function () {
                    $(this).attr("readonly", "true");
                });
    
                $(document).find("input[type='checkbox']").each(function () {
                    $(this).attr("disabled", "disabled");
                })
    
                $("#trprotitle").css("background-color", "#eee");
                $("#probatchtr").css("background-color", "#eee");
    
            });
            function addrows(count) {
    
                for (var i = 0; i < count; i++) {
                    tri++;
                    var tr = '<tr id="tr' + tri + '"><td><input  type="text" name="proName" class="required"
    style=" 294px"/><input type="hidden" name="proID" /></td><td><input type="text" name="proCount" class="{required:true,min:1,digits:true}"
    style=" 150px"/></td><td colspan="2"><input type="text" name="proPrice" class="{required:true,min:0.1,number:true}" style=" 150px"/>
    <input type="hidden" name="purchaseProID"/></td></tr>'; var obj = $("#troption"); $(obj).after(tr); } } //产品信息赋值 function setValues(proName, proID, proCount, proPrice, purchaseProID) { var proNames = proName.split(','); var proIDs = proID.split(','); var proCounts = proCount.split(','); var proPrices = proPrice.split(','); var purchaseProIDs=purchaseProID.split(','); var txtProName = document.getElementsByName("proName"); var txtProID = document.getElementsByName("proID"); var txtProCount = document.getElementsByName("proCount"); var txtproPrice = document.getElementsByName("proPrice"); var txtpurchaseProID = document.getElementsByName("purchaseProID"); for (var i = 0; i <(proIDs.length-1); i++) { txtProName[i].value = proNames[i]; txtProID[i].value = proIDs[i]; txtProCount[i].value = proCounts[i]; txtproPrice[i].value = proPrices[i]; txtpurchaseProID[i].value = purchaseProIDs[i]; } } function deleterow() { var obj = window.event.srcElement; var parenttr = obj.parentNode.parentNode; $(parenttr).remove(); } //根据后台传过来的产品批次个数,添加相应行数 function setaddbatchs(count) { var trbatch = '<tr> <td id="td2"><input id="txtProName0" value="" readonly="readonly" name="txtProName0"
    style=" 294px" type="text" class="input" size="50" /><input type="hidden" name="proIds" value=""/> </td>'; trbatch += '<td><input id="txtProCount0" name="txtProCount0" class="{required:true,min:1,digits:true}"
    type="text" size="5" /></td><td><input id="txtProBatch0" name="txtProBatch0" type="text" size="11" /> </td>'; trbatch += '<td><input id="txtProBoxNum0" name="txtProBoxNum0" value="" readonly="readonly" type="text" size="11" /> </td>'; trbatch += '<td><input id="txtMarkDate0" name="txtMarkDate0" onfocus="setday(this)" onclick="setday(this)"
    size="11" class="{required:true,dateISO:true}" type="text" readonly="readonly" /></td>'; trbatch += '<td><input id="txtExPirationDate0" onfocus="setday(this)"
    onclick="setday(this)" name="txtExPirationDate0" class="{required:true,dateISO:true}" size="11" type="text" readonly="readonly" />'; trbatch += '</td><td><input type="hidden" value="" name="PurchaseProID2"/>'; trbatch += '</td></tr>'; for (var i = 0; i < count; i++) { $("#probatchtr").after(trbatch); } } function setbatchsvalues(proname, proId, txtProCount, txtProBatch, txtProBoxNum, txtMarkDate, txtExPirationDate, PurchaseProID) { var pronames = proname.split(","); var proIds = proId.split(","); var ProCouns = txtProCount.split(","); var ProBatchs = txtProBatch.split(","); var ProBoxNums = txtProBoxNum.split(","); var MarkDates = txtMarkDate.split(","); var ExPirationDates = txtExPirationDate.split(","); var PurchaseProIDs = PurchaseProID.split(","); var txtProName0s = document.getElementsByName("txtProName0"); var txtproIds = document.getElementsByName("proIds") var txtProCount0 = document.getElementsByName("txtProCount0"); var txtProBatch0 = document.getElementsByName("txtProBatch0"); var txtProBoxNum0 = document.getElementsByName("txtProBoxNum0"); var txtMarkDate0 = document.getElementsByName("txtMarkDate0"); var txtExPirationDate0 = document.getElementsByName("txtExPirationDate0"); var PurchaseProID2 = document.getElementsByName("PurchaseProID2"); for (var i = 0; i < txtProName0s.length; i++) { txtProName0s[i].value = pronames[i]; txtproIds[i].value = proIds[i]; txtProCount0[i].value = ProCouns[i]; txtProBatch0[i].value = ProBatchs[i]; txtProBoxNum0[i].value = ProBoxNums[i]; txtMarkDate0[i].value = MarkDates[i]; txtExPirationDate0[i].value = ExPirationDates[i]; PurchaseProID2[i].value = PurchaseProIDs[i]; } } </script> </head> <body> <form id="form1" runat="server"> <div style=" 99%; height:750px; overflow:scroll;"> <table class="maintable Inupttable" style=" 900px;"> <tr> <td colspan="8" class="titlebar"> 商品采购审核单详细信息查看 </td> </tr> <tr> <td> 申请部门 </td> <td> <asp:TextBox ID="ddlDepartMent" runat="server"></asp:TextBox> </td> <td> 制表人 </td> <td class="style1"> <asp:Label ID="lbApplayUser" runat="server"></asp:Label> </td> <td> 经手人 </td> <td> <asp:TextBox ID="txtRealUserID" CssClass="{required:true,digits:true, min:1}" runat="server" Width="78px"></asp:TextBox> <asp:Label ID="lbOldRealName" runat="server" Text="Label"></asp:Label> </td> <td> 制表时间 </td> <td> <asp:Label ID="lbTime" runat="server" Text="Label"></asp:Label> </td> </tr> <tr> <td> 发货(订货)单位 </td> <td> <asp:TextBox ID="txtSendCom" runat="server" Width="72px" CssClass="{required:true,digits:true, min:1}"></asp:TextBox> <asp:Label ID="lbOldSenComName" runat="server" Text="Label"></asp:Label> </td> <td> 入库单位 </td> <td class="style1"> <asp:TextBox ID="ddlOrderCom" runat="server" Width="72px"></asp:TextBox> </td> <td> 采购方式 </td> <td> <asp:TextBox ID="ddlSaleType" runat="server" Width="72px"></asp:TextBox> </td> <td> 入库方式 </td> <td> <asp:TextBox ID="ddlTypes" runat="server" Width="72px"></asp:TextBox> </td> </tr> <tr> <td colspan="8" style="border: none;" class="style2"> <div> <table id="tableprolist" style="99%; border: solid 1px; border-collapse: collapse; line-height: 25px;"> <tr id="trprotitle"> <td> 产品名称及规格 </td> <td> 数量 </td> <td colspan="2"> 单价 </td> </tr> <tr id="troption"> <td> <input type="text" name="proName" class="required" style=" 294px" /><input type="hidden" name="proID" /> </td> <td> <input type="text" name="proCount" class="{required:true,min:1,digits:true}" style=" 150px" /> </td> <td colspan="2"> <input type="text" name="proPrice" class="{required:true,min:0.1,number:true}" style=" 150px" /> <input type="hidden" name="purchaseProID"/> </td> </tr> <tr id="caption"> <td colspan="4" style="text-align: right;"> </td> </tr> <tr> <td colspan="4"> <div id="divprobatch" style="display: none;"> <table id="tb2" align="left" cellpadding="0" border="0" cellspacing="0" width="100%" style=" margin:0px auto;"> <tr id="probatchtr"> <td> 订货产品名称及规格(只读) </td> <td style=" 70px;"> 数量 </td> <td style=" 95px;"> 批号 </td> <td style=" 95px;"> 货号(只读) </td> <td style=" 150px;"> 生产日期 </td> <td style=" 150px;"> 有效期 </td> </tr> </table> </div> </td> </tr> <tr> <td colspan="4"> <table id="pricetable"> <tr> <td> <asp:Label ID="lbTotal" runat="server" Text="产品总额"></asp:Label> <asp:Label ID="lbTotalInvoicePrice" runat="server" Text=""></asp:Label> </td> <td> <asp:Label ID="lbisPay" Visible="false" runat="server" Text="是否付款:"></asp:Label><asp:CheckBox ID="isPay" runat="server" Visible="false" /> </td> <td> <asp:Label ID="lbBill" runat="server" Text="账单编号:" Visible="false"></asp:Label> <asp:TextBox ID="txtBillNo" runat="server" Visible="false"></asp:TextBox> </td> <td> <asp:Label ID="lbPayuser" runat="server" Text=" 付款人:" Visible="false"></asp:Label> <asp:TextBox ID="txtBillUser" runat="server" Visible="false"></asp:TextBox> <asp:Label ID="lbBillUserName" runat="server" Text="Label"></asp:Label>   </td> </tr> </table> </td> </tr> </table> </div> <div id="proAuditing" style=" display:none;"> 产品质量审核:<asp:CheckBox ID="cb_Auditing" Text="质量审核合格" runat="server" /> </div> <div id="stockAuditing" style=" display:none;"> <span>仓库审核:<asp:CheckBox ID="cb_Stock" Text="仓库审核合格" runat="server" /></span> </span> </div> </td> </tr> <tr> <td> 历史审批意见 </td> <td colspan="7"> <asp:Label ID="lbRemarks" runat="server" Text=""></asp:Label> </td> </tr> <tr> <td colspan="8" class="bottomtd">  </td> </tr> </table> </div> </form> </body> </html>

     后台代码:

     public partial class ProPurchaseShow: BasePage
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {                          
                  
                    getdata();
                   
                    getprobatchDetail();
                }
           
            }
            /// <summary>
            /// 批号信息加载
            /// </summary>
            public void getprobatchDetail()
            {
                BioPurchaseBLL pbll = new BioPurchaseBLL();
                string id = Request.QueryString["taskid"];
                //string id = "10";
    
                DataTable dt = pbll.getProBatchDetailByPurchaseID(id);
                #region  加载产品批号信息
                if (dt.Rows.Count > 0)
                {
                    int count = dt.Rows.Count;
                    //2011年12月2日19:27:17
                    //显示添加批号的前端方法修改为:showobj
                    ClientScript.RegisterStartupScript(this.GetType(), "showobj", "showobj('divprobatch');setaddbatchs(" + count + ");", true);
                    string proname = "";
                    string proId = "";
                    string txtProCount = "";
                    string txtProBatch = "";
                    string txtProBoxNum = "";
                    string txtMarkDate = "";
                    string txtExPirationDate = "";
                    string PurchaseProID = "";
    
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        proname += dt.Rows[i]["proName"].ToString() + ",";
                        proId += dt.Rows[i]["proID"].ToString() + ",";
                        txtProCount += dt.Rows[i]["proCount"].ToString() + ",";
                        txtProBatch += dt.Rows[i]["batchNum"].ToString() + ",";
                        txtProBoxNum += dt.Rows[i]["boxNum"].ToString() + ",";
                        txtMarkDate += Convert.ToDateTime(dt.Rows[i]["makeDate"].ToString()).ToString("yyyy-MM-dd") + ",";
                        txtExPirationDate += Convert.ToDateTime(dt.Rows[i]["expirationDate"].ToString()).ToString("yyyy-MM-dd") + ",";
                        PurchaseProID += dt.Rows[i]["purchaseProID"].ToString() + ",";
    
                    }
    
                    ClientScript.RegisterStartupScript(this.GetType(), "setbatchsvalues", "setbatchsvalues('" + proname + "','" 
    + proId + "','" + txtProCount + "','" + txtProBatch + "','" + txtProBoxNum + "','" + txtMarkDate + "','"
    + txtExPirationDate + "','" + PurchaseProID + "');", true); #endregion //判断是否存在此产品的批号信息 if (dt.Rows.Count>0) { //当前登录用户是否有产品质量审核权限 值50 if (SqlComm.getUserRightsByUserId(Session["Userid"].ToString()).Contains(",50,")) { ClientScript.RegisterStartupScript(this.GetType(), "test", "showobj('proAuditing');", true); if (pbll.getauditingProBatchCountByPurchaseID(id) != 0) { this.cb_Auditing.Checked = true; } } else { if (pbll.getauditingProBatchCountByPurchaseID(id) != 0) { ClientScript.RegisterStartupScript(this.GetType(), "test", "showobj('proAuditing');", true); this.cb_Auditing.Checked = true; this.cb_Auditing.Enabled = false; } } //如果产品批号已经审核 并且 当前登录用户是仓库管理员 则显示相应控件 if (pbll.getauditingProBatchCountByPurchaseID(id) != 0 && SqlComm.getUserRightsByUserId(Session["Userid"].ToString()).Contains(",25,")) { ClientScript.RegisterStartupScript(this.GetType(), "test1", "showobj('stockAuditing');", true); } } } } protected void getdata() { ////如果获取阐述不存在直接跳转。 if (Request.QueryString["taskid"] == null || Request.QueryString["listid"] == null) { Response.Write("<script>window.history.go(-1);this.close()</script>"); } string taskid = Request.QueryString["taskid"].ToString(); string listid = Request.QueryString["listid"].ToString(); //string taskid = "10"; //string listid = "50"; string rights= SqlComm.getUserRightsByUserId(Session["Userid"].ToString()); BioPurchaseBLL purchasebll=new BioPurchaseBLL(); ViewBioPurchaseAppInfo viewpurchase = purchasebll.getViewBioPurchaseAppInfo(taskid); ddlDepartMent.Text=viewpurchase.DepartMent.ToString(); this.lbApplayUser.Text = viewpurchase.AppUserName.ToString(); this.lbOldRealName.Text = viewpurchase.RealUserName; this.txtRealUserID.Text = viewpurchase.RealUserID.ToString(); this.lbTime.Text = Convert.ToDateTime(viewpurchase.OrderTime).ToString("yyyy-MM-dd"); this.lbOldSenComName.Text = viewpurchase.CopanyName; this.txtSendCom.Text = viewpurchase.sendComID.ToString(); this.ddlOrderCom.Text = viewpurchase.OrderCom.ToString(); this.ddlSaleType.Text = viewpurchase.WholeType; this.ddlTypes.Text = viewpurchase.sendType; //判断是否数据库中已经添加了财务审核的记录 if (viewpurchase.BillNo != "" && viewpurchase.BillNo != null) { this.lbBill.Visible = true; this.lbisPay.Visible = true; this.isPay.Visible = true; this.txtBillNo.Visible = true; this.lbPayuser.Visible = true; this.txtBillUser.Visible = true; this.txtBillUser.Text = viewpurchase.BillUserID.ToString(); this.txtBillNo.Text = viewpurchase.BillNo.ToString(); this.lbBillUserName.Text = viewpurchase.BillUserName.ToString(); int paycount = int.Parse(SqlComm.GetObjectByCondition("dbo.BioPurchasePro", "count(isPay)", " PurchaseID="+taskid).ToString()); if (paycount > 0) { this.isPay.Checked = true; } } else { if (rights.Contains(",48,")) { this.lbBill.Visible = true; this.lbisPay.Visible = true; this.isPay.Visible = true; this.txtBillNo.Visible = true; this.lbPayuser.Visible = true; this.txtBillUser.Visible = true; this.txtBillUser.Text = Session["Userid"].ToString(); this.txtBillNo.Text = DateTime.Now.ToString("yyyyMMdd") + taskid; } } //根据表单单号在流程表中查询历史审批记录绑定信息 this.lbRemarks.Text= SqlComm.getTaskListRecordsMindsByCondition(taskid, ((int)TaskNavigateEmun.ProPurchase).ToString()); if (SqlComm.getAuditingSateByCondition("listid") == "2") { this.cb_Stock.Checked = true; } //根据表单编号查询产品基本信息并绑定 DataTable dt = SqlComm.GetDataByCondition("View_BioPurchaseProInfo",
    "ProID,ProName,ProCount,ProPrice,InvoicePrice,purchaseProID", "PurchaseID=" + taskid).Tables[0]; int count = dt.Rows.Count; ClientScript.RegisterStartupScript(this.GetType(), "addrows", "addrows(" + (count-1) + ");", true); string proNames = ""; string proIDs = ""; string proCounts = ""; string proPrices = ""; decimal totalInvoicePrice = 0; string purchaseProIDs = ""; for (int i = 0; i < dt.Rows.Count; i++) { proIDs+= dt.Rows[i]["ProID"].ToString()+","; proNames+=dt.Rows[i]["ProName"].ToString()+","; proCounts+= dt.Rows[i]["ProCount"].ToString()+","; proPrices+= decimal.Parse(dt.Rows[i]["ProPrice"].ToString()).ToString("0.0")+","; totalInvoicePrice += decimal.Parse(dt.Rows[i]["InvoicePrice"].ToString()); purchaseProIDs += dt.Rows[i]["purchaseProID"].ToString() + ","; } ClientScript.RegisterStartupScript(this.GetType(), "setValues",
    "setValues('" + proNames + "','" + proIDs + "','" + proCounts + "','" + proPrices + "','" + purchaseProIDs + "');", true); this.lbTotalInvoicePrice.Text = totalInvoicePrice.ToString("0.0"); } }

     产品的执行状态页面(完成页面):

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ProPurchaseRun.aspx.cs"
        Inherits="BioErpWeb.WholeSaleSystem.ProPurchase.ProPurchaseRun" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <link href="../../Styles/ERPBaseStyle.css" rel="stylesheet" type="text/css" />
        <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
        <script src="../../Scripts/jquery.validate.js" type="text/javascript"></script>
        <script src="../../Scripts/validateExtender.js" type="text/javascript"></script>
        <script src="../../Scripts/ValidateMessage_ZW.js" type="text/javascript"></script>
        <script src="../../Scripts/jquery.metadata.js" type="text/javascript"></script>
        <link href="../../Styles/InputStyle1.css" rel="stylesheet" type="text/css" />
        <script src="../../JS/CheckDepartMent.js" type="text/javascript"></script>
        <link href="../../Styles/CalenderStyle.css" rel="stylesheet" type="text/css" />
        <script src="../../Scripts/cld.js" type="text/javascript"></script>
        <script src="../../JS/CheckUserName.js" type="text/javascript"></script>
        <script src="../../JS/CustomerName.js" type="text/javascript"></script>
        <script src="../../JS/ProNameChoose.js" type="text/javascript"></script>
        <script src="../../Scripts/Comm.js" type="text/javascript"></script>
         <style type="text/css">
            #pricetable
            {
                border: none;
                 99%;
            }
            #pricetable td
            {
                border: none;
            }
            #divprobatch
            {
                 99%;
                border: none;
            }
            #divprobatch table
            {
                 100%;
                border: none;
            }
            #divprobatch table td
            {
                border: none;
                padding-right: 2px;
                 
            }
            .grayborder{ border:solid 1px #ccc;}
            .bordernone{ border-left:none; border-top:none; border-right:none; border-bottom:none;}
        </style>
    
        <script type="text/javascript">
            var tri = 0;
            $(document).ready(function () {
                $("#form1").validate();
                $(document).find("input[type='text']").each(function () {
                    $(this).attr("readonly", "true");
                });
    
                $(document).find("input[type='checkbox']").each(function () {
                    $(this).attr("disabled", "disabled");
                })
    
                $("#trprotitle").css("background-color", "#eee");
                $("#probatchtr").css("background-color", "#eee");
    
            });
            function addrows(count) {
    
                for (var i = 0; i < count; i++) {
                    tri++;
                    var tr = '<tr id="tr' + tri + '"><td><input  type="text" name="proName" 
    class="required" style=" 294px"/><input type="hidden" name="proID" />
    </td><td><input type="text" name="proCount" class="{required:true,min:1,digits:true}" style=" 150px"/></td>
    <td colspan="2"><input type="text" name="proPrice" class="{required:true,min:0.1,number:true}" style=" 150px"/>
    <input type="hidden" name="purchaseProID"/></td></tr>'; var obj = $("#troption"); $(obj).after(tr); } } //产品信息赋值 function setValues(proName, proID, proCount, proPrice, purchaseProID) { var proNames = proName.split(','); var proIDs = proID.split(','); var proCounts = proCount.split(','); var proPrices = proPrice.split(','); var purchaseProIDs=purchaseProID.split(','); var txtProName = document.getElementsByName("proName"); var txtProID = document.getElementsByName("proID"); var txtProCount = document.getElementsByName("proCount"); var txtproPrice = document.getElementsByName("proPrice"); var txtpurchaseProID = document.getElementsByName("purchaseProID"); for (var i = 0; i <(proIDs.length-1); i++) { txtProName[i].value = proNames[i]; txtProID[i].value = proIDs[i]; txtProCount[i].value = proCounts[i]; txtproPrice[i].value = proPrices[i]; txtpurchaseProID[i].value = purchaseProIDs[i]; } } function deleterow() { var obj = window.event.srcElement; var parenttr = obj.parentNode.parentNode; $(parenttr).remove(); } //根据后台传过来的产品批次个数,添加相应行数 function setaddbatchs(count) {
    var trbatch = '<tr> <td id="td2"><input id="txtProName0" value="" readonly="readonly" name="txtProName0"
    style=" 294px" type="text" class="input" size="50" /><input type="hidden" name="proIds" value=""/> </td>'; trbatch += '<td><input id="txtProCount0" name="txtProCount0" class="{required:true,min:1,digits:true}"
    type="text" size="5" /></td><td><input id="txtProBatch0" name="txtProBatch0" type="text" size="11" /> </td>'; trbatch += '<td><input id="txtProBoxNum0" name="txtProBoxNum0" value="" readonly="readonly" type="text" size="11" /> </td>'; trbatch += '<td><input id="txtMarkDate0" name="txtMarkDate0" onfocus="setday(this)" onclick="setday(this)"
    size="11" class="{required:true,dateISO:true}" type="text" readonly="readonly" /></td>'; trbatch += '<td><input id="txtExPirationDate0" onfocus="setday(this)"
    onclick="setday(this)" name="txtExPirationDate0" class="{required:true,dateISO:true}" size="11" type="text" readonly="readonly" />'; trbatch += '</td><td><input type="hidden" value="" name="PurchaseProID2"/>'; trbatch += '</td></tr>'; for (var i = 0; i < count; i++) { $("#probatchtr").after(trbatch); } } function setbatchsvalues(proname, proId, txtProCount, txtProBatch, txtProBoxNum, txtMarkDate, txtExPirationDate, PurchaseProID) { var pronames = proname.split(","); var proIds = proId.split(","); var ProCouns = txtProCount.split(","); var ProBatchs = txtProBatch.split(","); var ProBoxNums = txtProBoxNum.split(","); var MarkDates = txtMarkDate.split(","); var ExPirationDates = txtExPirationDate.split(","); var PurchaseProIDs = PurchaseProID.split(","); var txtProName0s = document.getElementsByName("txtProName0"); var txtproIds = document.getElementsByName("proIds") var txtProCount0 = document.getElementsByName("txtProCount0"); var txtProBatch0 = document.getElementsByName("txtProBatch0"); var txtProBoxNum0 = document.getElementsByName("txtProBoxNum0"); var txtMarkDate0 = document.getElementsByName("txtMarkDate0"); var txtExPirationDate0 = document.getElementsByName("txtExPirationDate0"); var PurchaseProID2 = document.getElementsByName("PurchaseProID2"); for (var i = 0; i < txtProName0s.length; i++) { txtProName0s[i].value = pronames[i]; txtproIds[i].value = proIds[i]; txtProCount0[i].value = ProCouns[i]; txtProBatch0[i].value = ProBatchs[i]; txtProBoxNum0[i].value = ProBoxNums[i]; txtMarkDate0[i].value = MarkDates[i]; txtExPirationDate0[i].value = ExPirationDates[i]; PurchaseProID2[i].value = PurchaseProIDs[i]; } } </script> </head> <body> <form id="form1" runat="server"> <div style=" 99%; height:750px; overflow:scroll;"> <table class="maintable Inupttable" style=" 900px;"> <tr> <td colspan="8" class="titlebar"> 商品采购审核单 流程结束 </td> </tr> <tr> <td> 申请部门 </td> <td> <asp:TextBox ID="ddlDepartMent" runat="server"></asp:TextBox> </td> <td> 制表人 </td> <td class="style1"> <asp:Label ID="lbApplayUser" runat="server"></asp:Label> </td> <td> 经手人 </td> <td> <asp:TextBox ID="txtRealUserID" CssClass="{required:true,digits:true, min:1}" runat="server" Width="78px"></asp:TextBox> <asp:Label ID="lbOldRealName" runat="server" Text="Label"></asp:Label> </td> <td> 制表时间 </td> <td> <asp:Label ID="lbTime" runat="server" Text="Label"></asp:Label> </td> </tr> <tr> <td> 发货(订货)单位 </td> <td> <asp:TextBox ID="txtSendCom" runat="server" Width="72px" CssClass="{required:true,digits:true, min:1}"></asp:TextBox> <asp:Label ID="lbOldSenComName" runat="server" Text="Label"></asp:Label> </td> <td> 入库单位 </td> <td class="style1"> <asp:TextBox ID="ddlOrderCom" runat="server" Width="72px"></asp:TextBox> </td> <td> 采购方式 </td> <td> <asp:TextBox ID="ddlSaleType" runat="server" Width="72px"></asp:TextBox> </td> <td> 入库方式 </td> <td> <asp:TextBox ID="ddlTypes" runat="server" Width="72px"></asp:TextBox> </td> </tr> <tr> <td colspan="8" style="border: none;" class="style2"> <div> <table id="tableprolist" style="99%; border: solid 1px; border-collapse: collapse; line-height: 25px;"> <tr id="trprotitle"> <td> 产品名称及规格 </td> <td> 数量 </td> <td colspan="2"> 单价 </td> </tr> <tr id="troption"> <td> <input type="text" name="proName" class="required" style=" 294px" /><input type="hidden" name="proID" /> </td> <td> <input type="text" name="proCount" class="{required:true,min:1,digits:true}" style=" 150px" /> </td> <td colspan="2"> <input type="text" name="proPrice" class="{required:true,min:0.1,number:true}" style=" 150px" /> <!--2011年11月29日22:37:47 添加 <input type="hidden" name="purchaseProID"/>--> <input type="hidden" name="purchaseProID"/> </td> </tr> <tr id="caption"> <td colspan="4" style="text-align: right;"> </td> </tr> <tr> <td colspan="4"> <div id="divprobatch" style="display: none;"> <table id="tb2" align="left" cellpadding="0" border="0" cellspacing="0" width="100%" style=" margin:0px auto;"> <tr id="probatchtr"> <td> 订货产品名称及规格(只读) </td> <td style=" 70px;"> 数量 </td> <td style=" 95px;"> 批号 </td> <td style=" 95px;"> 货号(只读) </td> <td style=" 150px;"> 生产日期 </td> <td style=" 150px;"> 有效期 </td> </tr> </table> </div> </td> </tr> <tr> <td colspan="4"> <table id="pricetable"> <tr> <td> <asp:Label ID="lbTotal" runat="server" Text="产品总额"></asp:Label> <asp:Label ID="lbTotalInvoicePrice" runat="server" Text=""></asp:Label> </td> <td> <asp:Label ID="lbisPay" Visible="false" runat="server" Text="是否付款:"></asp:Label><asp:CheckBox ID="isPay" runat="server" Visible="false" /> </td> <td> <asp:Label ID="lbBill" runat="server" Text="账单编号:" Visible="false"></asp:Label> <asp:TextBox ID="txtBillNo" runat="server" Visible="false"></asp:TextBox> </td> <td> <asp:Label ID="lbPayuser" runat="server" Text=" 付款人:" Visible="false"></asp:Label> <asp:TextBox ID="txtBillUser" runat="server" Visible="false"></asp:TextBox> <asp:Label ID="lbBillUserName" runat="server" Text="Label"></asp:Label>   </td> </tr> </table> </td> </tr> </table> </div> <div id="proAuditing" style=" display:none;"> 产品质量审核:<asp:CheckBox ID="cb_Auditing" Text="质量审核合格" runat="server" /> </div> <div id="stockAuditing" style=" display:none;"> <span>仓库审核:<asp:CheckBox ID="cb_Stock" Text="仓库审核合格" runat="server" /></span> </span> </div> </td> </tr> <tr> <td> 历史审批意见 </td> <td colspan="7"> <asp:Label ID="lbRemarks" runat="server" Text=""></asp:Label> </td> </tr> <tr> <td> 备注</td> <td colspan="7"> <asp:TextBox ID="txtRemark" Width="547px" runat="server"></asp:TextBox> </td> </tr> <tr> <td colspan="8" class="bottomtd"> <asp:Button ID="Button1" runat="server" CssClass="btnorange" Text="结束流程" onclick="Button1_Click" /> </td> </tr> </table> <asp:HiddenField ID="hf_applayDepartMent" runat="server" /> <asp:HiddenField ID="hf_subject" runat="server" /> <asp:HiddenField ID="hf_FirstAccepter" runat="server" /> <asp:HiddenField ID="hf_FirstTransmitter" runat="server" /> </div> </form> </body> </html>

     后台的代码:

     public partial class ProPurchaseRun: BasePage
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {         
                    getdata();               
                    getprobatchDetail();
                }
           
            }
            /// <summary>
            /// 批号信息加载
            /// </summary>
            public void getprobatchDetail()
            {
                BioPurchaseBLL pbll = new BioPurchaseBLL();
                string id = Request.QueryString["taskid"];
                //string id = "10";
    
                DataTable dt = pbll.getProBatchDetailByPurchaseID(id);
                #region  加载产品批号信息
                if (dt.Rows.Count > 0)
                {
                    int count = dt.Rows.Count;
                    //2011年12月2日19:27:17
                    //显示添加批号的前端方法修改为:showobj
                    ClientScript.RegisterStartupScript(this.GetType(), "showobj", "showobj('divprobatch');setaddbatchs(" + count + ");", true);
                    string proname = "";
                    string proId = "";
                    string txtProCount = "";
                    string txtProBatch = "";
                    string txtProBoxNum = "";
                    string txtMarkDate = "";
                    string txtExPirationDate = "";
                    string PurchaseProID = "";
    
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        proname += dt.Rows[i]["proName"].ToString() + ",";
                        proId += dt.Rows[i]["proID"].ToString() + ",";
                        txtProCount += dt.Rows[i]["proCount"].ToString() + ",";
                        txtProBatch += dt.Rows[i]["batchNum"].ToString() + ",";
                        txtProBoxNum += dt.Rows[i]["boxNum"].ToString() + ",";
                        txtMarkDate += Convert.ToDateTime(dt.Rows[i]["makeDate"].ToString()).ToString("yyyy-MM-dd") + ",";
                        txtExPirationDate += Convert.ToDateTime(dt.Rows[i]["expirationDate"].ToString()).ToString("yyyy-MM-dd") + ",";
                        PurchaseProID += dt.Rows[i]["purchaseProID"].ToString() + ",";
    
                    }
    
                    ClientScript.RegisterStartupScript(this.GetType(), "setbatchsvalues", "setbatchsvalues('" + proname + "','" + proId + "','" +
    txtProCount + "','" + txtProBatch + "','" + txtProBoxNum + "','" + txtMarkDate + "','" + txtExPirationDate + "','" + PurchaseProID + "');", true); #endregion //判断是否存在此产品的批号信息 if (dt.Rows.Count>0) { //当前登录用户是否有产品质量审核权限 值50 if (SqlComm.getUserRightsByUserId(Session["Userid"].ToString()).Contains(",50,")) { ClientScript.RegisterStartupScript(this.GetType(), "test", "showobj('proAuditing');", true); if (pbll.getauditingProBatchCountByPurchaseID(id) != 0) { this.cb_Auditing.Checked = true; } } else { if (pbll.getauditingProBatchCountByPurchaseID(id) != 0) { ClientScript.RegisterStartupScript(this.GetType(), "test", "showobj('proAuditing');", true); this.cb_Auditing.Checked = true; this.cb_Auditing.Enabled = false; } } //如果产品批号已经审核 并且 当前登录用户是仓库管理员 则显示相应控件 if (pbll.getauditingProBatchCountByPurchaseID(id) != 0 && SqlComm.getUserRightsByUserId(Session["Userid"].ToString()).Contains(",25,")) { ClientScript.RegisterStartupScript(this.GetType(), "test1", "showobj('stockAuditing');", true); } } } } protected void getdata() { ////如果获取阐述不存在直接跳转。 if (Request.QueryString["taskid"] == null || Request.QueryString["listid"] == null) { Response.Write("<script>window.history.go(-1);this.close()</script>"); } string taskid = Request.QueryString["taskid"].ToString(); string listid = Request.QueryString["listid"].ToString(); //string taskid = "10"; //string listid = "50"; string rights= SqlComm.getUserRightsByUserId(Session["Userid"].ToString()); BioPurchaseBLL purchasebll=new BioPurchaseBLL(); ViewBioPurchaseAppInfo viewpurchase = purchasebll.getViewBioPurchaseAppInfo(taskid); ddlDepartMent.Text=viewpurchase.DepartMent.ToString(); this.hf_applayDepartMent.Value = viewpurchase.DepartMentID.ToString(); this.lbApplayUser.Text = viewpurchase.AppUserName.ToString(); this.lbOldRealName.Text = viewpurchase.RealUserName; this.txtRealUserID.Text = viewpurchase.RealUserID.ToString(); this.lbTime.Text = Convert.ToDateTime(viewpurchase.OrderTime).ToString("yyyy-MM-dd"); this.lbOldSenComName.Text = viewpurchase.CopanyName; this.txtSendCom.Text = viewpurchase.sendComID.ToString(); this.ddlOrderCom.Text = viewpurchase.OrderCom.ToString(); this.ddlSaleType.Text = viewpurchase.WholeType; this.ddlTypes.Text = viewpurchase.sendType; //判断是否数据库中已经添加了财务审核的记录 if (viewpurchase.BillNo != "" && viewpurchase.BillNo != null) { this.lbBill.Visible = true; this.lbisPay.Visible = true; this.isPay.Visible = true; this.txtBillNo.Visible = true; this.lbPayuser.Visible = true; this.txtBillUser.Visible = true; this.txtBillUser.Text = viewpurchase.BillUserID.ToString(); this.txtBillNo.Text = viewpurchase.BillNo.ToString(); this.lbBillUserName.Text = viewpurchase.BillUserName.ToString(); int paycount = int.Parse(SqlComm.GetObjectByCondition("dbo.BioPurchasePro", "count(isPay)", " PurchaseID="+taskid).ToString()); if (paycount > 0) { this.isPay.Checked = true; } } else { if (rights.Contains(",48,")) { this.lbBill.Visible = true; this.lbisPay.Visible = true; this.isPay.Visible = true; this.txtBillNo.Visible = true; this.lbPayuser.Visible = true; this.txtBillUser.Visible = true; this.txtBillUser.Text = Session["Userid"].ToString(); this.txtBillNo.Text = DateTime.Now.ToString("yyyyMMdd") + taskid; } } //根据表单单号在流程表中查询历史审批记录绑定信息 this.lbRemarks.Text= SqlComm.getTaskListRecordsMindsByCondition(taskid, ((int)TaskNavigateEmun.ProPurchase).ToString()); if (SqlComm.getAuditingSateByCondition("listid") == "2") { this.cb_Stock.Checked = true; } this.hf_subject.Value = SqlComm.getTaskListSubjectByCondition(listid); this.hf_FirstTransmitter.Value = SqlComm.getFirstTransmitterByCondition(listid); this.hf_FirstAccepter.Value = SqlComm.getFirstAccpterByCondition(listid); //根据表单编号查询产品基本信息并绑定 DataTable dt = SqlComm.GetDataByCondition("View_BioPurchaseProInfo", "ProID,ProName,ProCount,ProPrice,
    InvoicePrice,purchaseProID", "PurchaseID=" + taskid).Tables[0]; int count = dt.Rows.Count; ClientScript.RegisterStartupScript(this.GetType(), "addrows", "addrows(" + (count-1) + ");", true); string proNames = ""; string proIDs = ""; strin g proCounts = ""; string proPrices = ""; decimal totalInvoicePrice = 0; string purchaseProIDs = ""; for (int i = 0; i < dt.Rows.Count; i++) { proIDs+= dt.Rows[i]["ProID"].ToString()+","; proNames+=dt.Rows[i]["ProName"].ToString()+","; proCounts+= dt.Rows[i]["ProCount"].ToString()+","; proPrices+= decimal.Parse(dt.Rows[i]["ProPrice"].ToString()).ToString("0.0")+","; totalInvoicePrice += decimal.Parse(dt.Rows[i]["InvoicePrice"].ToString()); purchaseProIDs += dt.Rows[i]["purchaseProID"].ToString() + ","; } ClientScript.RegisterStartupScript(this.GetType(), "setValues", "setValues('" + proNames + "','" + proIDs +
    "','" + proCounts + "','" + proPrices + "','" + purchaseProIDs + "');", true); this.lbTotalInvoicePrice.Text = totalInvoicePrice.ToString("0.0"); } protected void Button1_Click(object sender, EventArgs e) { TaskListRecord record = new TaskListRecord(); record.Accepter = int.Parse(this.hf_FirstTransmitter.Value); record.AuditingSate = 3; record.DepartMentId = int.Parse(this.hf_applayDepartMent.Value); record.FirstAccepter = int.Parse(this.hf_FirstAccepter.Value); record.FirstSumitTime = Convert.ToDateTime(this.lbTime.Text); record.FirstTransmitter = int.Parse(this.hf_FirstTransmitter.Value); record.Mind = this.txtRemark.Text; record.Pass = 1; record.Subject = hf_subject.Value; record.SumitTime = DateTime.Now; record.TaskID = int.Parse(Request.QueryString["taskid"].ToString()); record.TaskTableID = (int)TaskNavigateEmun.ProPurchase; record.Transmitter = int.Parse(Session["Userid"].ToString()); if (SqlComm.TaskListRecordAdd(record) != 0) { SqlComm.UpdateTableByCondition("dbo.TaskListRecord", " AuditingSate=1", " ListID=" + Request.QueryString["listid"].ToString()); } } }

     产品购进系统购进单列表查询视图:

    根据产品购进单查询产品对应总额:

    CREATE FUNCTION [dbo].[getPurchaseTotalMonenyByPurchaseID]
    ( 
    	@PurchaseID INT
    )
    RETURNS MONEY
    AS 
    BEGIN
    DECLARE @totalMoney MONEY
    SELECT @totalMoney=SUM(ProPrice*ProCount) FROM dbo.BioPurchasePro
    WHERE PurchaseID=@PurchaseID
    RETURN @totalMoney
    END
    

    购进单列表需要显示的信息:
    主题,表单状态,订货公司,发货公司,订货申请人,订货部门,订货时间,订货总金额,入库时间,下次接收人(当前接收人)

    需要的视图:

    CREATE VIEW [dbo].[View_PurchaseAppInfoShowList]
    AS
    
    SELECT
    	PurchaseID,
    	Subject,
    	DepartMentID,
    	DepartMentName=dbo.FN_GetDepartMentByID(DepartMentID),
    	AppUserId,
    	AppUserName=dbo.getUserNameByUserID(AppUserId),
    	RealUserID,
    	RealUserName=dbo.getUserNameByUserID(RealUserID),
    	OrderCom,
    	SendComID,
    	SendComName=dbo.getCustomerByID(SendComID),
    	ArrivedTime,
    	OrderTime,
    	sendType,
    	WholeType,
    	AcceptUserid,
    	PurchaseTotal=dbo.getPurchaseTotalMonenyByPurchaseID(PurchaseID),
    	BillUserID,
    	DeleteSate,
    	Transmitter=ISNULL(dbo.FN_CurrentTransmitter(2,PurchaseID),'数据错误'),
    	Listid= ISNULL(dbo.FN_GetDynamicId(2,PurchaseID),0),
    	AuditingSate=ISNULL(dbo.FN_CurrentAuditingSate(2,PurchaseID),0)
    FROM
    	dbo.BioPurchaseAppInfo
    

     产品采购审核列表查询页面:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ProPurchaseListShow.aspx.cs" 
    Inherits="BioErpWeb.WholeSaleSystem.ProPurchase.ProPurchaseListShow" %> <%@ Register assembly="AspNetPager" namespace="Wuqi.Webdiyer" tagprefix="webdiyer" %> <%@ Register src="../../UserControl/CRMChannelMenuBar.ascx" tagname="CRMChannelMenuBar" tagprefix="uc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <link href="../../Styles/ERPBaseStyle.css" rel="stylesheet" type="text/css" /> <link href="../../Styles/AspNetPagerStyle.css" rel="stylesheet" type="text/css" /> <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script> <link href="../../Scripts/jquery-ui-1.7.custom.css" rel="stylesheet" type="text/css" /> <script src="../../Scripts/jquery-ui-1.7.custom.min.js" type="text/javascript"></script> <link href="../../Styles/TopMenu2.css" rel="stylesheet" type="text/css" /> <link href="../../Styles/InputStyle1.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> $().ready(function () { $("#txtNoteTime").datepicker({ dateFormat: 'yy-mm-dd' }); }); </script> </head> <body> <form id="form1" runat="server"> <div> </div> <div> <table class="maintable" style=" 900px;"> <tr> <td colspan="5" class="titlebar"> <span>产品采购审核列表查询</span> </td> </tr> <tr> <td class="tdsearch"> <asp:Label ID="Label1" runat="server" Text="主题:"></asp:Label> <asp:TextBox ID="txtName" runat="server" Width="100px"></asp:TextBox> </td> <td class="tdsearch"> <asp:Label ID="Label2" runat="server" Text="购进申请人:"></asp:Label> <asp:TextBox ID="txtUserName" runat="server" Width="100px"></asp:TextBox> </td> <td class="tdsearch"> <asp:Label ID="Label11" runat="server" Text="提交时间"></asp:Label> <asp:TextBox ID="txtOrderTime" runat="server" Width="100px"></asp:TextBox> </td> <td class="tdsearch"> <asp:Label ID="Label3" runat="server" Text="是否删除"></asp:Label> <asp:DropDownList ID="ddlState" runat="server"> <asp:ListItem Value="0">否</asp:ListItem> <asp:ListItem Value="1">是</asp:ListItem> </asp:DropDownList> </td> <td class="tdsearch"> <asp:ImageButton ID="imgbutnSearch" Width="60" Height="22" runat="server" ImageUrl="~/Web/images/Btnsearch.gif" onclick="imgbutnSearch_Click" />  </td> </tr> <tr> <td colspan="6" class="bottomtd"> <asp:GridView ID="GridView1" Width="100%" runat="server" AutoGenerateColumns="False" DataKeyNames="PurchaseID"> <Columns> <asp:HyperLinkField DataNavigateUrlFields="PurchaseID,Listid" DataNavigateUrlFormatString="ToOtherAspx.aspx?id={0}&listid={1}" DataTextField="Subject" Target="MainFrame" HeaderText="主题"> <ItemStyle Width="150px" HorizontalAlign="Center" /> <HeaderStyle Width="150px" HorizontalAlign="Center"/> </asp:HyperLinkField> <asp:BoundField DataField="AuditingSate" HeaderText="状态" HeaderStyle-HorizontalAlign="Center"/> <asp:TemplateField HeaderText="订货公司" HeaderStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:Label ID="Label6" runat="server" Text='<%# Eval("OrderCom") %>'></asp:Label> </ItemTemplate> <HeaderStyle HorizontalAlign="Center"></HeaderStyle> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateField> <asp:TemplateField HeaderText="发货公司" HeaderStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:Label ID="Label7" runat="server" Text='<%#Eval("SendComName") %>'></asp:Label> </ItemTemplate> <HeaderStyle HorizontalAlign="Center"></HeaderStyle> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateField> <asp:TemplateField HeaderText="订货申请人" HeaderStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:Label ID="Label8" runat="server" Text='<%#Eval("AppUserName") %>'></asp:Label> </ItemTemplate> <HeaderStyle HorizontalAlign="Center"></HeaderStyle> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateField> <asp:TemplateField HeaderText="订货部门" HeaderStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:Label ID="Label9" runat="server" Text='<%# Eval("DepartMentName") %>'></asp:Label> </ItemTemplate> <HeaderStyle HorizontalAlign="Center"></HeaderStyle> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateField> <asp:TemplateField HeaderText="订货时间" HeaderStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:Label ID="lbortime" runat="server" Text='<%# Convert.ToDateTime(Eval("OrderTime")).ToString("yyyy-MM-dd") %>'>
    </asp:Label> </ItemTemplate> <HeaderStyle HorizontalAlign="Center"></HeaderStyle> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateField> <asp:TemplateField HeaderText="订货总额" HeaderStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:Label ID="lbtotal" runat="server" Text='<%# Eval("PurchaseTotal") %>'></asp:Label> </ItemTemplate> <HeaderStyle HorizontalAlign="Center"></HeaderStyle> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateField> <asp:TemplateField HeaderText="下次接收人" HeaderStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:Label ID="Label10" runat="server" Text='<%#Eval("Transmitter").ToString()%>'></asp:Label> </ItemTemplate> <HeaderStyle HorizontalAlign="Center"></HeaderStyle> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateField> <asp:TemplateField HeaderText="" HeaderStyle-HorizontalAlign="Center"> <ItemTemplate> <a href="ProPurchaseShow.aspx?taskid=<%#Eval("PurchaseID") %>&listid=<%#Eval("Listid")%>">查看详细</a> </ItemTemplate> <HeaderStyle HorizontalAlign="Center"></HeaderStyle> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateField> </Columns> </asp:GridView> </td> </tr> <tr> <td colspan="5"> <webdiyer:AspNetPager ID="AspNetPager1" runat="server" CssClass="paginator" CurrentPageButtonClass="cpb" onpagechanged="AspNetPager1_PageChanged"> </webdiyer:AspNetPager> </td> </tr> <tr><td colspan="5"> <asp:Button ID="Button1" runat="server" Text="导出全部" CssClass="btngreen" onclick="Button1_Click"/></td></tr> </table> </div> </form> </body> </html>

     后台代码:

    public partial class ProPurchaseListShow: BasePage
        {
            
            public static int pageindex = 0;
            public static int pagesize = 10;
            public static string condition = "";
    
            protected void Page_Load(object sender, EventArgs e)
            {
                //Session["Userid"] = "29";
                if (Session["Userid"] == null)
                {
                    Response.Redirect("../../web/UserLogin.aspx");
                }
    
            
                if (!IsPostBack)
                {
    
                    getallBioCRMContractList();
                }
            }
    
    
    
            /// <summary>
            /// 查询所有员工信息
            /// </summary>
            private void getallBioCRMContractList()
            {
                //如果有商品采购系统权限(特许权限)的人员可以查看所有表单
                if (SqlComm.getUserRightsByUserId(Session["Userid"].ToString()).Contains(",47,"))
                {
                    this.AspNetPager1.RecordCount = SqlComm.getDataCountByCondition("dbo.View_PurchaseAppInfoShowList", condition);
                    this.AspNetPager1.PageSize = pagesize;
                    this.GridView1.DataSource = SqlComm.getDataByPageIndex("dbo.View_PurchaseAppInfoShowList", "*", 
    "PurchaseID", condition, pageindex, pagesize); this.GridView1.DataBind(); } else if (Web.UserLogin.user.RoleId == ((int)RoseEmun.DepartMentManager)) { condition = condition + " and DepartMentID=" + Web.UserLogin.user.DepartmentId; this.AspNetPager1.RecordCount = SqlComm.getDataCountByCondition("dbo.View_PurchaseAppInfoShowList", condition); this.AspNetPager1.PageSize = pagesize; this.GridView1.DataSource = SqlComm.getDataByPageIndex("dbo.View_PurchaseAppInfoShowList", "*",
    "PurchaseID", condition, pageindex, pagesize); this.GridView1.DataBind(); } else //员工只能看自己的购进单 { condition = condition + " and AppUserId=" + Session["Userid"].ToString(); this.AspNetPager1.RecordCount = SqlComm.getDataCountByCondition("dbo.View_PurchaseAppInfoShowList", condition); this.AspNetPager1.PageSize = pagesize; this.GridView1.DataSource = SqlComm.getDataByPageIndex("dbo.View_PurchaseAppInfoShowList", "*",
    "PurchaseID", condition, pageindex, pagesize); this.GridView1.DataBind(); } for (int i = 0; i < GridView1.Rows.Count; i++) { switch (GridView1.Rows[i].Cells[1].Text) { case "0": GridView1.Rows[i].Cells[1].Text = "待审核"; GridView1.Rows[i].Cells[1].ForeColor = System.Drawing.Color.Green; break; case "2": GridView1.Rows[i].Cells[1].Text = "执行中"; GridView1.Rows[i].Cells[1].ForeColor = System.Drawing.Color.Orange; break; case "3": GridView1.Rows[i].Cells[1].Text = "已完成"; GridView1.Rows[i].Cells[1].ForeColor = System.Drawing.Color.Green; break; default: GridView1.Rows[i].Cells[1].Text = "出现错误"; break; } } } protected void AspNetPager1_PageChanged(object sender, EventArgs e) { pageindex = this.AspNetPager1.CurrentPageIndex - 1; getallBioCRMContractList(); } protected void imgbutnSearch_Click(object sender, ImageClickEventArgs e) { pageindex = 0; condition = ""; if (txtName.Text.Trim() != null && this.txtName.Text.Trim().Length != 0) { condition = condition + " and Subject like '" + txtName.Text + "%'"; } if (this.txtUserName.Text.Trim() != null && this.txtUserName.Text.Trim().Length != 0) { condition = condition + " and AppUserName like '" + txtUserName.Text + "%'"; } if (this.ddlState.SelectedValue == "1") { condition = condition + " and DeleteSate ='True'"; } else { condition = condition + " and DeleteSate ='False'"; } if (this.txtOrderTime.Text.Trim() != null && this.txtOrderTime.Text.Trim().Length != 0) { condition = condition + " and (OrderTime>= '" + Convert.ToDateTime(this.txtOrderTime.Text) +
    "' and OrderTime<'" + Convert.ToDateTime(this.txtOrderTime.Text).AddDays(1) + "')"; } getallBioCRMContractList(); } protected void Button1_Click(object sender, EventArgs e) { Response.Redirect("ToExcel.aspx?name='产品购进单信息'"); } }

     导出的公用方法:

       /// <summary>
           /// 根据指定文件名称和文件类型导出数据
           /// </summary>
           /// <param name="FileName">文件名</param>
           /// <param name="FileType">文件类型(Execl:application/vnd.ms-excel  Word:application/msword)</param>
           public static void ExportFile(System.Web.UI.Page p, string FileName, string FileType)
           {
               p.Response.Clear();
               p.Response.ContentEncoding = System.Text.Encoding.Default;
               p.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
               p.Response.ContentType = FileType;          
           }
        }
    

     导出的前端代码:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ToExcel.aspx.cs" Inherits="BioErpWeb.WholeSaleSystem.ProPurchase.ToExcel" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <style type="text/css">
    td{ text-align:center;}
      body{ background-color:transparent;}
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
                         <asp:GridView ID="GridView1" Width="100%"  runat="server"  AutoGenerateColumns="False" DataKeyNames="PurchaseID">
                             <Columns>    
                                 <asp:TemplateField  HeaderText="序号">
                                 <ItemTemplate>
                                 <%#Container.DataItemIndex+1 %>
                                 </ItemTemplate>
                                 </asp:TemplateField>               
                                 <asp:BoundField  DataField="Subject" HeaderText="主题" HeaderStyle-HorizontalAlign="Center"/>
                                                         
                                 <asp:TemplateField HeaderText="订货公司" HeaderStyle-HorizontalAlign="Center">
                                     <ItemTemplate>
                                          <asp:Label ID="Label6" runat="server" Text='<%# Eval("OrderCom") %>'></asp:Label>
                                     </ItemTemplate>
    
    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
    
                                     <ItemStyle HorizontalAlign="Center" />
                                 </asp:TemplateField>
                                 <asp:TemplateField HeaderText="发货公司" HeaderStyle-HorizontalAlign="Center">
                                     <ItemTemplate>
                                          <asp:Label ID="Label7" runat="server" Text='<%#Eval("SendComName") %>'></asp:Label>
                                     </ItemTemplate>
    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                     <ItemStyle HorizontalAlign="Center" />
                                 </asp:TemplateField>
    
                                   <asp:TemplateField HeaderText="订货申请人" HeaderStyle-HorizontalAlign="Center">
                                     <ItemTemplate>
                                          <asp:Label ID="Label8" runat="server" Text='<%#Eval("AppUserName") %>'></asp:Label>
                                     </ItemTemplate>
    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                     <ItemStyle HorizontalAlign="Center" />
                                 </asp:TemplateField>
                              
                                 <asp:TemplateField HeaderText="订货部门" HeaderStyle-HorizontalAlign="Center">
                                    <ItemTemplate>
                                          <asp:Label ID="Label9" runat="server" Text='<%# Eval("DepartMentName") %>'></asp:Label>
                                     </ItemTemplate>   
    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                     <ItemStyle HorizontalAlign="Center" />                          
                                 </asp:TemplateField>
                                   <asp:TemplateField HeaderText="订货时间" HeaderStyle-HorizontalAlign="Center">
                                    <ItemTemplate>
                                          <asp:Label ID="lbortime" runat="server" Text='<%#  Convert.ToDateTime(Eval("OrderTime")).ToString("yyyy-MM-dd") %>'></asp:Label>
                                     </ItemTemplate>   
    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                     <ItemStyle HorizontalAlign="Center" />                          
                                 </asp:TemplateField>
                                   <asp:TemplateField HeaderText="订货总额" HeaderStyle-HorizontalAlign="Center">
                                    <ItemTemplate>
                                          <asp:Label ID="lbtotal" runat="server" Text='<%# Eval("PurchaseTotal") %>'></asp:Label>
                                     </ItemTemplate>   
    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                     <ItemStyle HorizontalAlign="Center" />                          
                                 </asp:TemplateField>
                          
                              
                             </Columns>
                         </asp:GridView>
        
        </div>
        </form>
    </body>
    </html>
    

     后台代码:

      public partial class ToExcel : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                string filename = "";
                if (Request.QueryString["name"] != null)
                {
                    filename = DateTime.Now.ToString("yyyyMMdd")+Request.QueryString["name"].ToString()+".xls";
                }
                else
                {
                    filename = DateTime.Now.ToString("yyyyMMdd.xls");
                }
    
                Comm.ExportFile(this, filename, "application/ms-excel");
                gridviewbind();
    
              
            }
    
            /// <summary>
            /// 绑定gridview
            /// </summary>
            protected void gridviewbind()
            {
                this.GridView1.DataSource = SqlComm.GetDataByCondition("dbo.View_PurchaseAppInfoShowList", "*",null);
                this.GridView1.DataBind();
            }
        }
    

      

  • 相关阅读:
    简单了解winform
    SqL语句基础之增删改查
    数据库之表
    数据库基本概念与操作
    搞死人不偿命的 Bank系统
    for的循环题
    .net framework 版本汇总
    LinqToEntity模糊查询的方法选择
    日常工作中的点滴:C# 根据字节长度截包含中文的字符串
    64位系统 IIS中应用程序池设置导致 访问数据库错误
  • 原文地址:https://www.cnblogs.com/sunliyuan/p/7407066.html
Copyright © 2011-2022 走看看