jquery Test

Ajax html:s
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ajax.aspx.cs" Inherits="HyeyManager.Order.ajax" %>



<!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>

</head>

<body>

    <form id="form1" runat="server">

    <div>

    

    </div>

    </form>

</body>

</html>

 

Ajax aspx C#:

 

using System;

using System.Collections;

using System.Configuration;

using System.Data;

using System.Linq;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Xml.Linq;

using System.Text;



namespace HyeyManager.Order

{

	public partial class ajax : System.Web.UI.Page

	{

        protected void Page_Load(object sender, EventArgs e)

        {



            if (Request["pno"] != null && Request["pno"].ToString().ToString() != "")

            {

                GetData(Request["pno"].ToString());



            }





        }







        /// <summary>

        /// 获取IP归属地

        /// </summary>

        /// <param name="IP"></param>

        public void GetData(string pno)

        {

            string fldSql = "Ypmc,Gg,Cdmc,Ph,zbz,DW,Bz,dj,'-',sl,Je";

            string strViewName = "xsfp";

            string strWhere = string.Format("pno='{0}'", pno);



            //DA

            DataSet ds = HyeyClass.DALFactory.DataAccess.CreateComm().GetList(fldSql, strWhere, "ID asc", strViewName);



            string str = string.Empty;

            if (ds != null)

                str = ToJson(ds.Tables[0]);





            Response.Clear();

            Response.Write(str);

            Response.End();

        }





        #region dt转换成Json格式

        /// <summary>      

        /// dataTable转换成Json格式      

        /// </summary>      

        /// <param name="dt"></param>      

        /// <returns></returns>      

        public static string ToJson(DataTable dt)

        {

            StringBuilder s = new StringBuilder();

            if (dt.Rows.Count > 0)

            {

                s.Append("{\"");

                s.Append(dt.TableName.ToString());

                s.Append("\":[");

                for (int i = 0; i < dt.Rows.Count; i++)

                {

                    s.Append("{");

                    for (int j = 0; j < dt.Columns.Count; j++)

                    {

                        s.Append("\"");

                        s.Append(dt.Columns[j].ColumnName);

                        s.Append("\":\"");

                        s.Append(dt.Rows[i][j].ToString());

                        s.Append("\",");

                    }

                    s.Remove(s.Length - 1, 1);

                    s.Append("},");

                }

                s.Remove(s.Length - 1, 1);

                s.Append("]");

                s.Append("}");

            }

            return s.ToString();

        }



        #endregion dt转换成Json格式

	}

}



 

html:

<%@ Register TagPrefix="uc1" TagName="SourceList" Src="SourceList.ascx" %>

<%@ Page language="c#" Codebehind="YwYOrderDetails.aspx.cs" AutoEventWireup="false" Inherits="HyeyManager.Order.YwYOrderDetails" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<HTML>

	<HEAD>

		<title>YwYOrderDetails</title>

		<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">

		<meta name="CODE_LANGUAGE" content="C#">

		<meta name="vs_defaultClientScript" content="JavaScript">

		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">

		<LINK rel="stylesheet" type="text/css" href="../css/css.css">

		<script type="text/javascript" src="../js/Calendar.js"></script>

		<script type="text/javascript" src="../AnalyseUrl/My97DatePicker/WdatePicker.js"></script>

		<script type="text/javascript" src="../AnalyseUrl/js/jquery-1.3.2.min.js"></script>

		<style type="text/css">		

			A:link { COLOR: #000000; TEXT-DECORATION: none }		

			A:visited { COLOR: #000000; FONT-SIZE: 12px; TEXT-DECORATION: none }		

			A:hover { COLOR: #c0c0c0; FONT-SIZE: 12px; TEXT-DECORATION: underline }		

		</style>



	</HEAD>

	

		<script type="text/javascript">

		 //变色

         var currentColor="";

         function changeHangColor(objTR)

         {

            currentColor = $(objTR).children("td").attr("bgColor");

            

            $(objTR).children("td").each(

              function(i)

              {

                $(objTR).children("td").eq(i).attr("bgColor","#e8eefa");

              }

            )

                    

         }

         function changeHangColor2(objTR)

         {

         

            $(objTR).children("td").each(

              function(i)

              {

                $(objTR).children("td").eq(i).attr("bgColor","#FFFFFF");

              }

            )

         }

		</script>

		

	<body MS_POSITIONING="GridLayout">

		<form id="Form1" method="post" runat="server">

			<table border="0" cellSpacing="0" cellPadding="0" width="100%">

				<tr>

					<td height="30" width="3%" align="center"> </td>

					<td class="a1"><IMG align="absMiddle" src="../images/icon.gif" width="11" height="11">  您现在的位置 

						>> <A class="a1" href="../workaround.aspx" target="workaroundFrame">系统主页</A>

						>> <A class="a1" href="YwYOrderLists.aspx" target="workaroundFrame">业务员系统订单管理</A>

						>> 业务员系统订单详情

					</td>

				</tr>

			</table>

			<table border="0" cellSpacing="0" cellPadding="0" width="100%">

				<tr height="5">

					<td height="5"></td>

				</tr>

			</table>

			<div style="TEXT-ALIGN: left" id="divResume" runat="server">

			

				<table border="1" cellSpacing="1" borderColor="#f2f8f9" borderColorLight="#cadfe5" cellPadding="2"

								width="100%" bgColor="#ffffff" align="center">

								<tr>

									<td bgColor="#cadfe5" height="18" colSpan="10" align="left">  详细信息</td>

								</tr>

								<tr>

									<td bgColor="#f2f6f9" height="18" align="center">用户名</td>

									<td bgColor="#f2f6f9" align="center">企业名称</td>

									<td bgColor="#f2f6f9" align="center">联系人</td>

									<td bgColor="#f2f6f9" align="center">联系电话</td>

									<td bgColor="#f2f6f9" align="center">送货地址</td>

									<td bgColor="#f2f6f9" align="center">订购时间</td>

									<td bgColor="#f2f6f9" align="center">订单来源</td>

									<td bgColor="#f2f6f9" align="center">订单状态</td>

									<td bgColor="#f2f6f9" align="center">付款方式</td>

									<td bgColor="#f2f6f9" align="center">送货方式</td>

								</tr>

								<tr>

									<td height="18" align="center"><asp:label id="lblUserName" runat="server"></asp:label></td>

									<td align="center"><asp:label id="lblCompany" runat="server"></asp:label></td>

									<td align="center"><asp:label id="lblTrueName" runat="server"></asp:label></td>

									<td align="center"><asp:label id="lblMobile" runat="server"></asp:label></td>

									<td align="left"><asp:label id="lblAddress" runat="server"></asp:label></td>

									<td align="center"><asp:label id="lblInsertTime" runat="server"></asp:label></td>

									<td align="center"><asp:label id="lblOrderSource" runat="server"></asp:label></td>

									<td align="center"><asp:label id="lblOrderState" runat="server"></asp:label></td>

									<td align="center"><asp:label id="lblPayMode" runat="server"></asp:label></td>

									<td align="center"><asp:label id="lblSendMode" runat="server"></asp:label></td>

								</tr>

								<tr>

									<td bgColor="#f2f6f9" align="center">备注</td>

									<td colSpan="9" align="left"> 

										<asp:label id="lblRemark" runat="server"></asp:label></td>

								</tr>

				</table>

				<table border="0" cellSpacing="3" cellPadding="0" width="100%" align="center" >

					<tr>

						<td vAlign="top" align="center">

							<table border="1" cellSpacing="0" borderColor="#f2f8f9" borderColorLight="#cadfe5" cellPadding="0"

								width="100%" bgColor="#ffffff" align="center" height="22">

								<tr>

									<td bgColor="#cadfe5" align="left"><IMG src="../images/icon15.gif"><span class="color_red">  订单号:

											<asp:label id="lblOrderId" runat="server"></asp:label></span> 此订单客服业务员:

										<asp:label id="lblSalesCompany" runat="server"></asp:label><asp:label id="lblSupporter" runat="server"></asp:label></td>

								</tr>

							</table>

							<table border="0" cellSpacing="0" cellPadding="0" width="100%">

								<tr height="5">

									<td height="5"></td>

								</tr>

							</table><asp:HiddenField  id="hidshowpno"  runat="server" Value="0" />

							<table border="1" cellSpacing="1" borderColor="#f2f8f9" borderColorLight="#cadfe5" cellPadding="2"

								width="100%" bgColor="#ffffff" align="center">

								<tr>

									<td bgColor="#cadfe5" height="18" colSpan="13" align="left">  订购明细</td>

								</tr>

								<tr>

									<td bgColor="#cccccc" height="18" colSpan="13" align="left">  华源品种的详细订购明细:</td>

								</tr>

								<tr>

								    <td bgColor="#f2f6f9" height="18" align="center">编号</td>

									<td bgColor="#f2f6f9" align="center">药品名称</td>

									<td bgColor="#f2f6f9" align="center">规格</td>

									<td bgColor="#f2f6f9" align="center">产地</td>

									<td bgColor="#f2f6f9" align="center">生产批号</td>

									<td bgColor="#f2f6f9" align="center">件数</td>

									<td bgColor="#f2f6f9" align="center">单位</td>

									<td bgColor="#f2f6f9" align="center">包装</td>

									<td bgColor="#f2f6f9" align="center">单价</td>

									<td bgColor="#f2f6f9" align="center">原单价</td>

									<td bgColor="#f2f6f9" align="center">订购数</td>

									<td bgColor="#f2f6f9" align="center">合计</td>

									<td bgColor="#f2f6f9" align="center">内部清单号</td>

								</tr>

								<asp:repeater id="rptOrderDetail" runat="server">

									<ItemTemplate>

										<tr onmouseover="javascript:changeHangColor(this)" onmouseout="javascript:changeHangColor2(this)">

											<td><%# DataBinder.Eval(Container.DataItem, "OrderDetailID")%></td>

											<td height="18"><%# DataBinder.Eval(Container.DataItem, "Ypmc") %></td>

											<td> <%# DataBinder.Eval(Container.DataItem, "Gg") %></td>

											<td> <%# DataBinder.Eval(Container.DataItem, "Cdmc") %></td>

											<td align="center"> <%# DataBinder.Eval(Container.DataItem, "Ph") %></td>

											<td align="center"> <%# DataBinder.Eval(Container.DataItem, "PieceNum") %></td>

											<td align="center"> <%# DataBinder.Eval(Container.DataItem, "DW") %></td>

											<td align="center"> <%# DataBinder.Eval(Container.DataItem, "Bz") %></td>

											<td align="center"> <%# DataBinder.Eval(Container.DataItem, "Price") %></td>

											<td align="center"> <%# DataBinder.Eval(Container.DataItem, "Yprice") %></td>

											<td align="center"> <%# DataBinder.Eval(Container.DataItem, "SL") %></td>

											<td align="right"> 

												<%# GetDecimal(DataBinder.Eval(Container.DataItem, "Je").ToString()) %>

											</td>

											<td align="left">

                                             

											<input type="text" name="txtpno" onblur="Getxsfp(this)" onmouseout="Getxsfp(this)" style="width:100px;" /><input type="hidden" value="0" />

											<span name="pnoview" style="display:none;"><%# DataBinder.Eval(Container.DataItem, "pno").ToString() %></span>

											   </td>

										</tr>

									</ItemTemplate>

								</asp:repeater>

								<tr>

									<td bgColor="#cccccc" height="18" colSpan="13" align="left">  自有品种的详细订购明细:</td>

								</tr>

								<tr>				    

								    <td bgColor="#f2f6f9" height="18" align="center">编号</td>

									<td bgColor="#f2f6f9" align="center">药品名称</td>

									<td bgColor="#f2f6f9" align="center">规格</td>

									<td bgColor="#f2f6f9" align="center">产地</td>

									<td bgColor="#f2f6f9" align="center">生产批号</td>

									<td bgColor="#f2f6f9" align="center">件数</td>

									<td bgColor="#f2f6f9" align="center">单位</td>

									<td bgColor="#f2f6f9" align="center">包装</td>

									<td bgColor="#f2f6f9" align="center">单价</td>

									<td bgColor="#f2f6f9" align="center">原单价</td>

									<td bgColor="#f2f6f9" align="center">订购数</td>

									<td bgColor="#f2f6f9" align="center" colspan="2" >合计</td>

								

								</tr>

								<asp:Repeater ID="rptZyOrderDetail" Runat="server">

									<ItemTemplate>

										<tr onmouseover="javascript:changeHangColor(this)" onmouseout="javascript:changeHangColor2(this)">

										

											<td><%# DataBinder.Eval(Container.DataItem, "OrderDetailID")%></td>

											<td height="18"><%# DataBinder.Eval(Container.DataItem, "Ypmc") %></td>

											<td> <%# DataBinder.Eval(Container.DataItem, "Gg") %></td>

											<td> <%# DataBinder.Eval(Container.DataItem, "Cdmc") %></td>

											<td align="center"> <%# DataBinder.Eval(Container.DataItem, "Ph") %></td>

											<td align="center"> <%# DataBinder.Eval(Container.DataItem, "PieceNum") %></td>

											<td align="center"> <%# DataBinder.Eval(Container.DataItem, "DW") %></td>

											<td align="center"> <%# DataBinder.Eval(Container.DataItem, "Bz") %></td>

											<td align="center"> <%# DataBinder.Eval(Container.DataItem, "Price") %></td>

											<td align="center"> <%# DataBinder.Eval(Container.DataItem, "Yprice") %></td>

											<td align="center"> <%# DataBinder.Eval(Container.DataItem, "SL") %></td>

											<td align="right" colspan="2"> 

												<%# GetDecimal(DataBinder.Eval(Container.DataItem, "Je").ToString()) %>

											</td>

										

										</tr>

									</ItemTemplate>

								</asp:Repeater>

								

								<tr>

									<td height="18"  colspan ="11" align="left" >  总计</td><td align="right" colspan="2" ><font color="#ff0000">¥<asp:label id="lblOTprice" runat="server"></asp:label></font>

								

		

									</td>

								</tr>

							</table>

						

						</td>

					</tr>

				</table>

                <asp:Panel runat="server" ID="divAdd" Visible="true">

                    <table border="1" cellspacing="1" bordercolor="#f2f8f9" bordercolorlight="#cadfe5"

                        cellpadding="2" width="100%" bgcolor="#ffffff" align="center" style="margin-top: 20px;">

                        <tr>

                            <td bgcolor="#cadfe5" height="18" align="left">

                                  订单金额<font color="red">【*以下为必填项】</font>

                            </td>

                        </tr>

                        <tr>

                            <td>

                                <div style="font-size: 12px;">

                                    采购成本:<asp:TextBox ID="txtPurchaseCost" runat="server" CssClass="bottomline" Enabled="false">系统计数</asp:TextBox><asp:HiddenField

                                        ID="hidPurchaseCost" runat="server" />

                                    销售价格:

                                    <asp:TextBox ID="txtBillAmount" runat="server" CssClass="bottomline" Enabled="false"

                                        Text="">系统计数</asp:TextBox>

                                    <asp:HiddenField ID="hidBillAmount" runat="server" />

                                    <asp:DropDownList ID="ddlBillCost_Rebates" runat="server" Width="80">

                                        <asp:ListItem Value="1" Text="发票成本:"></asp:ListItem>

                                        <asp:ListItem Value="-1" Text="返点费:"></asp:ListItem>

                                    </asp:DropDownList>

                                    <asp:TextBox ID="txtBillCost_Rebates" runat="server" CssClass="bottomline" needValidate="true"

                                        value=""></asp:TextBox>

                                    管理费:

                                    <asp:TextBox ID="txtSystemCost" runat="server" CssClass="bottomline" needValidate="true"

                                        value=""></asp:TextBox>

                                    单位:元

                                </div>

                                <div style="height: 50px; font-size: 12px;">

                                    <span id="txtPurchaseCost_error"></span>  <span id="txtBillAmount_error"></span>  <span

                                        id="txtBillCost_Rebates_error"></span>  <span id="txtSystemCost_error"></span>

                                    <div>

                                        <span id="txtpno_error"></span>

                                    </div>

                                </div>

                            </td>

                        </tr>

                    </table>

                </asp:Panel>

                <asp:Panel runat="server" ID="divList" Visible="false">

                    <table border="1" cellspacing="0" bordercolor="#f2f8f9" bordercolorlight="#cadfe5"

                        cellpadding="0" width="100%" bgcolor="#ffffff" align="center" height="22">

                        <tr>

                            <td bgcolor="#cadfe5" align="left">

                                <img src="../images/icon15.gif"><span class="color_red">    成交订单明细:

                            </td>

                        </tr>

                    </table>

                    <table border="1" cellspacing="1" bordercolor="#f2f8f9" bordercolorlight="#cadfe5"

                        cellpadding="2" width="100%" bgcolor="#ffffff" align="center">

                        <tr>

                            <td bgcolor="#cccccc" height="18" colspan="15" align="left">

                                  华源品种的详细订购明细:

                            </td>

                            <tr>

                                <td bgcolor="#f2f6f9" height="18" align="center">

                                    选择

                                </td>

                                <td bgcolor="#f2f6f9" height="18" align="center">

                                    序号

                                </td>

                                <td bgcolor="#f2f6f9" height="18" align="center">

                                    编号

                                </td>

                                <td bgcolor="#f2f6f9" align="center">

                                    药品名称

                                </td>

                                <td bgcolor="#f2f6f9" align="center">

                                    规格

                                </td>

                                <td bgcolor="#f2f6f9" align="center">

                                    产地

                                </td>

                                <td bgcolor="#f2f6f9" align="center">

                                    生产批号

                                </td>

                                <td bgcolor="#f2f6f9" align="center">

                                    件数

                                </td>

                                <td bgcolor="#f2f6f9" align="center">

                                    单位

                                </td>

                                <td bgcolor="#f2f6f9" align="center">

                                    包装

                                </td>

                                <td bgcolor="#f2f6f9" align="center">

                                    单价

                                </td>

                                <td bgcolor="#f2f6f9" align="center">

                                    原单价

                                </td>

                                <td bgcolor="#f2f6f9" align="center">

                                    订购数

                                </td>

                                <td bgcolor="#f2f6f9" align="center">

                                    合计

                                </td>

                                <td bgcolor="#f2f6f9" align="center">

                                    操作

                                </td>

                            </tr>

                            <asp:Repeater ID="rpt_YwDealOrderDetail" runat="server" OnItemCommand="rpt_YwDealOrderDetail_ItemCommand">

                                <ItemTemplate>

                                    <tr onmouseover="javascript:changeHangColor(this)" onmouseout="javascript:changeHangColor2(this)">

                                        <td height="18" align="center" bgcolor="#f2f6f9">

                                            <input type="checkbox" value='<%# DataBinder.Eval(Container.DataItem, "DealID") %>'  getthis="selectthis" id="selectthisbox" runat="server"></input>

                                        </td>

                                        <td>

                                            <%# Convert.ToString(Container.ItemIndex+1)%>

                                        </td>

                                        <td>

                                            <%# DataBinder.Eval(Container.DataItem, "OrderDetailID")%>

                                        </td>

                                        <td height="18">

                                            <%# DataBinder.Eval(Container.DataItem, "Ypmc") %>

                                        </td>

                                        <td>

                                             <%# DataBinder.Eval(Container.DataItem, "Gg") %>

                                        </td>

                                        <td>

                                             <%# DataBinder.Eval(Container.DataItem, "Cdmc") %>

                                        </td>

                                        <td align="center">

                                             <%# DataBinder.Eval(Container.DataItem, "Ph") %>

                                        </td>

                                        <td align="center">

                                             <%# DataBinder.Eval(Container.DataItem, "PieceNum") %>

                                        </td>

                                        <td align="center">

                                             <%# DataBinder.Eval(Container.DataItem, "DW") %>

                                        </td>

                                        <td align="center">

                                             <%# DataBinder.Eval(Container.DataItem, "Bz") %>

                                        </td>

                                        <td align="center">

                                             <%# DataBinder.Eval(Container.DataItem, "Price") %>

                                        </td>

                                        <td align="center">

                                             <%# DataBinder.Eval(Container.DataItem, "Yprice") %>

                                        </td>

                                        <td align="center">

                                             <%# DataBinder.Eval(Container.DataItem, "SL") %>

                                        </td>

                                        <td align="right">

                                             

                                            <%# GetDecimal(DataBinder.Eval(Container.DataItem, "Je").ToString()) %>

                                        </td>

                                        <td align="left">

                                            <div id="divshow" style="display: none; color: #999999">

                                                已退货

                                            </div>

                                            <div id="<%# DataBinder.Eval(Container.DataItem, "TradeState") %>" style="display: inline;">

                                                <a href="updateYwOrderDetails.aspx?DealId=<%#DataBinder.Eval(Container.DataItem, "DealID") %>&&OrderId=<%=YW_OrderID %>">

                                                    换货</a>

                                                <%--<asp:LinkButton ID="lbtDelete" runat="server" CommandName="btnDelete"  CommandArgument='<%#DataBinder.Eval(Container.DataItem, "DealID") %>' CssClass="green" OnClientClick='return tuihuovalidate()'>退货</asp:LinkButton>--%>

                                                <a href="PrintOrderDetails.aspx?DealId=<%#DataBinder.Eval(Container.DataItem, "DealID") %>&&OrderId=<%=YW_OrderID %>">

                                                    打印</a>

                                                <input type="hidden" value="0" />

                                            </div>

                                        </td>

                                    </tr>

                                </ItemTemplate>

                            </asp:Repeater>



                           

                    </table>

                    <table border="0" cellspacing="0" cellpadding="0" width="100%" height="30">

                        <tr>

                            <td width="49%" align="left" colspan="4">

                               <div style="float:left;">   <input onclick="selectallCheckBox()" value="checkbox" type="checkbox"

                                    name="selectall"/>全选    

                               <%-- <input type="hidden" value="" id="updateID" />

                                <a   href="#" onclick ="GetOrderDetailID()">【换货】</a>--%></div>

                                <div id="divDel" style="float:left;"><asp:LinkButton ID="lbtDel" runat="server"  onclick="lbtDel_Click" OnClientClick="return tuihuovalidate()" >【退货】</asp:LinkButton>

                                    <asp:DropDownList ID="delddlBillCost_Rebates" runat="server" Width="80">

                                        <asp:ListItem Value="1" Text="发票成本:"></asp:ListItem>

                                        <asp:ListItem Value="-1" Text="返点费:"></asp:ListItem>

                                    </asp:DropDownList>

                                    <asp:TextBox ID="deltxtBillCost_Rebates" runat="server" CssClass="bottomline" delneedValidate="true"

                                        value=""></asp:TextBox>

                                    <span id="deltxtBillCost_Rebates_error"></span>管理费:

                                    <asp:TextBox ID="deltxtSystemCost" runat="server" CssClass="bottomline" delneedValidate="true"

                                        value=""></asp:TextBox>

                                    <span id="deltxtSystemCost_error"></span>单位:元</div>

                            </td>

                        </tr>

                    </table>

                </asp:Panel>

            </div>

			<table cellSpacing="0" cellPadding="0" width="100%" border="0">

				<tr width="100%">

					<td align="center">

                        <asp:Button ID="btnadd" runat="server" Text="成交"  OnClientClick="return validate()" onclick="btnadd_Click" />

                        <asp:Button ID="btnprint" runat="server" Text="打印"  Visible="false"  OnClientClick="PrintNote()" />

                     

					  <FONT face="宋体">    

						</FONT><input type="button" value="返回" onclick="javascript:document.location.href='YwYOrderLists.aspx'"/></td>

				</tr>

			</table>

		</form>

	</body>

</HTML>





 <script type="text/javascript">

								

							//删除checkbox

								$("div[id=divshow]").each(function(){

								

								if($(this).next().attr("id")==1)

								{

								    $(this).show();

								    $(this).next().hide();

								    $(this).parent().parent().children().eq(0).html(" ");

								

								}

								

								});

								

								

								

								

								

                            </script>

<script type="text/javascript">

	//隐藏pno

	if($("#hidshowpno").val()=="1")

	{

	    $("input[name=txtpno]").each(function() { $(this).hide();   });

	    $("span[name=pnoview]").each(function() { $(this).show();   });

	   

	}

</script>



<script type="text/javascript">

function GetOrderDetailID()

{

    var ID="";

    $("input[getthis=selectthis]").each(function(){

	 if ($(this).attr("checked")) { 

	     ID+=$(this).val()+",";				

	 }	



	});

	

	

	document.location.href="updateYwOrderDetails.aspx?DealId="+ID+"&OrderId=<%=YW_OrderID %>";

	

}

 </script>



<script language="javascript" type="text/javascript">

	function PrintNote()

	{

		var printText=document.getElementById("divResume").innerHTML;

		document.body.innerHTML=printText;

		document.body.style.backgroundColor='#ffffff';

		

		window.print();

		

		//window.location.href=window.location;

		

		alert("请在打印完毕之后按确定键...");

		//window.close();

		

	}

</script>



<script type="text/javascript" >



function Getxsfp(obj)

{//取pno



     

      if($(obj).val()!="")

      {

          $.post( 

          'ajax.aspx', 

          {pno:$(obj).val()}, 

          function (data,textStatus) //回传函数 

          {

            var trID=$(obj).parent().parent().children().eq(0).text();

            var str="<tr id='"+trID+"' align='center' onmouseover='javascript:changeHangColor(this)' onmouseout='javascript:changeHangColor2(this)'>";

            if(data!="")

            {

                str+="<td> </td>";

                var myObject = eval('(' + data + ')');

                var json=myObject.Table;

               

                

                //最末级遍历

                for(var one in json)

                {

                    for(var key in json[one])

                    {

                        if(json[one][key]=="")

                            str+="<td > </td>";

                        else

                            str+="<td >"+json[one][key]+"</td>";

                    }

                   

                }

                

                str+="<td ><font color='red'  >"+$(obj).val()+"号,产品信息对照</font>";

                //pno

                str+="<input type='hidden' name='hidpno' value='"+$(obj).val()+"' >";

                //je

                for(var i in json)

                {

                    str+="<input type='hidden' name='hidJe' value='"+json[i].Je+"' >";

                    

                    str+="<input type='hidden' name='hidSl' value='"+parseFloat(json[i].sl)*parseFloat($(obj).parent().parent().children().eq(8).text())+"' >";

                    

                    str+="<input type='hidden' name='hidOrderDetailID' value='"+$(obj).parent().parent().children().eq(0).text()+"' >";

                }

                str+="</td>";

                

             

            }

            else

            {

                str+="<td align='center'colspan='13'><font color='red'>订单号错误!或"+$(obj).val()+"不存在!</font></td>";

            }

            

           

            //tr存在则删除   订单号相同时的处理

            if($("#"+trID).length>0)

            {

                $("#"+trID).remove();

            }

            

            str +="</tr>";

            //添加tr

            $(obj).parent().parent().append(str);

            

            //PurchaseCost计算

            var PurchaseCost=0;

            $("input[name=hidJe]").each(function (){  PurchaseCost+=parseFloat($(this).val()); });

            $("#txtPurchaseCost").val(round(PurchaseCost,4));

            $("#hidPurchaseCost").val(round(PurchaseCost,4));

            

             //BillAmount计算

            var BillAmount=0;

            $("input[name=hidSl]").each(function (){  BillAmount+=parseFloat($(this).val()); });

            $("#txtBillAmount").val(round(BillAmount,4));

            $("#hidBillAmount").val(round(BillAmount,4));

            

          }

         ); 

     }

    

    

}



function   round(v,e)   

  {   

    var   t=1;   

    for(;e>0;t*=10,e--);   

    for(;e<0;t/=10,e++);   

    return   Math.round(v*t)/t;   

  } 

  



</script>



<script type="text/javascript">



function tuihuovalidate()

{

    var biaozhi = true;

    

     var ID="";

    $("input[getthis=selectthis]").each(function(){

     if ($(this).attr("checked")) { 

         ID+=$(this).val()+",";				

     }	

    });

    

    if(ID!="")

    {

    

        if(confirm("请先确认已经填写“订单金额“,点击确定完成退货!"))

        {

           

          $("input[delneedValidate=true]").each(function(){

          

          if(!requireField(this))

          { biaozhi = false; }

          }

          )



          return biaozhi;

        }

        else

        return false;

    }

    else

    {

        alert("请选择操作项!");

        return false;

    }

    

}



//验证

  $("input[needValidate='true']").blur(function()

  {//点击失去焦点时

      if(requireField(this))//首先客户端验证

      {

     

      //$('#num_error').html("");

      $('#'+this.id+'_error').html("");

      }





  });

  

  //验证

  $("input[delneedValidate='true']").blur(function()

  {//点击失去焦点时

      if(requireField(this))//首先客户端验证

      {

     

      //$('#num_error').html("");

      $('#'+this.id+'_error').html("");

      }





  });

  

  function validate()

  {//提交时

      var biaozhi = true;

      

      biaozhi=checkpno();



      $("input[needValidate='true']").each(function(i){

      if(!requireField(this))

      { biaozhi = false; }

      }

      )



      return biaozhi;

  }

  

  function requireField(o)

  {



  var ReturnValue;



  var num = /^\d{0,10}(\d|(\.[0-9]{1,4}))$/;







  var txtPurchaseCost_error = "请输入真实采购成本;如10000.0000!";

  var txtBillAmount_error = "请输入真实售出价格;如10000.0000!";

  var txtBillCost_Rebates_error = "请输入真实发票成本或返点费;如10000.0000!";

  var txtSystemCost_error = "请输入真实管理费;如10000.0000!";

    

  var deltxtBillCost_Rebates_error = "*";

  var deltxtSystemCost_error = "*";





  if(o.value.match(eval(num)) )

  {

  ReturnValue= true;

  }

  else

  {



  $('#'+o.id+'_error').html(eval(o.id+'_error')).attr("style","color:red;");

  ReturnValue= false;

  }





  return ReturnValue;

  }

  

  function checkpno()

 {

      var ReturnValue;

      //规则验证

      var pno = /^([0-9]){1,}$/;

      

      var str="";

      $("input[name=txtpno]").each(function(){ 

            str+=$(this).val();

       });

       

      if(str.match(pno))

      {

        ReturnValue= true;

      }

      else

      {

          $('#txtpno_error').html("请输入正确单号!").attr("style","color:red;");

          ReturnValue=false;

      }

     



      //正确验证

      if(ReturnValue==true)

      {

      $('#txtpno_error').html("");

      }

      return  ReturnValue;



  }

 

</script>



<script type="text/javascript">

	function selectallCheckBox()   //全选/取消

	{

		var element = document.Form1.elements;

		var length = element.length;

		if(document.all("selectall").checked == true)

		{

			for(var i =0;i<length;i++)

			{

				if(element[i].type == "checkbox")

				{

					element[i].checked = true;

				}

			}

		}else

		{

			for(var i =0;i<length;i++)

			{

				if(element[i].type == "checkbox")

				{

					element[i].checked = false;

				}

			}

		}

	}

	function CheckSelect()	//检查是否选择订单

	{

		var element = document.Form1.elements;

		var length = element.length;

		var flag = false;

	

		for(var i =0;i<length;i++)

		{

			if(element[i].type == "checkbox"&&element[i].checked == true)

			{

				flag = true;				

				break;

			}	

		}

		if(flag == false)

		{

			alert("请至少选择一个订单!");

			return false;

		}

		else

		{

			return true;

		}				

	}

	function DelAll()		//是否删除

	{

		if(confirm("确定要删除订单?"))

		{

			return CheckSelect();

		}

		else

		{

			return false;

		}

	}

	

 //变色

 var currentColor="";

 function changeHangColor(objTR)

 {

    currentColor = $(objTR).children("td").attr("bgColor");

    

    $(objTR).children("td").each(

      function(i)

      {

        $(objTR).children("td").eq(i).attr("bgColor","#e8eefa");

      }

    )

            

 }

 function changeHangColor2(objTR)

 {

 

    $(objTR).children("td").each(

      function(i)

      {

        $(objTR).children("td").eq(i).attr("bgColor","#FFFFFF");

      }

    )

 }

</SCRIPT>



using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using System.Text.RegularExpressions;

using System.Text;

using HyeyClass.Common;

 

namespace HyeyManager.Order

{

	/// <summary>

	/// 功能: 业务员系统订单详细信息.

	/// 时间: 2009-09-23

	/// 作者: Hyey.wl

	/// 其它:

	/// 修改:2009-12-14

	/// YwYOrderDetails 的摘要说明。

	/// </summary>

	public class YwYOrderDetails : System.Web.UI.Page

	{

		#region 初始化

		protected System.Web.UI.WebControls.TextBox tbxOrderId;

		protected System.Web.UI.WebControls.TextBox tbxUserName;

		protected System.Web.UI.WebControls.TextBox tbxCompany;

		protected System.Web.UI.WebControls.TextBox tbxTrueName;

		protected System.Web.UI.WebControls.TextBox tbxMobile;

		protected System.Web.UI.WebControls.DropDownList dplOrderState;

		protected System.Web.UI.WebControls.ImageButton imbSearch;

		protected System.Web.UI.WebControls.Label lblOrderId;

		protected System.Web.UI.WebControls.Label lblSalesCompany;

		protected System.Web.UI.WebControls.Label lblSupporter;

		protected System.Web.UI.WebControls.Repeater rptOrderDetail;

		protected System.Web.UI.WebControls.Label lblOTprice;

		protected System.Web.UI.WebControls.Label lblUserName;

		protected System.Web.UI.WebControls.Label lblCompany;

		protected System.Web.UI.WebControls.Label lblTrueName;

		protected System.Web.UI.WebControls.Label lblMobile;

		protected System.Web.UI.WebControls.Label lblAddress;

		protected System.Web.UI.WebControls.Label lblInsertTime;

		protected System.Web.UI.WebControls.Label lblOrderSource;

		protected System.Web.UI.WebControls.Label lblOrderState;

		protected System.Web.UI.WebControls.Label lblPayMode;

		protected System.Web.UI.WebControls.Label lblSendMode;

		protected System.Web.UI.WebControls.DropDownList ddlType;

		protected System.Web.UI.WebControls.TextBox txtBeginTime;

		protected System.Web.UI.WebControls.TextBox txtEndTime;

		protected System.Web.UI.HtmlControls.HtmlGenericControl divResume;

		protected System.Web.UI.WebControls.Repeater rptZyOrderDetail;

		protected System.Web.UI.WebControls.Label lblRemark;







        protected System.Web.UI.WebControls.Repeater rpt_YwDealOrderDetail;

        

        protected System.Web.UI.WebControls.TextBox txtPurchaseCost;

        protected System.Web.UI.WebControls.TextBox txtBillAmount;

        protected System.Web.UI.WebControls.DropDownList ddlBillCost_Rebates;

        protected System.Web.UI.WebControls.TextBox txtBillCost_Rebates;

        protected System.Web.UI.WebControls.TextBox txtSystemCost;

        protected System.Web.UI.WebControls.Button btnadd;



        protected System.Web.UI.WebControls.Panel divList;

        protected System.Web.UI.WebControls.Panel divAdd;



        protected System.Web.UI.WebControls.HiddenField hidPurchaseCost;

        protected System.Web.UI.WebControls.HiddenField hidBillAmount;

        protected System.Web.UI.WebControls.HiddenField hidshowpno;



        protected System.Web.UI.WebControls.DropDownList delddlBillCost_Rebates;

        protected System.Web.UI.WebControls.TextBox deltxtBillCost_Rebates;

        protected System.Web.UI.WebControls.TextBox deltxtSystemCost;

        protected System.Web.UI.WebControls.Button btnprint;

        

	

		#endregion



        public int YW_OrderID

        {

            get

            {

                if (Request.QueryString["OrderId"] != null)

                {

                    return Convert.ToInt32(Request.QueryString["OrderId"]);

                }

                else

                    return 0;

            }

        }



		#region 页面加载

		private void Page_Load(object sender, System.EventArgs e)

		{

			// 在此处放置用户代码以初始化页面

			if(!IsPostBack)

			{

				bind_data();

			}

		}

		#endregion



		#region 绑定订单信息和采购订单药品的详细信息

		/// <summary>

		/// 功能:绑定页面信息

		/// 时间:09-09-23

		/// 作者:Hyey.wl

		/// 修改:

		/// 版本:

		/// 其它:

		/// Bind_datas this instance.

		/// </summary>

		private void bind_data()

		{

			string OrderId = HyeyClass.Web.PageValidate.ReplaceStr((""+Request.QueryString["OrderId"]).Trim());

			if(!HyeyClass.Web.PageValidate.IsNumber(OrderId))

			{

				Response.Write("<script defer>alert('你的信息不正确!请重试!');history.back();</script>");

				Response.End();

			}

			lblOrderId.Text = OrderId;		



			#region 查询数据

			System.Text.StringBuilder mySB = new System.Text.StringBuilder();

			mySB.Append("[YwOrders].[OrderID] ,[YwUserID]=(select username from MembersView where Userid=[YwOrders].YwUserID)");

			mySB.Append(",[DW]");

			mySB.Append(",[CUserID] ,[CUserName]  ,[CTrueName] ,Left([CCompany],12) AS [CCompany]  ,[CPostCode]");

			mySB.Append(",[CPhone] ,[CMobile],[CEmail],[EAddress],[InsertTime],[TotalPiece],[Amount],[Zq]");

			mySB.Append(",[OrderState] = (case OrderState ");

			mySB.Append("when 0 then '<font color=red>新订单</font>' ");

			mySB.Append("when 1 then '<font color=blue>请求处理</font>'");

			mySB.Append("when 2 then '<font color=Brown>处理中</font>'");

			mySB.Append("when 3 then '<font color=darkgoldenrod>已处理</font>'");

			mySB.Append("when 4 then '<font color=green>已完成</font>'");

			mySB.Append(" else '未处理' end)");

			mySB.Append(" ,[OrderModel]= (case OrderModel ");

			mySB.Append("  when 0 then '<font color=Orange>终端采购会员订单</font>' ");

			mySB.Append("  when 1 then '<font color=SaddleBrown>业务员采购的订单</font>'");

			mySB.Append(" else '未处理'  end)");

			mySB.Append("   ,[Remark]");

			mySB.Append(",[OrderDetailID]");

			mySB.Append(",[DrugID]");

			mySB.Append(",[Ypmc]");

			mySB.Append(",[Cdmc]");

			mySB.Append(",[Gg]");

			mySB.Append(",[Ph]");

			mySB.Append(",[Bz]");

			mySB.Append(",[Yprice]");

			mySB.Append(",[SL]");

			mySB.Append(",[PieceNum]");

			mySB.Append(",[Price]");

			mySB.Append(",[Je]");           

			mySB.Append(",[TradeSate]");

            mySB.Append(",PurchaseCost,BillAmount,BillCost,Rebates,SystemCost");

            mySB.Append(",isnull((select ERPSaleID from YwDealOrderDetail where OrderDetailId=YwOrderDetail.OrderDetailId),'未采购') as pno");

			mySB.Append(",'汇款' as PayMode,'未定' as SendMode");

			mySB.Append(",'华源网' as OrderSource ,[YwOrderDetail].Source as Source");

			string FindStr = mySB.ToString();

			#endregion



            DataSet ds = HyeyClass.Bll.YwOrders.GetOrderListInfo(FindStr, "[YwOrderDetail] ,[YwOrders]", " [YwOrders].[OrderID] = '" + OrderId + "' AND [YwOrders].[OrderID] = [YwOrderDetail].[OrderID] ");



            if (ds.Tables[0].Rows.Count > 0)

            {

                lblUserName.Text = ds.Tables[0].Rows[0]["CUserName"].ToString();

                lblAddress.Text = ds.Tables[0].Rows[0]["EAddress"].ToString();

                lblCompany.Text = ds.Tables[0].Rows[0]["CCompany"].ToString();

                lblTrueName.Text = ds.Tables[0].Rows[0]["CTrueName"].ToString();

                lblMobile.Text = ds.Tables[0].Rows[0]["CMobile"].ToString();

                lblInsertTime.Text = ds.Tables[0].Rows[0]["InsertTime"].ToString();



                if (ds.Tables[0].Rows[0]["OrderSource"].ToString().Trim() == String.Empty)

                {

                    lblOrderSource.Text = "华源网";

                }

                else

                {

                    lblOrderSource.Text = ds.Tables[0].Rows[0]["OrderSource"].ToString();

                }



                lblOrderState.Text = ds.Tables[0].Rows[0]["OrderState"].ToString();

                lblPayMode.Text = ds.Tables[0].Rows[0]["PayMode"].ToString();

                lblSendMode.Text = ds.Tables[0].Rows[0]["SendMode"].ToString();

                lblSupporter.Text = ds.Tables[0].Rows[0]["YwUserID"].ToString();

                lblSalesCompany.Text = "华源医药业务员";

                lblRemark.Text = ds.Tables[0].Rows[0]["remark"].ToString();

                lblOTprice.Text = (decimal.Round(decimal.Parse(ds.Tables[0].Rows[0]["Amount"].ToString()), 2)).ToString();







                txtPurchaseCost.Text = ds.Tables[0].Rows[0]["PurchaseCost"].ToString();

                txtBillAmount.Text = ds.Tables[0].Rows[0]["BillAmount"].ToString();

                if (string.IsNullOrEmpty(ds.Tables[0].Rows[0]["BillCost"].ToString()) && string.IsNullOrEmpty(ds.Tables[0].Rows[0]["Rebates"].ToString()))

                {

                    ddlBillCost_Rebates.Enabled = true;

                    delddlBillCost_Rebates.Enabled = true;

                }

                else

                {

                    if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["BillCost"].ToString()) && ds.Tables[0].Rows[0]["BillCost"].ToString() != "0.0000")

                    {

                        txtBillCost_Rebates.Text = ds.Tables[0].Rows[0]["BillCost"].ToString();

                        ddlBillCost_Rebates.SelectedIndex = 0;

                        delddlBillCost_Rebates.SelectedIndex = 0;

                    }

                    else

                    {

                        txtBillCost_Rebates.Text = ds.Tables[0].Rows[0]["Rebates"].ToString();

                        ddlBillCost_Rebates.SelectedIndex = 1;

                        delddlBillCost_Rebates.SelectedIndex = 1;

                    }

                    ddlBillCost_Rebates.Enabled = false;

                    delddlBillCost_Rebates.Enabled = false;

                }



                txtSystemCost.Text = ds.Tables[0].Rows[0]["SystemCost"].ToString();



            }





			// Hyey.wl Mod 2010-04-19 添加只有品种和华源品种分开处理.

			if(ds != null && ds.Tables[0].Rows.Count > 0)

			{

				DataView  dv = ds.Tables[0].DefaultView;

				#region  华源品种订单				 

				dv.RowFilter = "Source ='0'";				

				rptOrderDetail.DataSource = dv;

				rptOrderDetail.DataBind();

								

				#endregion		

                 

				#region  自有品种订单

				dv.RowFilter = "Source <> '0'";					

				rptZyOrderDetail.DataSource = dv;

				rptZyOrderDetail.DataBind();

					

				#endregion

			}

			else

			{

               rptOrderDetail.Visible = false;

               rptZyOrderDetail.Visible = false;

			}



		

			mySB.Remove(0,mySB.Length);

			ds.Clear();

			ds.Dispose();





            Bindtrue();

           





        }



        /// <summary>

        /// 绑定真实成交单

        /// </summary>

        public void Bindtrue()

        {

            #region charry

            StringBuilder s = new StringBuilder();

            s.AppendFormat(" select a.* from YwDealOrderDetail a where a.OrderID={0} order by TradeDate desc", YW_OrderID);

            DataSet ds_YwOrderDetail = HyeyClass.DALFactory.DataAccess.CreateComm().GetList(s.ToString());



            if (ds_YwOrderDetail != null && ds_YwOrderDetail.Tables[0].Rows.Count > 0)

            {

                DataView dv = ds_YwOrderDetail.Tables[0].DefaultView;

                #region  华源品种订单

                //dv.RowFilter = "Source ='0'";

                rpt_YwDealOrderDetail.DataSource = dv;

                rpt_YwDealOrderDetail.DataBind();



                #endregion



                divList.Visible = true;

                txtBillCost_Rebates.Enabled = false;

                txtSystemCost.Enabled = false;

                btnadd.Visible = false;

                hidshowpno.Value = "1";

            }

            else

            {

                rpt_YwDealOrderDetail.Visible = false;

                rpt_YwDealOrderDetail.Visible = false;

                btnprint.Visible = false;



            }

            #endregion



            //txtPurchaseCost.Text = "";

            //txtBillAmount.Text = "";

            //txtBillCost_Rebates.Text = "";

            //txtSystemCost.Text = "";

            



        }



		#endregion



		#region 辅助函数		

		/// <summary>

		/// Gets the decimal.

		/// </summary>

		/// <param name="strDec">The STR dec.</param>

		/// <returns></returns>

		public string GetDecimal(string strDec)

		{

           return (decimal.Round(decimal.Parse(strDec),2)).ToString();

		}

		#endregion



		#region Web 窗体设计器生成的代码

		override protected void OnInit(EventArgs e)

		{

			//

			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。

			//

			InitializeComponent();

			base.OnInit(e);

		}

		

		/// <summary>

		/// 设计器支持所需的方法 - 不要使用代码编辑器修改

		/// 此方法的内容。

		/// </summary>

		private void InitializeComponent()

		{

			this.Load += new System.EventHandler(this.Page_Load);

           



		}

		#endregion



        protected void btnadd_Click(object sender, EventArgs e)

        {

            string strpno = Request.Form["hidpno"];

            string strOrderDetailID = Request.Form["hidOrderDetailID"];

            int rev = 0;



            if (!string.IsNullOrEmpty(strpno))

            {

                





                #region YwOrders

                HyeyClass.Model.YwOrders model_yworder = new HyeyClass.Model.YwOrders();



                model_yworder.OrderID = YW_OrderID;

                model_yworder.PurchaseCost = Convert.ToDecimal(hidPurchaseCost.Value);

                model_yworder.BillAmount = Convert.ToDecimal(hidBillAmount.Value);

                if (ddlBillCost_Rebates.Text == "1")

                {

                    model_yworder.BillCost = Convert.ToDecimal(txtBillCost_Rebates.Text);

                    model_yworder.Rebates = 0;

                   

                }

                else

                {

                    model_yworder.BillCost = 0;

                    model_yworder.Rebates = Convert.ToDecimal(txtBillCost_Rebates.Text);

                }

                model_yworder.SystemCost = Convert.ToDecimal(txtSystemCost.Text);

                #endregion



                #region YwFundsInfo



                Role roleObj = new RoleOper();

                string AdminName = roleObj.CheckAdmin();



                decimal sum = Convert.ToDecimal(model_yworder.PurchaseCost + model_yworder.BillAmount + model_yworder.BillCost - model_yworder.Rebates + model_yworder.SystemCost);

                HyeyClass.Model.YwFundsInfo model_ywfundsinfo = new HyeyClass.Model.YwFundsInfo();





                model_ywfundsinfo.PriceSum = sum;

                model_ywfundsinfo.PriceType = 1;//金额交易类型  0:打款 本笔存入金额;1:交易 本笔支出金额;2:结转

                model_ywfundsinfo.TradeTime = DateTime.Now;

                model_ywfundsinfo.TradeDescr = "累计支出金额-成交";//定制描述规则

                model_ywfundsinfo.OperPerson = AdminName;

                model_ywfundsinfo.RelatedObjcectId = YW_OrderID;





                #endregion



                #region ManageLog





                HyeyClass.Model.ManageLog model_managelog = new HyeyClass.Model.ManageLog();



                model_managelog.NodeId = 64;

                model_managelog.LtyId = 39;

                model_managelog.MglUserIP = HttpContext.Current.Request.UserHostAddress;

                model_managelog.MglUserName = AdminName;

                model_managelog.MglWorkAddr = HttpContext.Current.Request.Path;

                model_managelog.MglPostPara = HttpContext.Current.Request.QueryString.ToString();

                model_managelog.MglWorkTime = DateTime.Now;

                model_managelog.MglType = 1;//操作成功

                #endregion



                

                Regex reg = new Regex(",");

                string[] pno = reg.Split(strpno);



                string[] OrderDetailID = reg.Split(strOrderDetailID);



                for (int i = 0; i < pno.Length; i++ )

                {

                    if (!string.IsNullOrEmpty(pno[i]))

                    {



                        #region YwDealOrderDetail

                        HyeyClass.Model.YwDealOrderDetail model_yworderdetail = new HyeyClass.Model.YwDealOrderDetail();



                        StringBuilder s = new StringBuilder();

                        s.AppendFormat(" select a.* from xsfp a where a.pno='{0}' ", pno[i]);

                        DataSet ds_YwOrderDetail = HyeyClass.DALFactory.DataAccess.CreateComm().GetList(s.ToString());

                        

                        if (ds_YwOrderDetail != null)

                        {

                            if (ds_YwOrderDetail.Tables[0].Rows.Count > 0)

                            {



                                model_yworderdetail.OrderDetailId = Convert.ToInt32(OrderDetailID[i]);

                                model_yworderdetail.OrderID = YW_OrderID;

                                model_yworderdetail.ERPSaleID = pno[i];

                                model_yworderdetail.Ypmc = ds_YwOrderDetail.Tables[0].Rows[0]["Ypmc"].ToString();

                                model_yworderdetail.Cdmc = ds_YwOrderDetail.Tables[0].Rows[0]["Cdmc"].ToString();

                                model_yworderdetail.Gg = ds_YwOrderDetail.Tables[0].Rows[0]["Gg"].ToString();

                                model_yworderdetail.Ph = ds_YwOrderDetail.Tables[0].Rows[0]["Ph"].ToString();

                                model_yworderdetail.Bz = ds_YwOrderDetail.Tables[0].Rows[0]["Bz"].ToString();

                                model_yworderdetail.YXQ = ds_YwOrderDetail.Tables[0].Rows[0]["YXQ"].ToString();

                                model_yworderdetail.PZWH = ds_YwOrderDetail.Tables[0].Rows[0]["PZWH"].ToString();

                                model_yworderdetail.Dw = ds_YwOrderDetail.Tables[0].Rows[0]["Dw"].ToString();

                                if (ds_YwOrderDetail.Tables[0].Rows[0]["Lsj"].ToString() != "")

                                    model_yworderdetail.Lsj = Convert.ToDecimal(ds_YwOrderDetail.Tables[0].Rows[0]["Lsj"].ToString());

                                model_yworderdetail.CK = ds_YwOrderDetail.Tables[0].Rows[0]["CK"].ToString();

                                model_yworderdetail.Cashier = ds_YwOrderDetail.Tables[0].Rows[0]["Cashier"].ToString();

                                model_yworderdetail.InvoiceClerck = ds_YwOrderDetail.Tables[0].Rows[0]["InvoiceClerck"].ToString();

                                //原单价

                                model_yworderdetail.Yprice = Convert.ToDecimal(ds_YwOrderDetail.Tables[0].Rows[0]["dj"].ToString());

                                model_yworderdetail.TradeState = 0;

                                model_yworderdetail.TradeDate = DateTime.Now;

                                model_yworderdetail.SL = Convert.ToInt32(ds_YwOrderDetail.Tables[0].Rows[0]["SL"].ToString());

                                





                                //单价与件数



                                string str = " select *  from YwOrderDetail where OrderDetailId=" + OrderDetailID[i];

                                DataSet ds_1 = HyeyClass.DALFactory.DataAccess.CreateComm().GetList(str.ToString());

                                if (ds_1 != null && ds_1.Tables[0].Rows.Count > 0)

                                {

                                    if (!string.IsNullOrEmpty(ds_1.Tables[0].Rows[0]["pieceNum"].ToString()))

                                        model_yworderdetail.pieceNum = Convert.ToInt32(ds_1.Tables[0].Rows[0]["pieceNum"].ToString());

                                    if (!string.IsNullOrEmpty(ds_1.Tables[0].Rows[0]["Price"].ToString()))

                                        model_yworderdetail.Price = Convert.ToDecimal(ds_1.Tables[0].Rows[0]["Price"].ToString());

                                }

                                model_yworderdetail.Je = Convert.ToDecimal(model_yworderdetail.Price * model_yworderdetail.SL);



                           



                            }

                        }



                        #endregion



                        rev = HyeyClass.Bll.YwOrders.addYwDealOrderDetail(model_yworder, model_yworderdetail, model_ywfundsinfo, model_managelog);

                    }



                }

            }

            Response.Redirect("YwYOrderDetails.aspx?orderid=" + YW_OrderID);

            





        }



        protected void rpt_YwDealOrderDetail_ItemCommand(object source, RepeaterCommandEventArgs e)

        {

            if (e.CommandName == "btnDelete")

            {

                if (DelOrderDetail(Convert.ToInt32(e.CommandArgument))== 1)

                    Page.ClientScript.RegisterStartupScript(this.GetType(), "js", "<script>alert('操作成功!');</script>");

                else

                    Page.ClientScript.RegisterStartupScript(this.GetType(), "js", "<script>alert('操作失败!');</script>");

            }



            Bindtrue();





        }



        /// <summary>

        /// 退货

        /// </summary>

        /// <param name="DealID"></param>

        /// <returns></returns>

        public int DelOrderDetail(int DealID)

        {

            #region YwOrders

            HyeyClass.Model.YwOrders model_yworder = new HyeyClass.Model.YwOrders();



            model_yworder.OrderID = YW_OrderID;

   

            if (delddlBillCost_Rebates.Text == "1")

            {

                model_yworder.BillCost = Convert.ToDecimal(deltxtBillCost_Rebates.Text);

                model_yworder.Rebates = 0;



            }

            else

            {

                model_yworder.BillCost = 0;

                model_yworder.Rebates = Convert.ToDecimal(deltxtBillCost_Rebates.Text);

            }

            model_yworder.SystemCost = Convert.ToDecimal(deltxtSystemCost.Text);

            #endregion



            #region YwFundsInfo

            Role roleObj = new RoleOper();

            string AdminName = roleObj.CheckAdmin();



            decimal sum = Convert.ToDecimal(model_yworder.PurchaseCost + model_yworder.BillAmount + model_yworder.BillCost - model_yworder.Rebates + model_yworder.SystemCost);

            HyeyClass.Model.YwFundsInfo model_ywfundsinfo = new HyeyClass.Model.YwFundsInfo();





            model_ywfundsinfo.PriceSum = sum;

            model_ywfundsinfo.PriceType = 0;//金额交易类型  0:打款 本笔存入金额;1:交易 本笔支出金额;2:结转

            model_ywfundsinfo.TradeTime = DateTime.Now;

            model_ywfundsinfo.TradeDescr = "累计存入金额-退货";//定制描述规则

            model_ywfundsinfo.OperPerson = AdminName;

            model_ywfundsinfo.RelatedObjcectId = YW_OrderID;

            #endregion



            #region managelog

            HyeyClass.Model.ManageLog model_managelog = new HyeyClass.Model.ManageLog();



            model_managelog.NodeId = 64;

            model_managelog.LtyId = 39;

            model_managelog.MglUserIP = HttpContext.Current.Request.UserHostAddress;

            model_managelog.MglUserName = AdminName;

            model_managelog.MglWorkAddr = HttpContext.Current.Request.Path;

            model_managelog.MglPostPara = HttpContext.Current.Request.QueryString.ToString();

            model_managelog.MglWorkTime = DateTime.Now;

            model_managelog.MglType = 1;//操作成功

            #endregion



            return HyeyClass.Bll.YwOrders.DeleteYwDealOrderDetail(model_yworder, DealID, model_ywfundsinfo, model_managelog);

        }





        protected void lkbDownOrdr_Click(object sender, EventArgs e)

        {





        }





        protected void lbtDel_Click(object sender, EventArgs e)

        {

            foreach (RepeaterItem item in rpt_YwDealOrderDetail.Items)

            {

                HtmlInputCheckBox ckbox = (HtmlInputCheckBox)item.FindControl("selectthisbox");

                if (ckbox.Checked == true)

                {

                    DelOrderDetail(Convert.ToInt32(ckbox.Value));



                }

            }



            bind_data();

            deltxtBillCost_Rebates.Text = "";

            deltxtSystemCost.Text = "";

            deltxtSystemCost.Enabled = false;

            deltxtBillCost_Rebates.Enabled = false;

        }





		

	}

}



 

你可能感兴趣的:(jquery)