using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace Bll
{
	public class OrdersBll
	{
		private static string statusaaa = "定单已生成，未取瓶";
		private string sqlcmd1 = "select ca.name,ct.name,c.id,c.client_name,c.mobile,c.address from CLIENT c inner join CLIENT_AREA ca on c.cli_id = ca.id inner join CLIENT_TYPE ct on ct.id = c.cli_id2 where c.mobile=";
		private string sqlcmd4 = "select count(*) from CLIENT c inner join CLIENT_AREA ca on c.cli_id = ca.id inner join CLIENT_TYPE ct on ct.id = c.cli_id2 where c.mobile = ";
		private string sqlcmd2 = "select c.id,c.client_name,ca.name,ct.name,c.mobile,c.address,c.insert_date_time from CLIENT c inner join CLIENT_AREA ca on c.cli_id = ca.id inner join CLIENT_TYPE ct on ct.id = c.cli_id2";
		private string sqlcmd3 = "SELECT l.id,c.client_name,c.mobile,l.productName,l.amount,l.foregift,l.month_hire,l.status,l.inser_data_time,l.over_data_time FROM dbo.LEASE l inner join dbo.CLIENT c on l.cli_id = c.id order by inser_data_time desc";
		private string sqlcmd5 = "select * from dbo.PRODUCT";
        private string sqlcmd7 = "select o.id,o.no,c.client_name,c.mobile,ca.name,c.address,p.name,o.price,o.aount,o.cope_money,o.fact_money,o.insert_date_time,o.payment_date_time,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.MOME,o.BOTTLE,o.TACK_NUMBER from orders o inner join dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id order by o.insert_date_time desc";
        private string sqlcmd9 = "select ca.name,c.address,c.mobile,o.aount,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.price,o.fact_money,o.insert_date_time,o.mome from orders o inner join dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id  where o.insert_date_time between '" + DateTime.Now.ToShortDateString() + "' and dateadd(d,1,'" + DateTime.Now.ToShortDateString() + "') order by o.insert_date_time desc";
		/// 得到客户数据
		/// </summary>
		/// <param name="id"></param>
		/// <returns></returns>
		public SqlDataReader GetReader(string moblie)
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			SqlDataReader reader = sqlhelp.GetSqlDataReader("select ca.name,ct.name,c.id,c.client_name,c.mobile,c.address from CLIENT c inner join CLIENT_AREA ca on c.cli_id = ca.id inner join CLIENT_TYPE ct on ct.id = c.cli_id2 where c.mobile='" + moblie + "'");
			return reader;
		}

		/// <summary>
		/// 关闭数据库
		/// </summary>
		public void Close()
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			sqlhelp.Close();
		}

		/// <summary>
		/// 返回记录的数目
		/// </summary>
		/// <param name="moblie"></param>
		/// <returns></returns>
		public int GetExcuteScal(string moblie)
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			return sqlhelp.RunSqlReturn("select count(*) from CLIENT c inner join CLIENT_AREA ca on c.cli_id = ca.id inner join CLIENT_TYPE ct on ct.id = c.cli_id2 where c.mobile = '" + moblie + "'");
		}

		/// <summary>
		/// 添加租瓶信息
		/// </summary>
		/// <param name="cli_id">客户标示</param>
		/// <param name="productname">产品名</param>
		/// <param name="amount">数量</param>
		/// <param name="foregift">押金</param>
		/// <param name="month_hire">月租</param>
		/// <param name="inser_data_time">插入时间</param>
		/// <param name="status">状态</param>
		/// <param name="mome">备注</param>
		public void AddLeaseInfo(int cli_id, string productname, int amount, decimal foregift, decimal month_hire, DateTime inser_data_time, string status, string mome)
		{
			string sqlstr = "insert into LEASE(cli_id,productname,amount,foregift,month_hire,inser_data_time,status,mome) values(@cli_id,@productname,@amount,@foregift,@month_hire,@inser_data_time,@status,@mome)";
			using (SqlConnection sqlconn = new SqlConnection(DataBaseDrHelp.strConn))
			{
				sqlconn.Open();
				SqlCommand cmd = new SqlCommand(sqlstr, sqlconn);
				cmd.Parameters.Add("@cli_id", SqlDbType.Int).Value = cli_id;
				cmd.Parameters.Add("@productname", SqlDbType.VarChar, 10).Value = productname;
				cmd.Parameters.Add("@amount", SqlDbType.Int).Value = amount;
				cmd.Parameters.Add("@foregift", SqlDbType.Decimal).Value = foregift;
				cmd.Parameters.Add("@month_hire", SqlDbType.Decimal).Value = month_hire;
				cmd.Parameters.Add("@inser_data_time", SqlDbType.DateTime).Value = inser_data_time;
				cmd.Parameters.Add("@status", SqlDbType.VarChar, 50).Value = status;
				cmd.Parameters.Add("@mome", SqlDbType.VarChar, 50).Value = mome;
				cmd.ExecuteNonQuery();
			}
		}

		/// <summary>
		/// 得到所有客户
		/// </summary>
		/// <returns></returns>
		public DataSet GetAllClientInfo()
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			DataSet ds = new DataSet();
			using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlcmd2))
			{
				DataTable dt = new DataTable("Client");
				dt.Columns.Add(new DataColumn("c.id", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("c.client_name", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("ct.name", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("c.insert_date_time", Type.GetType("System.String")));
				while (reader.Read())
				{
					DataRow dr = dt.NewRow();
					dr["c.id"] = reader[0];
					dr["c.client_name"] = reader[1];
					dr["ca.name"] = reader[2];//ct.name
					dr["ct.name"] = reader[3];//ca.name
					dr["c.mobile"] = reader[4];
					dr["c.address"] = reader[5];
					dr["c.insert_date_time"] = reader[6];
					dt.Rows.Add(dr);
				}
				ds.Tables.Add(dt);
			}
			return ds;
		}

		/// <summary>
		/// 通过手机号得到客户信息
		/// </summary>
		/// <returns></returns>
		public DataSet GetAllClientInfo(string mobile)
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			DataSet ds = new DataSet();
			using (SqlDataReader reader = sqlhelp.GetSqlDataReader("select c.id,c.client_name,ca.name,ct.name,c.mobile,c.address,c.insert_date_time from CLIENT c inner join CLIENT_AREA ca on c.cli_id = ca.id inner join CLIENT_TYPE ct on ct.id = c.cli_id2 where mobile = '" + mobile + "'"))
			{
				DataTable dt = new DataTable("Client");
				dt.Columns.Add(new DataColumn("c.id", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("c.client_name", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("ct.name", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("c.insert_date_time", Type.GetType("System.String")));
				while (reader.Read())
				{
					DataRow dr = dt.NewRow();
					dr["c.id"] = reader[0];
					dr["c.client_name"] = reader[1];
					dr["ca.name"] = reader[2];//ct.name
					dr["ct.name"] = reader[3];//ca.name
					dr["c.mobile"] = reader[4];
					dr["c.address"] = reader[5];
					dr["c.insert_date_time"] = reader[6];
					dt.Rows.Add(dr);
				}
				ds.Tables.Add(dt);
			}
			return ds;
		}


		/// <summary>
		/// 返回所有的租瓶信息
		/// </summary>
		/// <returns></returns>
		public DataSet GetAllLeaseInfo()
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			DataSet ds = new DataSet();
			using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlcmd3))
			{
				DataTable dt = new DataTable("LeaseInfo");
				dt.Columns.Add(new DataColumn("l.id", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("c.client_name", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("l.productName", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("l.amount", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("l.foregift", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("l.month_hire", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("l.status", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("l.inser_data_time", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("l.over_data_time", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("day", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("money", Type.GetType("System.String")));


				while (reader.Read())
				{
					DataRow dr = dt.NewRow();
					dr["l.id"] = reader[0];
					dr["c.client_name"] = reader[1];
					dr["c.mobile"] = reader[2];
					dr["l.productName"] = reader[3];
					dr["l.amount"] = reader[4];
					dr["l.foregift"] = reader[5];
					dr["l.month_hire"] = reader[6];
					dr["l.status"] = reader[7];
					dr["l.inser_data_time"] = reader[8];
					dr["l.over_data_time"] = reader[9];
					string over = reader[9].ToString();
					string start = reader[8].ToString();
					decimal dd = Convert.ToDecimal(reader[6]);
					if (over != "")
					{
						dr["day"] = Convert.ToDateTime(over) - Convert.ToDateTime(start);
						TimeSpan daynumber = Convert.ToDateTime(over) - Convert.ToDateTime(start);
						double number = daynumber.TotalDays; //Convert.ToInt32(daynumber.Substring(0));
						dr["money"] = Convert.ToInt32(number) * dd;
					}
					else
					{
						dr["day"] = "";
						dr["money"] = "";
					}
					
					dt.Rows.Add(dr);
				}
				ds.Tables.Add(dt);
			}
			return ds;
		}

		/// <summary>
		/// 退租
		/// </summary>
		public void QuitLease(string id, string status)
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			sqlhelp.RunSql("update LEASE set status = '" + status + "',OVER_DATA_TIME ='" + DateTime.Now + "' where id = '" + id + "'");
		}

		/// <summary>
		/// 按照手机号查询租瓶信息
		/// </summary>
		/// <returns></returns>
		public DataSet GetSignLeaseInfo(string mobile)
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			DataSet ds = new DataSet();
			string sqlstr = "SELECT l.id,c.client_name,c.mobile,l.productName,l.amount,l.foregift,l.month_hire,l.status,l.inser_data_time,l.over_data_time FROM dbo.LEASE l inner join dbo.CLIENT c on l.cli_id = c.id where c.mobile ='" + mobile + "'";
			using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlstr))
			{
				DataTable dt = new DataTable("LeaseInfo");
				dt.Columns.Add(new DataColumn("l.id", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("c.client_name", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("l.productName", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("l.amount", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("l.foregift", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("l.month_hire", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("l.status", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("l.inser_data_time", Type.GetType("System.String")));
				dt.Columns.Add(new DataColumn("l.over_data_time", Type.GetType("System.String")));
                dt.Columns.Add(new DataColumn("day", Type.GetType("System.String")));
                dt.Columns.Add(new DataColumn("money", Type.GetType("System.String")));
				while (reader.Read())
				{
					DataRow dr = dt.NewRow();
					dr["l.id"] = reader[0];
					dr["c.client_name"] = reader[1];
					dr["c.mobile"] = reader[2];
					dr["l.productName"] = reader[3];
					dr["l.amount"] = reader[4];
					dr["l.foregift"] = reader[5];
					dr["l.month_hire"] = reader[6];
					dr["l.status"] = reader[7];
					dr["l.inser_data_time"] = reader[8];
					dr["l.over_data_time"] = reader[9];
                    string over = reader[9].ToString();
                    string start = reader[8].ToString();
                    decimal dd = Convert.ToDecimal(reader[6]);
                    if (over != "")
                    {
                        dr["day"] = Convert.ToDateTime(over) - Convert.ToDateTime(start);
                        TimeSpan daynumber = Convert.ToDateTime(over) - Convert.ToDateTime(start);
                        double number = daynumber.TotalDays; 
                        dr["money"] = Convert.ToInt32(number) * dd;
                    }
                    else
                    {
                        dr["day"] = "";
                        dr["money"] = "";
                    }
					dt.Rows.Add(dr);
				}
				ds.Tables.Add(dt);
			}
			return ds;
		}

		/// <summary>
		/// 删除一条信息
		/// </summary>
		/// <param name="id"></param>
		public void DeleteLease(string id)
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			sqlhelp.RunSql("delete Lease where id = '" + id + "'");
		}

		/// <summary>
		/// 得到所有产品信息
		/// </summary>
		/// <returns></returns>
		public DataSet GetAllProduct()
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			return sqlhelp.GetDs(sqlcmd5);
		}

		/// <summary>
		/// 通过产品查询产品信息
		/// </summary>
		/// <returns>产品名字</returns>
		public SqlDataReader GetSingProduct(string name)
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			SqlDataReader reader = sqlhelp.GetSqlDataReader("select id,price from dbo.PRODUCT where name = '" + name + "'");
			return reader;
		}

		/// <summary>
		/// 添加定单数据
		/// </summary>
		/// <param name="cli_id">客户ID</param>
		/// <param name="pro_id">产品ID</param>
		/// <param name="no">定单号</param>
		/// <param name="status">状态</param>
		/// <param name="insert_date_time">插入时间</param>
		/// <param name="aount">购买数量</param>
		/// <param name="price">单价</param>
		/// <param name="bottle">应急瓶</param>
		/// <param name="cope_money">应负金额</param>
		public int AddOrdersInfo(int cli_id, int pro_id, string no, string status, DateTime insert_date_time, int aount, decimal price, string bottle)
		{
			string sqlcmd6 = "insert into orders(c_id,pro_id,no,status,insert_date_time,aount,price,bottle,cope_money) values(@c_id,@pro_id,@no,@status,@insert_date_time,@aount,@price,@bottle,@cope_money)";
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			using (SqlConnection sqlconn = new SqlConnection(DataBaseDrHelp.strConn))
			{
				try
				{
					sqlconn.Open();
					SqlCommand cmd = new SqlCommand(sqlcmd6, sqlconn);
					cmd.Parameters.Add("@c_id", SqlDbType.Int).Value = cli_id;
					cmd.Parameters.Add("@pro_id", SqlDbType.Int).Value = pro_id;
					cmd.Parameters.Add("no", SqlDbType.VarChar, 30).Value = no;
					cmd.Parameters.Add("@status", SqlDbType.VarChar, 30).Value = status;
					cmd.Parameters.Add("@insert_date_time", SqlDbType.DateTime).Value = insert_date_time;
					cmd.Parameters.Add("@aount", SqlDbType.Int).Value = aount;
					cmd.Parameters.Add("@price", SqlDbType.Decimal, 10).Value = price;
					cmd.Parameters.Add("@bottle", SqlDbType.VarChar, 10).Value = bottle;
					cmd.Parameters.Add("@cope_money", SqlDbType.Decimal, 10).Value = aount * price;
					int result = cmd.ExecuteNonQuery();
					return result;
				}
				catch (SqlException)
				{
					throw;
				}
			}
		}

		/// <summary>
		/// 定单管理总查询
		/// </summary>
		/// <returns></returns>
		public DataSet GetOrdersInfo()
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			DataSet ds = new DataSet();
			using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlcmd7))
			{
				DataTable dt = new DataTable("Orders");

				dt.Columns.Add(new DataColumn("o.id", Type.GetType("System.String")));//定单ID
				dt.Columns.Add(new DataColumn("o.no", Type.GetType("System.String")));//定单号
				dt.Columns.Add(new DataColumn("c.client_name", Type.GetType("System.String")));//客户姓名
				dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
				dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域 
				dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
				dt.Columns.Add(new DataColumn("p.name", Type.GetType("System.String")));//产品名字
				dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//产品单价
				dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//购买数量
				dt.Columns.Add(new DataColumn("o.cope_money", Type.GetType("System.String")));//应付金额
				dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//实付金额
				dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
				dt.Columns.Add(new DataColumn("o.payment_date_time", Type.GetType("System.String")));//付款时间
				//dt.Columns.Add(new DataColumn("o.status", Type.GetType("System.String")));//状态
				dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶人
				dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶人


				while (reader.Read())
				{
					DataRow dr = dt.NewRow();

					dr["o.id"] = reader[0];//定单ID
					dr["o.no"] = reader[1];//定单号
					dr["c.client_name"] = reader[2];//客户姓名
					dr["c.mobile"] = reader[3];//客户电话ca.name
					dr["ca.name"] = reader[4];//客户区域
					dr["c.address"] = reader[5];//客户地址
					dr["p.name"] = reader[6];//产品名字
					dr["o.price"] = reader[7];//产品单价
					dr["o.aount"] = reader[8];//购买数量
					dr["o.cope_money"] = reader[9];//应付金额
					dr["o.fact_money"] = reader[10];//实付金额
					dr["o.insert_date_time"] = reader[11];//下单时间
					dr["o.payment_date_time"] = reader[12];//付款时间
					//dr["o.status"] = reader[13];//状态
					dr["o.TACK_BOTTLEER"] = reader[13];//取瓶人
					dr["o.DELI_BOTTLEER"] = reader[14];//送瓶人

					dt.Rows.Add(dr);
				}
				ds.Tables.Add(dt);
			}
			return ds;
		}

		/// <summary>
		/// 删除１个定单
		/// </summary>
		public void DeleteOrder(string id)
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			string sqlstr = "delete orders where id ='" + id + "'";
			sqlhelp.RunSql(sqlstr);
		}


		/// <summary>
		/// 根据状态查询定单信息
		/// </summary>
		/// <param name="status"></param>
		/// <returns></returns>
		public DataSet GetOrdersInfo(string status)
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			DataSet ds = new DataSet();
			string sqlcmd8 = "select o.id,o.no,c.client_name,c.mobile,ca.name,c.address, p.name,o.price,o.aount,o.cope_money,o.fact_money,o.insert_date_time,o.payment_date_time,o.status  from orders o inner join  dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id  inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id  where o.status = '" + status + "' order by o.insert_date_time desc";
			using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlcmd8))
			{
				DataTable dt = new DataTable("Orders");

				dt.Columns.Add(new DataColumn("o.id", Type.GetType("System.String")));//定单ID
				dt.Columns.Add(new DataColumn("o.no", Type.GetType("System.String")));//定单号
				dt.Columns.Add(new DataColumn("c.client_name", Type.GetType("System.String")));//客户姓名
				dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
				dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域 
				dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
				dt.Columns.Add(new DataColumn("p.name", Type.GetType("System.String")));//产品名字
				dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//产品单价
				dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//购买数量
				dt.Columns.Add(new DataColumn("o.cope_money", Type.GetType("System.String")));//应付金额
				dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//实付金额
				dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
				dt.Columns.Add(new DataColumn("o.payment_date_time", Type.GetType("System.String")));//付款时间
				dt.Columns.Add(new DataColumn("o.status", Type.GetType("System.String")));//状态

				while (reader.Read())
				{
					DataRow dr = dt.NewRow();

					dr["o.id"] = reader[0];//定单ID
					dr["o.no"] = reader[1];//定单号
					dr["c.client_name"] = reader[2];//客户姓名
					dr["c.mobile"] = reader[3];//客户电话ca.name
					dr["ca.name"] = reader[4];//客户区域
					dr["c.address"] = reader[5];//客户地址
					dr["p.name"] = reader[6];//产品名字
					dr["o.price"] = reader[7];//产品单价
					dr["o.aount"] = reader[8];//购买数量
					dr["o.cope_money"] = reader[9];//应付金额
					dr["o.fact_money"] = reader[10];//实付金额
					dr["o.insert_date_time"] = reader[11];//下单时间
					dr["o.payment_date_time"] = reader[12];//付款时间
					dr["o.status"] = reader[13];//状态

					dt.Rows.Add(dr);
				}
				ds.Tables.Add(dt);
			}
			return ds;
		}

		/// <summary>
		/// 根据定单ＩＤ休息定单状态
		/// </summary>
		/// <param name="status"></param>
		/// <param name="id"></param>
		public void EiditOrder(string status, string id)
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			string sqlstr = "update orders set status ='" + status + "' where id = '" + id + "'";
			sqlhelp.RunSql(sqlstr);
		}


		/// <summary>
		/// 根据状态查询定单信息
		/// </summary>
		/// <param name="status"></param>
		/// <returns></returns>
		public DataSet GetOrdersInfo(string status1, string status2)
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			DataSet ds = new DataSet();
			string sqlcmd8 = "select o.id,o.no,c.client_name,c.mobile,ca.name,c.address, p.name,o.price,o.aount,o.cope_money,o.fact_money,o.insert_date_time,o.payment_date_time,o.status  from orders o inner join  dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id  inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id  where o.status in( '" + status1 + "','" + status2 + "') order by o.insert_date_time desc";
			using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlcmd8))
			{
				DataTable dt = new DataTable("Orders");

				dt.Columns.Add(new DataColumn("o.id", Type.GetType("System.String")));//定单ID
				dt.Columns.Add(new DataColumn("o.no", Type.GetType("System.String")));//定单号
				dt.Columns.Add(new DataColumn("c.client_name", Type.GetType("System.String")));//客户姓名
				dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
				dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域 
				dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
				dt.Columns.Add(new DataColumn("p.name", Type.GetType("System.String")));//产品名字
				dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//产品单价
				dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//购买数量
				dt.Columns.Add(new DataColumn("o.cope_money", Type.GetType("System.String")));//应付金额
				dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//实付金额
				dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
				dt.Columns.Add(new DataColumn("o.payment_date_time", Type.GetType("System.String")));//付款时间
				dt.Columns.Add(new DataColumn("o.status", Type.GetType("System.String")));//状态

				while (reader.Read())
				{
					DataRow dr = dt.NewRow();

					dr["o.id"] = reader[0];//定单ID
					dr["o.no"] = reader[1];//定单号
					dr["c.client_name"] = reader[2];//客户姓名
					dr["c.mobile"] = reader[3];//客户电话ca.name
					dr["ca.name"] = reader[4];//客户区域
					dr["c.address"] = reader[5];//客户地址
					dr["p.name"] = reader[6];//产品名字
					dr["o.price"] = reader[7];//产品单价
					dr["o.aount"] = reader[8];//购买数量
					dr["o.cope_money"] = reader[9];//应付金额
					dr["o.fact_money"] = reader[10];//实付金额
					dr["o.insert_date_time"] = reader[11];//下单时间
					dr["o.payment_date_time"] = reader[12];//付款时间
					dr["o.status"] = reader[13];//状态

					dt.Rows.Add(dr);
				}
				ds.Tables.Add(dt);
			}
			return ds;
		}

		/// <summary>
		/// 收款
		/// </summary>
		/// <param name="fact_money"></param>
		/// <param name="dt"></param>
		/// <param name="mome"></param>
		/// <param name="id"></param>
		public void UpdateOrder1(decimal fact_money, DateTime dt, string mome, string id)
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			string sqlstr = "update orders set fact_money ='" + fact_money + "' ,payment_date_time = '" + dt + "' ,mome ='" + mome + "' where id =  '" + id + "'";
			sqlhelp.RunSql(sqlstr);
		}

		/// <summary>
        /// 取瓶操作string sqlstr = "update orders set TACK_BOTTLEER='" + tack + "', TACK_NUMBER = " + tacknumber + " where id =  '" + id + "'";
		/// </summary>
		/// <param name="tack"></param>
		/// <param name="id"></param>
		public void UpdateOrder2(string tack, string id)
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			string sqlstr = "update orders set TACK_BOTTLEER='" + tack + "' where id =  '" + id + "'";
			sqlhelp.RunSql(sqlstr);
		}

		/// <summary>
		/// 送瓶操作
		/// </summary>
		/// <param name="delivery"></param>
		/// <param name="id"></param>
		public void UpdateOrder3(string delivery, string id)
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			string sqlstr = "update orders set DELI_BOTTLEER='" + delivery + "' where id =  '" + id + "'";
			sqlhelp.RunSql(sqlstr);
		}

        /// <summary>
        /// 欠瓶操作
        /// </summary>
        /// <param name="delivery"></param>
        /// <param name="id"></param>
        public void UpdateOrder4(int tacknumber, string id)
        {
            DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
            string sqlstr = "update orders set TACK_NUMBER = " + tacknumber + " where id =  '" + id + "'";
            sqlhelp.RunSql(sqlstr);
        }

		/// <summary>
		/// 得到定单的应付金额
		/// </summary>
		/// <param name="id"></param>
		/// <returns></returns>
		public string GerSingOrderInfo(string id)
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			string sqlstr = "select cope_money from orders where id = '" + id + "'";
			string cope_money = "select count(*) as ff from orders where insert_date_time between '2009-4-16' and '2009-4-18'";
			cope_money = sqlhelp.ExecuteScalar(sqlstr);
			return cope_money;
		}

		/// <summary>
		/// 定气统计
		/// </summary>
		/// <returns></returns>
		public int OrderNumber(DateTime day,DateTime month,DateTime startTime,DateTime overTime)
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			int number = 0;
			string sqlstr = "select count(aount) as ff from orders where insert_date_time between '" + DateTime.Now.ToShortDateString() + "' and dateadd(d,1,'" + DateTime.Now.ToShortDateString() + "') ";
			string sqlday = "select count(aount) as ff from orders where insert_date_time between '" + day.ToShortDateString() + "' and dateadd(d,1,'" + day.ToShortDateString() + "')";
			string sqlmonth = "select count(aount) as ff from orders where insert_date_time between '" + month.ToShortDateString() + "' and dateadd(m,1,'" + month.ToShortDateString() + "')";
			string sqlstrAndover = "select count(aount) as ff from orders where insert_date_time between '" + startTime.ToShortDateString() + "' and '" + overTime.ToShortDateString() + "'";

			if(day.ToShortDateString() != "1900-1-1" && month.ToShortDateString() =="1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1")
			{
				number = sqlhelp.RunSqlReturn(sqlday);
			}
			if(day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() != "1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1")
			{
				number = sqlhelp.RunSqlReturn(sqlmonth);
			}
			if(day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() == "1900-1-1" && startTime.ToShortDateString() != "1900-1-1" && overTime.ToShortDateString() != "1900-1-1")
			{
				number = sqlhelp.RunSqlReturn(sqlstrAndover);
			}
			if (day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() == "1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1")
			{
				number = sqlhelp.RunSqlReturn(sqlstr);
			}
			return number;
		}

		/// <summary>
		/// 送气统计
		/// </summary>
		/// <returns></returns>
		public int DeliveryOrder(DateTime day, DateTime month, DateTime startTime, DateTime overTime)
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			int number = 0;
			string sqlstr = "select count(aount) as ff from orders where DELI_BOTTLEER is not null and insert_date_time between '" + DateTime.Now.ToShortDateString() + "' and dateadd(d,1,'" + DateTime.Now.ToShortDateString() + "') ";
			string sqlday = "select count(aount) as ff from orders where DELI_BOTTLEER is not null and insert_date_time between '" + day.ToShortDateString() + "' and dateadd(d,1,'" + day.ToShortDateString() + "')";
			string sqlmonth = "select count(aount) as ff from orders where DELI_BOTTLEER is not null and insert_date_time between '" + month.ToShortDateString() + "' and dateadd(m,1,'" + month.ToShortDateString() + "')";
			string sqlstartAndovertime = "select count(aount) as ff from orders where DELI_BOTTLEER is not null and insert_date_time between '" + startTime.ToShortDateString() + "' and '" + overTime.ToShortDateString() + "'";
			if(day.ToShortDateString() != "1900-1-1" && month.ToShortDateString() =="1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1")
			{
				number = sqlhelp.RunSqlReturn(sqlday);
			}
			if(day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() != "1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1")
			{
				number = sqlhelp.RunSqlReturn(sqlmonth);
			}
			if(day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() == "1900-1-1" && startTime.ToShortDateString() != "1900-1-1" && overTime.ToShortDateString() != "1900-1-1")
			{
				number = sqlhelp.RunSqlReturn(sqlstartAndovertime);
			}
			if (day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() == "1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1")
			{
				number = sqlhelp.RunSqlReturn(sqlstr);
			}
			return number;
		}

		/// <summary>
		/// 收款统计
		/// </summary>
		/// <returns></returns>
		public int Gathering(DateTime day, DateTime month, DateTime startTime, DateTime overTime)
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			int number = 0;
			string sqlstr = "select sum(fact_money) as ff from orders where payment_date_time between '" + DateTime.Now.ToShortDateString() + "' and dateadd(d,1,'" + DateTime.Now.ToShortDateString() + "')";
			string sqlday = "select sum(fact_money) as ff from orders where payment_date_time between '" + day.ToShortDateString() + "' and dateadd(d,1,'" + day.ToShortDateString() + "')";
			string sqlmonth = "select sum(fact_money) as ff from orders where payment_date_time between '" + month.ToShortDateString() + "' and dateadd(m,1,'" + month.ToShortDateString() + "')";
			string sqlstartAndovertime = "select sum(fact_money) as ff from orders where payment_date_time between '" + startTime.ToShortDateString() + "' and '" + overTime.ToShortDateString() + "'";
			if (day.ToShortDateString() != "1900-1-1" && month.ToShortDateString() == "1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1")
			{
				number = sqlhelp.RunSqlReturn(sqlday);
			}
			if (day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() != "1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1")
			{
				number = sqlhelp.RunSqlReturn(sqlmonth);
			}
			if (day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() == "1900-1-1" && startTime.ToShortDateString() != "1900-1-1" && overTime.ToShortDateString() != "1900-1-1")
			{
				number = sqlhelp.RunSqlReturn(sqlstartAndovertime);
			}
			if (day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() == "1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1")
			{
				number = sqlhelp.RunSqlReturn(sqlstr);
			}
			return number;
		}

		/// <summary>
		/// 今日应收款
		/// </summary>
		/// <returns></returns>
		public int ToDayCopeMoney()
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			string sqlstr = "select sum(cope_money) from orders where payment_date_time between '" + DateTime.Now.ToShortDateString() + "' and dateadd(d,1,'" + DateTime.Now.ToShortDateString() + "')";
			return sqlhelp.RunSqlReturn(sqlstr);
		}

		/// <summary>
		/// 得到所有未打印取瓶单的定单
		/// </summary>
		/// <param name="status"></param>
		/// <returns></returns>
		public DataSet GetAllNotQuOrdersInfo()
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			DataSet ds = new DataSet();
			using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlcmd9))
			{
				DataTable dt = new DataTable("Orders");
				//o.id,ca.name,c.address,c.mobile,o.aount,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.price,o.fact_money,o.mome,o.insert_date_time
				dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域
				dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
				dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
				dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//数量
				dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶
				dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶
				dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//价格
				dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//收款
				dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
				dt.Columns.Add(new DataColumn("qian", Type.GetType("System.String")));//欠瓶
				dt.Columns.Add(new DataColumn("o.mome", Type.GetType("System.String")));//备注


				while (reader.Read())
				{
					DataRow dr = dt.NewRow();

					dr["ca.name"] = reader[0];//客户区域
					dr["c.address"] = reader[1];//客户地址
					dr["c.mobile"] = reader[2];//客户电话
					dr["o.aount"] = reader[3];//数量
					dr["o.TACK_BOTTLEER"] = reader[4];//取瓶
					dr["o.DELI_BOTTLEER"] = reader[5];//送瓶
					dr["o.price"] = reader[6];//价格
					dr["o.fact_money"] = reader[7];//实付金额
					dr["o.insert_date_time"] = reader[8];//下单时间
					if (reader[5].ToString() != "" && reader[4].ToString() == "")
					{
						dr["qian"] = "欠瓶";
					}
					else
					{
						dr["qian"] = "";
					}
					dr["o.mome"] = reader[9];//备注

					dt.Rows.Add(dr);
				}
				ds.Tables.Add(dt);
			}
			return ds;
		}

		/// <summary>
		/// 得到所有未打印取瓶单的定单（按区域查）
		/// </summary>
		/// <param name="status"></param>
		/// <returns></returns>
		public DataSet GetAllNotQuOrdersInfo(string area)
		{
			string sqlstr = "select ca.name,c.address,c.mobile,o.aount,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.price,o.fact_money,o.insert_date_time,o.mome from orders o inner join dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id where ca.name = '" + area + "' order by o.insert_date_time desc";
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			DataSet ds = new DataSet();
			using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlstr))
			{
				DataTable dt = new DataTable("Orders");
				//o.id,ca.name,c.address,c.mobile,o.aount,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.price,o.fact_money,o.mome,o.insert_date_time
				dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域
				dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
				dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
				dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//数量
				dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶
				dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶
				dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//价格
				dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//收款
				dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
				dt.Columns.Add(new DataColumn("qian", Type.GetType("System.String")));//欠瓶
				dt.Columns.Add(new DataColumn("o.mome", Type.GetType("System.String")));//备注


				while (reader.Read())
				{
					DataRow dr = dt.NewRow();

					dr["ca.name"] = reader[0];//客户区域
					dr["c.address"] = reader[1];//客户地址
					dr["c.mobile"] = reader[2];//客户电话
					dr["o.aount"] = reader[3];//数量
					dr["o.TACK_BOTTLEER"] = reader[4];//取瓶
					dr["o.DELI_BOTTLEER"] = reader[5];//送瓶
					dr["o.price"] = reader[6];//价格
					dr["o.fact_money"] = reader[7];//实付金额
					dr["o.insert_date_time"] = reader[8];//下单时间
					if (reader[5].ToString() != "" && reader[4].ToString() == "")
					{
						dr["qian"] = "欠瓶";
					}
					else
					{
						dr["qian"] = "";
					}
					dr["o.mome"] = reader[9];//备注

					dt.Rows.Add(dr);
				}
				ds.Tables.Add(dt);
			}
			return ds;
		}

		/// <summary>
		/// 得到所有未打印取瓶单的定单（按天查）
		/// </summary>
		/// <param name="status"></param>
		/// <returns></returns>
		public DataSet GetAllNotQuOrdersInfoByDay(DateTime datetime)
		{
			string sqlstr = "select ca.name,c.address,c.mobile,o.aount,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.price,o.fact_money,o.insert_date_time,o.mome from orders o inner join dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id where o.insert_date_time between '" + datetime.ToShortDateString() + "' and dateadd(d,1,'" + datetime.ToShortDateString() + "') order by o.insert_date_time desc";
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			DataSet ds = new DataSet();
			using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlstr))
			{
				DataTable dt = new DataTable("Orders");
				//o.id,ca.name,c.address,c.mobile,o.aount,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.price,o.fact_money,o.mome,o.insert_date_time
				dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域
				dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
				dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
				dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//数量
				dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶
				dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶
				dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//价格
				dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//收款
				dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
				dt.Columns.Add(new DataColumn("qian", Type.GetType("System.String")));//欠瓶
				dt.Columns.Add(new DataColumn("o.mome", Type.GetType("System.String")));//备注


				while (reader.Read())
				{
					DataRow dr = dt.NewRow();

					dr["ca.name"] = reader[0];//客户区域
					dr["c.address"] = reader[1];//客户地址
					dr["c.mobile"] = reader[2];//客户电话
					dr["o.aount"] = reader[3];//数量
					dr["o.TACK_BOTTLEER"] = reader[4];//取瓶
					dr["o.DELI_BOTTLEER"] = reader[5];//送瓶
					dr["o.price"] = reader[6];//价格
					dr["o.fact_money"] = reader[7];//实付金额
					dr["o.insert_date_time"] = reader[8];//下单时间
					if (reader[5].ToString() != "" && reader[4].ToString() == "")
					{
						dr["qian"] = "欠瓶";
					}
					else
					{
						dr["qian"] = "";
					}
					dr["o.mome"] = reader[9];//备注

					dt.Rows.Add(dr);
				}
				ds.Tables.Add(dt);
			}
			return ds;
		}

		/// <summary>
		/// 得到所有未打印取瓶单的定单（按月查）
		/// </summary>
		/// <param name="status"></param>
		/// <returns></returns>
		public DataSet GetAllNotQuOrdersInfoByMonth(DateTime datetime)
		{
			string sqlstr = "select ca.name,c.address,c.mobile,o.aount,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.price,o.fact_money,o.insert_date_time,o.mome from orders o inner join dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id where o.insert_date_time between '" + datetime.ToShortDateString() + "' and dateadd(m,1,'" + datetime.ToShortDateString() + "') order by o.insert_date_time desc";
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			DataSet ds = new DataSet();
			using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlstr))
			{
				DataTable dt = new DataTable("Orders");
				//o.id,ca.name,c.address,c.mobile,o.aount,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.price,o.fact_money,o.mome,o.insert_date_time
				dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域
				dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
				dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
				dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//数量
				dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶
				dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶
				dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//价格
				dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//收款
				dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
				dt.Columns.Add(new DataColumn("qian", Type.GetType("System.String")));//欠瓶
				dt.Columns.Add(new DataColumn("o.mome", Type.GetType("System.String")));//备注


				while (reader.Read())
				{
					DataRow dr = dt.NewRow();

					dr["ca.name"] = reader[0];//客户区域
					dr["c.address"] = reader[1];//客户地址
					dr["c.mobile"] = reader[2];//客户电话
					dr["o.aount"] = reader[3];//数量
					dr["o.TACK_BOTTLEER"] = reader[4];//取瓶
					dr["o.DELI_BOTTLEER"] = reader[5];//送瓶
					dr["o.price"] = reader[6];//价格
					dr["o.fact_money"] = reader[7];//实付金额
					dr["o.insert_date_time"] = reader[8];//下单时间
					if (reader[5].ToString() != "" && reader[4].ToString() == "")
					{
						dr["qian"] = "欠瓶";
					}
					else
					{
						dr["qian"] = "";
					}
					dr["o.mome"] = reader[9];//备注

					dt.Rows.Add(dr);
				}
				ds.Tables.Add(dt);
			}
			return ds;
		}

		/// <summary>
		/// 得到所有未打印取瓶单的定单（按范围查）
		/// </summary>
		/// <param name="status"></param>
		/// <returns></returns>
		public DataSet GetAllNotQuOrdersInfoByTimeArea(DateTime datetime, DateTime date)
		{
			string sqlstr = "select ca.name,c.address,c.mobile,o.aount,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.price,o.fact_money,o.insert_date_time,o.mome from orders o inner join dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id where o.insert_date_time between '" + datetime.ToShortDateString() + "' and '" + date.ToShortDateString() + "' order by o.insert_date_time desc";
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			DataSet ds = new DataSet();
			using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlstr))
			{
				DataTable dt = new DataTable("Orders");
				//o.id,ca.name,c.address,c.mobile,o.aount,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.price,o.fact_money,o.mome,o.insert_date_time
				dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域
				dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
				dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
				dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//数量
				dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶
				dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶
				dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//价格
				dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//收款
				dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
				dt.Columns.Add(new DataColumn("qian", Type.GetType("System.String")));//欠瓶
				dt.Columns.Add(new DataColumn("o.mome", Type.GetType("System.String")));//备注


				while (reader.Read())
				{
					DataRow dr = dt.NewRow();

					dr["ca.name"] = reader[0];//客户区域
					dr["c.address"] = reader[1];//客户地址
					dr["c.mobile"] = reader[2];//客户电话
					dr["o.aount"] = reader[3];//数量
					dr["o.TACK_BOTTLEER"] = reader[4];//取瓶
					dr["o.DELI_BOTTLEER"] = reader[5];//送瓶
					dr["o.price"] = reader[6];//价格
					dr["o.fact_money"] = reader[7];//实付金额
					dr["o.insert_date_time"] = reader[8];//下单时间
					if (reader[5].ToString() != "" && reader[4].ToString() == "")
					{
						dr["qian"] = "欠瓶";
					}
					else
					{
						dr["qian"] = "";
					}
					dr["o.mome"] = reader[9];//备注

					dt.Rows.Add(dr);
				}
				ds.Tables.Add(dt);
			}
			return ds;
		}
        
        /// <summary>
        /// 按各种条件查询日清单
        /// </summary>
        /// <param name="area">区域</param>
        /// <param name="day">天</param>
        /// <param name="month">月</param>
        /// <param name="startTime">开始时间</param>
        /// <param name="overTime">结束时间</param>
        /// <returns></returns>
        public DataSet GetAllNotQuOrdersInfo(string area,DateTime day, DateTime month, DateTime startTime, DateTime overTime)
        {
            DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
            DataSet ds = new DataSet();
            string sqlstr1 = "select ca.name,c.address,c.mobile,o.aount,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.price,o.fact_money,o.insert_date_time,o.mome,o.TACK_NUMBER from orders o inner join dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id where ca.name = '" + area + "' order by o.insert_date_time desc";
            string sqlstr2 = "select ca.name,c.address,c.mobile,o.aount,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.price,o.fact_money,o.insert_date_time,o.mome,o.TACK_NUMBER from orders o inner join dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id where o.insert_date_time between '" + day.ToShortDateString() + "' and dateadd(d,1,'" + day.ToShortDateString() + "') order by o.insert_date_time desc";
            string sqlstr3 = "select ca.name,c.address,c.mobile,o.aount,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.price,o.fact_money,o.insert_date_time,o.mome,o.TACK_NUMBER from orders o inner join dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id where o.insert_date_time between '" + month.ToShortDateString() + "' and dateadd(m,1,'" + month.ToShortDateString() + "') order by o.insert_date_time desc";
            string sqlstr4 = "select ca.name,c.address,c.mobile,o.aount,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.price,o.fact_money,o.insert_date_time,o.mome,o.TACK_NUMBER from orders o inner join dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id where o.insert_date_time between '" + startTime.ToShortDateString() + "' and '" + overTime.ToShortDateString() + "' order by o.insert_date_time desc";
            string sqlstr5 = "select ca.name,c.address,c.mobile,o.aount,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.price,o.fact_money,o.insert_date_time,o.mome,o.TACK_NUMBER from orders o inner join dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id  where o.insert_date_time between '" + DateTime.Now.ToShortDateString() + "' and dateadd(d,1,'" + DateTime.Now.ToShortDateString() + "') order by o.insert_date_time desc"; ;

            if (area != "" && day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() == "1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1")
            {
                using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlstr1))
                {
                    DataTable dt = new DataTable("Orders");
                    //o.id,ca.name,c.address,c.mobile,o.aount,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.price,o.fact_money,o.mome,o.insert_date_time
                    dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域
                    dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
                    dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
                    dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//数量
                    dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶
                    dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶
                    dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//价格
                    dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//收款
                    dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
                    dt.Columns.Add(new DataColumn("o.mome", Type.GetType("System.String")));//备注
                    dt.Columns.Add(new DataColumn("o.TACK_NUMBER", Type.GetType("System.String")));//欠瓶


                    while (reader.Read())
                    {
                        DataRow dr = dt.NewRow();

                        dr["ca.name"] = reader[0];//客户区域
                        dr["c.address"] = reader[1];//客户地址
                        dr["c.mobile"] = reader[2];//客户电话
                        dr["o.aount"] = reader[3];//数量
                        dr["o.TACK_BOTTLEER"] = reader[4];//取瓶
                        dr["o.DELI_BOTTLEER"] = reader[5];//送瓶
                        dr["o.price"] = reader[6];//价格
                        dr["o.fact_money"] = reader[7];//实付金额
                        dr["o.insert_date_time"] = reader[8];//下单时间
                        dr["o.mome"] = reader[9];//备注
                        dr["o.TACK_NUMBER"] = reader[10];//欠瓶

                        dt.Rows.Add(dr);
                    }
                    ds.Tables.Add(dt);
                }
            }
            if(area == "" && day.ToShortDateString() != "1900-1-1" && month.ToShortDateString() == "1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1")
            {
                using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlstr2))
                {
                    DataTable dt = new DataTable("Orders");
                    //o.id,ca.name,c.address,c.mobile,o.aount,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.price,o.fact_money,o.mome,o.insert_date_time
                    dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域
                    dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
                    dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
                    dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//数量
                    dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶
                    dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶
                    dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//价格
                    dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//收款
                    dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
                    dt.Columns.Add(new DataColumn("o.TACK_NUMBER", Type.GetType("System.String")));//欠瓶
                    dt.Columns.Add(new DataColumn("o.mome", Type.GetType("System.String")));//备注


                    while (reader.Read())
                    {
                        DataRow dr = dt.NewRow();

                        dr["ca.name"] = reader[0];//客户区域
                        dr["c.address"] = reader[1];//客户地址
                        dr["c.mobile"] = reader[2];//客户电话
                        dr["o.aount"] = reader[3];//数量
                        dr["o.TACK_BOTTLEER"] = reader[4];//取瓶
                        dr["o.DELI_BOTTLEER"] = reader[5];//送瓶
                        dr["o.price"] = reader[6];//价格
                        dr["o.fact_money"] = reader[7];//实付金额
                        dr["o.insert_date_time"] = reader[8];//下单时间
                        dr["o.mome"] = reader[9];//备注
                        dr["o.TACK_NUMBER"] = reader[10];//欠瓶


                        dt.Rows.Add(dr);
                    }
                    ds.Tables.Add(dt);
                }
            }
            if(area == "" && day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() != "1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1")
            {
                using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlstr3))
                {
                    DataTable dt = new DataTable("Orders");
                    //o.id,ca.name,c.address,c.mobile,o.aount,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.price,o.fact_money,o.mome,o.insert_date_time
                    dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域
                    dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
                    dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
                    dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//数量
                    dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶
                    dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶
                    dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//价格
                    dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//收款
                    dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
                    dt.Columns.Add(new DataColumn("o.mome", Type.GetType("System.String")));//备注
                    dt.Columns.Add(new DataColumn("o.TACK_NUMBER", Type.GetType("System.String")));//欠瓶


                    while (reader.Read())
                    {
                        DataRow dr = dt.NewRow();

                        dr["ca.name"] = reader[0];//客户区域
                        dr["c.address"] = reader[1];//客户地址
                        dr["c.mobile"] = reader[2];//客户电话
                        dr["o.aount"] = reader[3];//数量
                        dr["o.TACK_BOTTLEER"] = reader[4];//取瓶
                        dr["o.DELI_BOTTLEER"] = reader[5];//送瓶
                        dr["o.price"] = reader[6];//价格
                        dr["o.fact_money"] = reader[7];//实付金额
                        dr["o.insert_date_time"] = reader[8];//下单时间
                        dr["o.mome"] = reader[9];//备注
                        dr["o.TACK_NUMBER"] = reader[10];//欠瓶


                        dt.Rows.Add(dr);
                    }
                    ds.Tables.Add(dt);
                }
            }
            if(area == "" && day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() == "1900-1-1" && startTime.ToShortDateString() != "1900-1-1" && overTime.ToShortDateString() != "1900-1-1")
            {
                using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlstr4))
                {
                    DataTable dt = new DataTable("Orders");
                    //o.id,ca.name,c.address,c.mobile,o.aount,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.price,o.fact_money,o.mome,o.insert_date_time
                    dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域
                    dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
                    dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
                    dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//数量
                    dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶
                    dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶
                    dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//价格
                    dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//收款
                    dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
                    dt.Columns.Add(new DataColumn("o.mome", Type.GetType("System.String")));//备注
                    dt.Columns.Add(new DataColumn("o.TACK_NUMBER", Type.GetType("System.String")));//欠瓶


                    while (reader.Read())
                    {
                        DataRow dr = dt.NewRow();

                        dr["ca.name"] = reader[0];//客户区域
                        dr["c.address"] = reader[1];//客户地址
                        dr["c.mobile"] = reader[2];//客户电话
                        dr["o.aount"] = reader[3];//数量
                        dr["o.TACK_BOTTLEER"] = reader[4];//取瓶
                        dr["o.DELI_BOTTLEER"] = reader[5];//送瓶
                        dr["o.price"] = reader[6];//价格
                        dr["o.fact_money"] = reader[7];//实付金额
                        dr["o.insert_date_time"] = reader[8];//下单时间
                        dr["o.mome"] = reader[9];//备注
                        dr["o.TACK_NUMBER"] = reader[10];//欠瓶

                        dt.Rows.Add(dr);
                    }
                    ds.Tables.Add(dt);
                }
            }
            if (area == "" && day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() == "1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1")
            {
                using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlstr5))
                {
                    DataTable dt = new DataTable("Orders");
                    //o.id,ca.name,c.address,c.mobile,o.aount,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.price,o.fact_money,o.mome,o.insert_date_time
                    dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域
                    dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
                    dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
                    dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//数量
                    dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶
                    dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶
                    dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//价格
                    dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//收款
                    dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
                    dt.Columns.Add(new DataColumn("o.mome", Type.GetType("System.String")));//备注
                    dt.Columns.Add(new DataColumn("o.TACK_NUMBER", Type.GetType("System.String")));//欠瓶


                    while (reader.Read())
                    {
                        DataRow dr = dt.NewRow();

                        dr["ca.name"] = reader[0];//客户区域
                        dr["c.address"] = reader[1];//客户地址
                        dr["c.mobile"] = reader[2];//客户电话
                        dr["o.aount"] = reader[3];//数量
                        dr["o.TACK_BOTTLEER"] = reader[4];//取瓶
                        dr["o.DELI_BOTTLEER"] = reader[5];//送瓶
                        dr["o.price"] = reader[6];//价格
                        dr["o.fact_money"] = reader[7];//实付金额
                        dr["o.insert_date_time"] = reader[8];//下单时间
                        dr["o.mome"] = reader[9];//备注
                        dr["o.TACK_NUMBER"] = reader[10];//欠瓶

                        dt.Rows.Add(dr);
                    }
                    ds.Tables.Add(dt);
                }
            }
            return ds;
        }

		/// <summary>
		/// 得到所有的定单信息
		/// </summary>
		/// <returns></returns>
		public SqlDataReader GetAllOrdersInfo()
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlcmd7);
			return reader;
		}

		/// <summary>
		/// 按区域查询
		/// </summary>
		/// <returns></returns>
		public DataSet GetOrdersInfoByArea(string area)
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			DataSet ds = new DataSet();
			string sqlstr = "select o.id,o.no,c.client_name,c.mobile,ca.name,c.address,p.name,o.price,o.aount,o.cope_money,o.fact_money,o.insert_date_time,o.payment_date_time,o.TACK_BOTTLEER,o.DELI_BOTTLEER from orders o inner join dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id where ca.name = '" + area + "' order by o.insert_date_time desc";
			using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlstr))
			{
				DataTable dt = new DataTable("Orders");

				dt.Columns.Add(new DataColumn("o.id", Type.GetType("System.String")));//定单ID
				dt.Columns.Add(new DataColumn("o.no", Type.GetType("System.String")));//定单号
				dt.Columns.Add(new DataColumn("c.client_name", Type.GetType("System.String")));//客户姓名
				dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
				dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域 
				dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
				dt.Columns.Add(new DataColumn("p.name", Type.GetType("System.String")));//产品名字
				dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//产品单价
				dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//购买数量
				dt.Columns.Add(new DataColumn("o.cope_money", Type.GetType("System.String")));//应付金额
				dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//实付金额
				dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
				dt.Columns.Add(new DataColumn("o.payment_date_time", Type.GetType("System.String")));//付款时间
				//dt.Columns.Add(new DataColumn("o.status", Type.GetType("System.String")));//状态
				dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶人
				dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶人


				while (reader.Read())
				{
					DataRow dr = dt.NewRow();

					dr["o.id"] = reader[0];//定单ID
					dr["o.no"] = reader[1];//定单号
					dr["c.client_name"] = reader[2];//客户姓名
					dr["c.mobile"] = reader[3];//客户电话ca.name
					dr["ca.name"] = reader[4];//客户区域
					dr["c.address"] = reader[5];//客户地址
					dr["p.name"] = reader[6];//产品名字
					dr["o.price"] = reader[7];//产品单价
					dr["o.aount"] = reader[8];//购买数量
					dr["o.cope_money"] = reader[9];//应付金额
					dr["o.fact_money"] = reader[10];//实付金额
					dr["o.insert_date_time"] = reader[11];//下单时间
					dr["o.payment_date_time"] = reader[12];//付款时间
					//dr["o.status"] = reader[13];//状态
					dr["o.TACK_BOTTLEER"] = reader[13];//取瓶人
					dr["o.DELI_BOTTLEER"] = reader[14];//送瓶人

					dt.Rows.Add(dr);
				}
				ds.Tables.Add(dt);
			}
			return ds;
		}

		/// <summary>
		/// 按各种条件查询定单信息
		/// </summary>
		/// <param name="day">指定日</param>
		/// <param name="month">指定月</param>
		/// <param name="startTime">开始时间</param>
		/// <param name="overTime">结束时间</param>
		/// <param name="mobile">电话</param>
		/// <param name="area">区域</param>
		/// <param name="dayNumber">超时天数</param>
		/// <returns></returns>
        public DataSet GetOrdersInfo(DateTime day, DateTime month, DateTime startTime, DateTime overTime, string mobile, string area, int dayNumber, string address, bool notDelivery,bool NotMoney,bool qian_money,bool qian_bottle)
		{
			DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
			DataSet ds = new DataSet();
			//区域
            string sqlarea = "select o.id,o.no,c.client_name,c.mobile,ca.name,c.address,p.name,o.price,o.aount,o.cope_money,o.fact_money,o.insert_date_time,o.payment_date_time,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.MOME,o.BOTTLE,o.TACK_NUMBER from orders o inner join dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id where ca.name = '" + area + "' order by o.insert_date_time desc";
			//指定日
            string sqlday = "select o.id,o.no,c.client_name,c.mobile,ca.name,c.address,p.name,o.price,o.aount,o.cope_money,o.fact_money,o.insert_date_time,o.payment_date_time,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.MOME,o.BOTTLE,o.TACK_NUMBER from orders o inner join dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id where o.insert_date_time between '" + day + "' and dateadd(d,1,'" + day + "') order by o.insert_date_time desc";
			//指定月
            string sqlmonth = "select o.id,o.no,c.client_name,c.mobile,ca.name,c.address,p.name,o.price,o.aount,o.cope_money,o.fact_money,o.insert_date_time,o.payment_date_time,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.MOME,o.BOTTLE,o.TACK_NUMBER from orders o inner join dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id where o.insert_date_time between '" + month + "' and dateadd(m,1,'" + month + "') order by o.insert_date_time desc";
			//时间范围
            string sqlTimeArea = "select o.id,o.no,c.client_name,c.mobile,ca.name,c.address,p.name,o.price,o.aount,o.cope_money,o.fact_money,o.insert_date_time,o.payment_date_time,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.MOME,o.BOTTLE,o.TACK_NUMBER from orders o inner join dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id where o.insert_date_time between '" + startTime + "' and '" + overTime + "' order by o.insert_date_time desc";
			//电话
            string sqlmobile = "select o.id,o.no,c.client_name,c.mobile,ca.name,c.address,p.name,o.price,o.aount,o.cope_money,o.fact_money,o.insert_date_time,o.payment_date_time,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.MOME,o.BOTTLE,o.TACK_NUMBER from orders o inner join dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id where c.mobile = '" + mobile + "' order by o.insert_date_time desc";
			//超时查询
            string sqldayNumber = "select o.id,o.no,c.client_name,c.mobile,ca.name,c.address,p.name,o.price,o.aount,o.cope_money,o.fact_money,o.insert_date_time,o.payment_date_time,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.MOME,o.BOTTLE,o.TACK_NUMBER from orders o inner join dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id where ('" + DateTime.Now + "' - o.insert_date_time) > " + Convert.ToInt32(dayNumber) + " order by o.insert_date_time desc";
			//按时间查询
            string sqladdress = "select o.id,o.no,c.client_name,c.mobile,ca.name,c.address,p.name,o.price,o.aount,o.cope_money,o.fact_money,o.insert_date_time,o.payment_date_time,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.MOME,o.BOTTLE,o.TACK_NUMBER from orders o inner join dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id where c.address = '" + address + "' order by o.insert_date_time desc";
            //未送气查询
            string sqlNotDelivery = "select o.id,o.no,c.client_name,c.mobile,ca.name,c.address,p.name,o.price,o.aount,o.cope_money,o.fact_money,o.insert_date_time,o.payment_date_time,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.MOME,o.BOTTLE,o.TACK_NUMBER from orders o inner join dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id where o.DELI_BOTTLEER is null order by o.insert_date_time desc";
			//未付款
			string sqlNotMoney = "select o.id,o.no,c.client_name,c.mobile,ca.name,c.address,p.name,o.price,o.aount,o.cope_money,o.fact_money,o.insert_date_time,o.payment_date_time,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.MOME,o.BOTTLE,o.TACK_NUMBER from orders o inner join dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id where o.fact_money is null order by o.insert_date_time desc";
            //欠款
            string sqlqian_money = "select o.id,o.no,c.client_name,c.mobile,ca.name,c.address,p.name,o.price,o.aount,o.cope_money,o.fact_money,o.insert_date_time,o.payment_date_time,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.MOME,o.BOTTLE,o.TACK_NUMBER from orders o inner join dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id where o.fact_money =0.00 and TACK_BOTTLEER is not null and DELI_BOTTLEER is not null order by o.insert_date_time desc";
            //欠瓶
            string sqlqian_bottle = "select o.id,o.no,c.client_name,c.mobile,ca.name,c.address,p.name,o.price,o.aount,o.cope_money,o.fact_money,o.insert_date_time,o.payment_date_time,o.TACK_BOTTLEER,o.DELI_BOTTLEER,o.MOME,o.BOTTLE,o.TACK_NUMBER from orders o inner join dbo.CLIENT c on o.c_id = c.id inner join dbo.PRODUCT p on p.id = o.pro_id inner join dbo.CLIENT_AREA ca on ca.id = c.cli_id where o.TACK_NUMBER is not null and o.TACK_NUMBER <> '0' order by o.insert_date_time desc";

			//按区域查
            if (area != "" && day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() == "1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1" && mobile == "" && dayNumber == 0 && address == "" && notDelivery == false && NotMoney == false && qian_money == false && qian_bottle == false)
			{
				using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlarea))
				{
					DataTable dt = new DataTable("Orders");

					dt.Columns.Add(new DataColumn("o.id", Type.GetType("System.String")));//定单ID
					dt.Columns.Add(new DataColumn("o.no", Type.GetType("System.String")));//定单号
					dt.Columns.Add(new DataColumn("c.client_name", Type.GetType("System.String")));//客户姓名
					dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
					dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域 
					dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
					dt.Columns.Add(new DataColumn("p.name", Type.GetType("System.String")));//产品名字
					dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//产品单价
					dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//购买数量
					dt.Columns.Add(new DataColumn("o.cope_money", Type.GetType("System.String")));//应付金额
					dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//实付金额
					dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
					dt.Columns.Add(new DataColumn("o.payment_date_time", Type.GetType("System.String")));//付款时间
					//dt.Columns.Add(new DataColumn("o.status", Type.GetType("System.String")));//状态
					dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶人
					dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶人
                    dt.Columns.Add(new DataColumn("o.MOME", Type.GetType("System.String")));//备注
                    dt.Columns.Add(new DataColumn("o.BOTTLE", Type.GetType("System.String")));//应急
                    dt.Columns.Add(new DataColumn("o.TACK_NUMBER", Type.GetType("System.String")));//欠瓶


					while (reader.Read())
					{
						DataRow dr = dt.NewRow();

						dr["o.id"] = reader[0];//定单ID
						dr["o.no"] = reader[1];//定单号
						dr["c.client_name"] = reader[2];//客户姓名
						dr["c.mobile"] = reader[3];//客户电话ca.name
						dr["ca.name"] = reader[4];//客户区域
						dr["c.address"] = reader[5];//客户地址
						dr["p.name"] = reader[6];//产品名字
						dr["o.price"] = reader[7];//产品单价
						dr["o.aount"] = reader[8];//购买数量
						dr["o.cope_money"] = reader[9];//应付金额
						dr["o.fact_money"] = reader[10];//实付金额
						dr["o.insert_date_time"] = reader[11];//下单时间
						dr["o.payment_date_time"] = reader[12];//付款时间
						//dr["o.status"] = reader[13];//状态
						dr["o.TACK_BOTTLEER"] = reader[13];//取瓶人
						dr["o.DELI_BOTTLEER"] = reader[14];//送瓶人
                        dr["o.MOME"] = reader[15];
                        dr["o.BOTTLE"] = reader[16];
                        dr["o.TACK_NUMBER"] = reader[17];

						dt.Rows.Add(dr);
					}
					ds.Tables.Add(dt);
				}
			}

			//按天查询
            if (area == "" && day.ToShortDateString() != "1900-1-1" && month.ToShortDateString() == "1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1" && mobile == "" && dayNumber == 0 && address == "" && notDelivery == false && NotMoney == false && qian_money == false && qian_bottle == false)
			{
				using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlday))
				{
					DataTable dt = new DataTable("Orders");

					dt.Columns.Add(new DataColumn("o.id", Type.GetType("System.String")));//定单ID
					dt.Columns.Add(new DataColumn("o.no", Type.GetType("System.String")));//定单号
					dt.Columns.Add(new DataColumn("c.client_name", Type.GetType("System.String")));//客户姓名
					dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
					dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域 
					dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
					dt.Columns.Add(new DataColumn("p.name", Type.GetType("System.String")));//产品名字
					dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//产品单价
					dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//购买数量
					dt.Columns.Add(new DataColumn("o.cope_money", Type.GetType("System.String")));//应付金额
					dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//实付金额
					dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
					dt.Columns.Add(new DataColumn("o.payment_date_time", Type.GetType("System.String")));//付款时间
					//dt.Columns.Add(new DataColumn("o.status", Type.GetType("System.String")));//状态
					dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶人
					dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶人
                    dt.Columns.Add(new DataColumn("o.MOME", Type.GetType("System.String")));//备注
                    dt.Columns.Add(new DataColumn("o.BOTTLE", Type.GetType("System.String")));//应急
                    dt.Columns.Add(new DataColumn("o.TACK_NUMBER", Type.GetType("System.String")));//欠瓶


					while (reader.Read())
					{
						DataRow dr = dt.NewRow();

						dr["o.id"] = reader[0];//定单ID
						dr["o.no"] = reader[1];//定单号
						dr["c.client_name"] = reader[2];//客户姓名
						dr["c.mobile"] = reader[3];//客户电话ca.name
						dr["ca.name"] = reader[4];//客户区域
						dr["c.address"] = reader[5];//客户地址
						dr["p.name"] = reader[6];//产品名字
						dr["o.price"] = reader[7];//产品单价
						dr["o.aount"] = reader[8];//购买数量
						dr["o.cope_money"] = reader[9];//应付金额
						dr["o.fact_money"] = reader[10];//实付金额
						dr["o.insert_date_time"] = reader[11];//下单时间
						dr["o.payment_date_time"] = reader[12];//付款时间
						//dr["o.status"] = reader[13];//状态
						dr["o.TACK_BOTTLEER"] = reader[13];//取瓶人
						dr["o.DELI_BOTTLEER"] = reader[14];//送瓶人
                        dr["o.MOME"] = reader[15];
                        dr["o.BOTTLE"] = reader[16];
                        dr["o.TACK_NUMBER"] = reader[17];

						dt.Rows.Add(dr);
					}
					ds.Tables.Add(dt);
				}
			}

            //未送气查询
            if (area == "" && day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() == "1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1" && mobile == "" && dayNumber == 0 && address == "" && notDelivery != false && NotMoney == false && qian_money == false && qian_bottle == false)
            {
                using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlNotDelivery))
                {
                    DataTable dt = new DataTable("Orders");

                    dt.Columns.Add(new DataColumn("o.id", Type.GetType("System.String")));//定单ID
                    dt.Columns.Add(new DataColumn("o.no", Type.GetType("System.String")));//定单号
                    dt.Columns.Add(new DataColumn("c.client_name", Type.GetType("System.String")));//客户姓名
                    dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
                    dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域 
                    dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
                    dt.Columns.Add(new DataColumn("p.name", Type.GetType("System.String")));//产品名字
                    dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//产品单价
                    dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//购买数量
                    dt.Columns.Add(new DataColumn("o.cope_money", Type.GetType("System.String")));//应付金额
                    dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//实付金额
                    dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
                    dt.Columns.Add(new DataColumn("o.payment_date_time", Type.GetType("System.String")));//付款时间
                    //dt.Columns.Add(new DataColumn("o.status", Type.GetType("System.String")));//状态
                    dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶人
                    dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶人
                    dt.Columns.Add(new DataColumn("o.MOME", Type.GetType("System.String")));//备注
                    dt.Columns.Add(new DataColumn("o.BOTTLE", Type.GetType("System.String")));//应急
                    dt.Columns.Add(new DataColumn("o.TACK_NUMBER", Type.GetType("System.String")));//欠瓶


                    while (reader.Read())
                    {
                        DataRow dr = dt.NewRow();

                        dr["o.id"] = reader[0];//定单ID
                        dr["o.no"] = reader[1];//定单号
                        dr["c.client_name"] = reader[2];//客户姓名
                        dr["c.mobile"] = reader[3];//客户电话ca.name
                        dr["ca.name"] = reader[4];//客户区域
                        dr["c.address"] = reader[5];//客户地址
                        dr["p.name"] = reader[6];//产品名字
                        dr["o.price"] = reader[7];//产品单价
                        dr["o.aount"] = reader[8];//购买数量
                        dr["o.cope_money"] = reader[9];//应付金额
                        dr["o.fact_money"] = reader[10];//实付金额
                        dr["o.insert_date_time"] = reader[11];//下单时间
                        dr["o.payment_date_time"] = reader[12];//付款时间
                        //dr["o.status"] = reader[13];//状态
                        dr["o.TACK_BOTTLEER"] = reader[13];//取瓶人
                        dr["o.DELI_BOTTLEER"] = reader[14];//送瓶人
                        dr["o.MOME"] = reader[15];
                        dr["o.BOTTLE"] = reader[16];
                        dr["o.TACK_NUMBER"] = reader[17];

                        dt.Rows.Add(dr);
                    }
                    ds.Tables.Add(dt);
                }
            }


			//按月查询
            if (area == "" && day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() != "1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1" && mobile == "" && dayNumber == 0 && address == "" && notDelivery == false && NotMoney == false && qian_money == false && qian_bottle == false)
			{
				using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlmonth))
				{
					DataTable dt = new DataTable("Orders");

					dt.Columns.Add(new DataColumn("o.id", Type.GetType("System.String")));//定单ID
					dt.Columns.Add(new DataColumn("o.no", Type.GetType("System.String")));//定单号
					dt.Columns.Add(new DataColumn("c.client_name", Type.GetType("System.String")));//客户姓名
					dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
					dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域 
					dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
					dt.Columns.Add(new DataColumn("p.name", Type.GetType("System.String")));//产品名字
					dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//产品单价
					dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//购买数量
					dt.Columns.Add(new DataColumn("o.cope_money", Type.GetType("System.String")));//应付金额
					dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//实付金额
					dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
					dt.Columns.Add(new DataColumn("o.payment_date_time", Type.GetType("System.String")));//付款时间
					//dt.Columns.Add(new DataColumn("o.status", Type.GetType("System.String")));//状态
					dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶人
					dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶人
                    dt.Columns.Add(new DataColumn("o.MOME", Type.GetType("System.String")));//备注
                    dt.Columns.Add(new DataColumn("o.BOTTLE", Type.GetType("System.String")));//应急
                    dt.Columns.Add(new DataColumn("o.TACK_NUMBER", Type.GetType("System.String")));//欠瓶

					while (reader.Read())
					{
						DataRow dr = dt.NewRow();

						dr["o.id"] = reader[0];//定单ID
						dr["o.no"] = reader[1];//定单号
						dr["c.client_name"] = reader[2];//客户姓名
						dr["c.mobile"] = reader[3];//客户电话ca.name
						dr["ca.name"] = reader[4];//客户区域
						dr["c.address"] = reader[5];//客户地址
						dr["p.name"] = reader[6];//产品名字
						dr["o.price"] = reader[7];//产品单价
						dr["o.aount"] = reader[8];//购买数量
						dr["o.cope_money"] = reader[9];//应付金额
						dr["o.fact_money"] = reader[10];//实付金额
						dr["o.insert_date_time"] = reader[11];//下单时间
						dr["o.payment_date_time"] = reader[12];//付款时间
						//dr["o.status"] = reader[13];//状态
						dr["o.TACK_BOTTLEER"] = reader[13];//取瓶人
						dr["o.DELI_BOTTLEER"] = reader[14];//送瓶人
                        dr["o.MOME"] = reader[15];
                        dr["o.BOTTLE"] = reader[16];
                        dr["o.TACK_NUMBER"] = reader[17];

						dt.Rows.Add(dr);
					}
					ds.Tables.Add(dt);
				}
			}

			//按时间范围查询
            if (area == "" && day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() == "1900-1-1" && startTime.ToShortDateString() != "1900-1-1" && overTime.ToShortDateString() != "1900-1-1" && mobile == "" && dayNumber == 0 && address == "" && notDelivery == false && NotMoney == false && qian_money == false && qian_bottle == false)
			{
				using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlTimeArea))
				{
					DataTable dt = new DataTable("Orders");

					dt.Columns.Add(new DataColumn("o.id", Type.GetType("System.String")));//定单ID
					dt.Columns.Add(new DataColumn("o.no", Type.GetType("System.String")));//定单号
					dt.Columns.Add(new DataColumn("c.client_name", Type.GetType("System.String")));//客户姓名
					dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
					dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域 
					dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
					dt.Columns.Add(new DataColumn("p.name", Type.GetType("System.String")));//产品名字
					dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//产品单价
					dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//购买数量
					dt.Columns.Add(new DataColumn("o.cope_money", Type.GetType("System.String")));//应付金额
					dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//实付金额
					dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
					dt.Columns.Add(new DataColumn("o.payment_date_time", Type.GetType("System.String")));//付款时间
					//dt.Columns.Add(new DataColumn("o.status", Type.GetType("System.String")));//状态
					dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶人
					dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶人
                    dt.Columns.Add(new DataColumn("o.MOME", Type.GetType("System.String")));//备注
                    dt.Columns.Add(new DataColumn("o.BOTTLE", Type.GetType("System.String")));//应急
                    dt.Columns.Add(new DataColumn("o.TACK_NUMBER", Type.GetType("System.String")));//欠瓶


					while (reader.Read())
					{
						DataRow dr = dt.NewRow();

						dr["o.id"] = reader[0];//定单ID
						dr["o.no"] = reader[1];//定单号
						dr["c.client_name"] = reader[2];//客户姓名
						dr["c.mobile"] = reader[3];//客户电话ca.name
						dr["ca.name"] = reader[4];//客户区域
						dr["c.address"] = reader[5];//客户地址
						dr["p.name"] = reader[6];//产品名字
						dr["o.price"] = reader[7];//产品单价
						dr["o.aount"] = reader[8];//购买数量
						dr["o.cope_money"] = reader[9];//应付金额
						dr["o.fact_money"] = reader[10];//实付金额
						dr["o.insert_date_time"] = reader[11];//下单时间
						dr["o.payment_date_time"] = reader[12];//付款时间
						//dr["o.status"] = reader[13];//状态
						dr["o.TACK_BOTTLEER"] = reader[13];//取瓶人
						dr["o.DELI_BOTTLEER"] = reader[14];//送瓶人
                        dr["o.MOME"] = reader[15];
                        dr["o.BOTTLE"] = reader[16];
                        dr["o.TACK_NUMBER"] = reader[17];

						dt.Rows.Add(dr);
					}
					ds.Tables.Add(dt);
				}
			}

			//按电话查询查询
            if (area == "" && day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() == "1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1" && mobile != "" && dayNumber == 0 && address == "" && notDelivery == false && NotMoney == false && qian_money == false && qian_bottle == false)
			{
				using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlmobile))
				{
					DataTable dt = new DataTable("Orders");

					dt.Columns.Add(new DataColumn("o.id", Type.GetType("System.String")));//定单ID
					dt.Columns.Add(new DataColumn("o.no", Type.GetType("System.String")));//定单号
					dt.Columns.Add(new DataColumn("c.client_name", Type.GetType("System.String")));//客户姓名
					dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
					dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域 
					dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
					dt.Columns.Add(new DataColumn("p.name", Type.GetType("System.String")));//产品名字
					dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//产品单价
					dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//购买数量
					dt.Columns.Add(new DataColumn("o.cope_money", Type.GetType("System.String")));//应付金额
					dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//实付金额
					dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
					dt.Columns.Add(new DataColumn("o.payment_date_time", Type.GetType("System.String")));//付款时间
					//dt.Columns.Add(new DataColumn("o.status", Type.GetType("System.String")));//状态
					dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶人
					dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶人
                    dt.Columns.Add(new DataColumn("o.MOME", Type.GetType("System.String")));//备注
                    dt.Columns.Add(new DataColumn("o.BOTTLE", Type.GetType("System.String")));//应急
                    dt.Columns.Add(new DataColumn("o.TACK_NUMBER", Type.GetType("System.String")));//欠瓶

					while (reader.Read())
					{
						DataRow dr = dt.NewRow();

						dr["o.id"] = reader[0];//定单ID
						dr["o.no"] = reader[1];//定单号
						dr["c.client_name"] = reader[2];//客户姓名
						dr["c.mobile"] = reader[3];//客户电话ca.name
						dr["ca.name"] = reader[4];//客户区域
						dr["c.address"] = reader[5];//客户地址
						dr["p.name"] = reader[6];//产品名字
						dr["o.price"] = reader[7];//产品单价
						dr["o.aount"] = reader[8];//购买数量
						dr["o.cope_money"] = reader[9];//应付金额
						dr["o.fact_money"] = reader[10];//实付金额
						dr["o.insert_date_time"] = reader[11];//下单时间
						dr["o.payment_date_time"] = reader[12];//付款时间
						//dr["o.status"] = reader[13];//状态
						dr["o.TACK_BOTTLEER"] = reader[13];//取瓶人
						dr["o.DELI_BOTTLEER"] = reader[14];//送瓶人
                        dr["o.MOME"] = reader[15];
                        dr["o.BOTTLE"] = reader[16];
                        dr["o.TACK_NUMBER"] = reader[17];


						dt.Rows.Add(dr);
					}
					ds.Tables.Add(dt);
				}
			}


			//按地址查询
            if (area == "" && day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() == "1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1" && mobile == "" && dayNumber == 0 && address != "" && notDelivery == false && NotMoney == false && qian_money == false && qian_bottle == false)
			{
				using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqladdress))
				{
					DataTable dt = new DataTable("Orders");

					dt.Columns.Add(new DataColumn("o.id", Type.GetType("System.String")));//定单ID
					dt.Columns.Add(new DataColumn("o.no", Type.GetType("System.String")));//定单号
					dt.Columns.Add(new DataColumn("c.client_name", Type.GetType("System.String")));//客户姓名
					dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
					dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域 
					dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
					dt.Columns.Add(new DataColumn("p.name", Type.GetType("System.String")));//产品名字
					dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//产品单价
					dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//购买数量
					dt.Columns.Add(new DataColumn("o.cope_money", Type.GetType("System.String")));//应付金额
					dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//实付金额
					dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
					dt.Columns.Add(new DataColumn("o.payment_date_time", Type.GetType("System.String")));//付款时间
					//dt.Columns.Add(new DataColumn("o.status", Type.GetType("System.String")));//状态
					dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶人
					dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶人
					dt.Columns.Add(new DataColumn("o.MOME", Type.GetType("System.String")));//备注
					dt.Columns.Add(new DataColumn("o.BOTTLE", Type.GetType("System.String")));//应急
                    dt.Columns.Add(new DataColumn("o.TACK_NUMBER", Type.GetType("System.String")));//欠瓶

					while (reader.Read())
					{
						DataRow dr = dt.NewRow();

						dr["o.id"] = reader[0];//定单ID
						dr["o.no"] = reader[1];//定单号
						dr["c.client_name"] = reader[2];//客户姓名
						dr["c.mobile"] = reader[3];//客户电话ca.name
						dr["ca.name"] = reader[4];//客户区域
						dr["c.address"] = reader[5];//客户地址
						dr["p.name"] = reader[6];//产品名字
						dr["o.price"] = reader[7];//产品单价
						dr["o.aount"] = reader[8];//购买数量
						dr["o.cope_money"] = reader[9];//应付金额
						dr["o.fact_money"] = reader[10];//实付金额
						dr["o.insert_date_time"] = reader[11];//下单时间
						dr["o.payment_date_time"] = reader[12];//付款时间
						//dr["o.status"] = reader[13];//状态
						dr["o.TACK_BOTTLEER"] = reader[13];//取瓶人
						dr["o.DELI_BOTTLEER"] = reader[14];//送瓶人
						dr["o.MOME"] = reader[15];
						dr["o.BOTTLE"] = reader[16];
                        dr["o.TACK_NUMBER"] = reader[17];


						dt.Rows.Add(dr);
					}
					ds.Tables.Add(dt);
				}
			}


			//超时查询
            if (area == "" && day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() == "1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1" && mobile == "" && dayNumber != 0 && address == "" && notDelivery == false && NotMoney == false && qian_money == false && qian_bottle == false)
			{
				using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqldayNumber))
				{
					DataTable dt = new DataTable("Orders");

					dt.Columns.Add(new DataColumn("o.id", Type.GetType("System.String")));//定单ID
					dt.Columns.Add(new DataColumn("o.no", Type.GetType("System.String")));//定单号
					dt.Columns.Add(new DataColumn("c.client_name", Type.GetType("System.String")));//客户姓名
					dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
					dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域 
					dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
					dt.Columns.Add(new DataColumn("p.name", Type.GetType("System.String")));//产品名字
					dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//产品单价
					dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//购买数量
					dt.Columns.Add(new DataColumn("o.cope_money", Type.GetType("System.String")));//应付金额
					dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//实付金额
					dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
					dt.Columns.Add(new DataColumn("o.payment_date_time", Type.GetType("System.String")));//付款时间
					//dt.Columns.Add(new DataColumn("o.status", Type.GetType("System.String")));//状态
					dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶人
					dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶人
                    dt.Columns.Add(new DataColumn("o.MOME", Type.GetType("System.String")));//备注
                    dt.Columns.Add(new DataColumn("o.BOTTLE", Type.GetType("System.String")));//应急
                    dt.Columns.Add(new DataColumn("o.TACK_NUMBER", Type.GetType("System.String")));//欠瓶


					while (reader.Read())
					{
						DataRow dr = dt.NewRow();

						dr["o.id"] = reader[0];//定单ID
						dr["o.no"] = reader[1];//定单号
						dr["c.client_name"] = reader[2];//客户姓名
						dr["c.mobile"] = reader[3];//客户电话ca.name
						dr["ca.name"] = reader[4];//客户区域
						dr["c.address"] = reader[5];//客户地址
						dr["p.name"] = reader[6];//产品名字
						dr["o.price"] = reader[7];//产品单价
						dr["o.aount"] = reader[8];//购买数量
						dr["o.cope_money"] = reader[9];//应付金额
						dr["o.fact_money"] = reader[10];//实付金额
						dr["o.insert_date_time"] = reader[11];//下单时间
						dr["o.payment_date_time"] = reader[12];//付款时间
						//dr["o.status"] = reader[13];//状态
						dr["o.TACK_BOTTLEER"] = reader[13];//取瓶人
						dr["o.DELI_BOTTLEER"] = reader[14];//送瓶人
                        dr["o.MOME"] = reader[15];
                        dr["o.BOTTLE"] = reader[16];
                        dr["o.TACK_NUMBER"] = reader[17];

						dt.Rows.Add(dr);
					}
					ds.Tables.Add(dt);
				}
			}


			//未付款查询
            if (area == "" && day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() == "1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1" && mobile == "" && dayNumber == 0 && address == "" && notDelivery == false && NotMoney != false && qian_money == false && qian_bottle == false)
			{
				using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlNotMoney))
				{
					DataTable dt = new DataTable("Orders");

					dt.Columns.Add(new DataColumn("o.id", Type.GetType("System.String")));//定单ID
					dt.Columns.Add(new DataColumn("o.no", Type.GetType("System.String")));//定单号
					dt.Columns.Add(new DataColumn("c.client_name", Type.GetType("System.String")));//客户姓名
					dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
					dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域 
					dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
					dt.Columns.Add(new DataColumn("p.name", Type.GetType("System.String")));//产品名字
					dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//产品单价
					dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//购买数量
					dt.Columns.Add(new DataColumn("o.cope_money", Type.GetType("System.String")));//应付金额
					dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//实付金额
					dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
					dt.Columns.Add(new DataColumn("o.payment_date_time", Type.GetType("System.String")));//付款时间
					//dt.Columns.Add(new DataColumn("o.status", Type.GetType("System.String")));//状态
					dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶人
					dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶人
					dt.Columns.Add(new DataColumn("o.MOME", Type.GetType("System.String")));//备注
					dt.Columns.Add(new DataColumn("o.BOTTLE", Type.GetType("System.String")));//应急
					dt.Columns.Add(new DataColumn("o.TACK_NUMBER", Type.GetType("System.String")));//欠瓶


					while (reader.Read())
					{
						DataRow dr = dt.NewRow();

						dr["o.id"] = reader[0];//定单ID
						dr["o.no"] = reader[1];//定单号
						dr["c.client_name"] = reader[2];//客户姓名
						dr["c.mobile"] = reader[3];//客户电话ca.name
						dr["ca.name"] = reader[4];//客户区域
						dr["c.address"] = reader[5];//客户地址
						dr["p.name"] = reader[6];//产品名字
						dr["o.price"] = reader[7];//产品单价
						dr["o.aount"] = reader[8];//购买数量
						dr["o.cope_money"] = reader[9];//应付金额
						dr["o.fact_money"] = reader[10];//实付金额
						dr["o.insert_date_time"] = reader[11];//下单时间
						dr["o.payment_date_time"] = reader[12];//付款时间
						//dr["o.status"] = reader[13];//状态
						dr["o.TACK_BOTTLEER"] = reader[13];//取瓶人
						dr["o.DELI_BOTTLEER"] = reader[14];//送瓶人
						dr["o.MOME"] = reader[15];
						dr["o.BOTTLE"] = reader[16];
						dr["o.TACK_NUMBER"] = reader[17];

						dt.Rows.Add(dr);
					}
					ds.Tables.Add(dt);
				}
			}


            //欠款查询
            if (area == "" && day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() == "1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1" && mobile == "" && dayNumber == 0 && address == "" && notDelivery == false && NotMoney == false && qian_money != false && qian_bottle == false)
            {
                using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlqian_money))
                {
                    DataTable dt = new DataTable("Orders");

                    dt.Columns.Add(new DataColumn("o.id", Type.GetType("System.String")));//定单ID
                    dt.Columns.Add(new DataColumn("o.no", Type.GetType("System.String")));//定单号
                    dt.Columns.Add(new DataColumn("c.client_name", Type.GetType("System.String")));//客户姓名
                    dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
                    dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域 
                    dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
                    dt.Columns.Add(new DataColumn("p.name", Type.GetType("System.String")));//产品名字
                    dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//产品单价
                    dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//购买数量
                    dt.Columns.Add(new DataColumn("o.cope_money", Type.GetType("System.String")));//应付金额
                    dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//实付金额
                    dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
                    dt.Columns.Add(new DataColumn("o.payment_date_time", Type.GetType("System.String")));//付款时间
                    //dt.Columns.Add(new DataColumn("o.status", Type.GetType("System.String")));//状态
                    dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶人
                    dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶人
                    dt.Columns.Add(new DataColumn("o.MOME", Type.GetType("System.String")));//备注
                    dt.Columns.Add(new DataColumn("o.BOTTLE", Type.GetType("System.String")));//应急
                    dt.Columns.Add(new DataColumn("o.TACK_NUMBER", Type.GetType("System.String")));//欠瓶


                    while (reader.Read())
                    {
                        DataRow dr = dt.NewRow();

                        dr["o.id"] = reader[0];//定单ID
                        dr["o.no"] = reader[1];//定单号
                        dr["c.client_name"] = reader[2];//客户姓名
                        dr["c.mobile"] = reader[3];//客户电话ca.name
                        dr["ca.name"] = reader[4];//客户区域
                        dr["c.address"] = reader[5];//客户地址
                        dr["p.name"] = reader[6];//产品名字
                        dr["o.price"] = reader[7];//产品单价
                        dr["o.aount"] = reader[8];//购买数量
                        dr["o.cope_money"] = reader[9];//应付金额
                        dr["o.fact_money"] = reader[10];//实付金额
                        dr["o.insert_date_time"] = reader[11];//下单时间
                        dr["o.payment_date_time"] = reader[12];//付款时间
                        //dr["o.status"] = reader[13];//状态
                        dr["o.TACK_BOTTLEER"] = reader[13];//取瓶人
                        dr["o.DELI_BOTTLEER"] = reader[14];//送瓶人
                        dr["o.MOME"] = reader[15];
                        dr["o.BOTTLE"] = reader[16];
                        dr["o.TACK_NUMBER"] = reader[17];

                        dt.Rows.Add(dr);
                    }
                    ds.Tables.Add(dt);
                }
            }


            //欠瓶查询
            if (area == "" && day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() == "1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1" && mobile == "" && dayNumber == 0 && address == "" && notDelivery == false && NotMoney == false && qian_money == false && qian_bottle != false)
            {
                using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlqian_bottle))
                {
                    DataTable dt = new DataTable("Orders");

                    dt.Columns.Add(new DataColumn("o.id", Type.GetType("System.String")));//定单ID
                    dt.Columns.Add(new DataColumn("o.no", Type.GetType("System.String")));//定单号
                    dt.Columns.Add(new DataColumn("c.client_name", Type.GetType("System.String")));//客户姓名
                    dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
                    dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域 
                    dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
                    dt.Columns.Add(new DataColumn("p.name", Type.GetType("System.String")));//产品名字
                    dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//产品单价
                    dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//购买数量
                    dt.Columns.Add(new DataColumn("o.cope_money", Type.GetType("System.String")));//应付金额
                    dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//实付金额
                    dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
                    dt.Columns.Add(new DataColumn("o.payment_date_time", Type.GetType("System.String")));//付款时间
                    //dt.Columns.Add(new DataColumn("o.status", Type.GetType("System.String")));//状态
                    dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶人
                    dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶人
                    dt.Columns.Add(new DataColumn("o.MOME", Type.GetType("System.String")));//备注
                    dt.Columns.Add(new DataColumn("o.BOTTLE", Type.GetType("System.String")));//应急
                    dt.Columns.Add(new DataColumn("o.TACK_NUMBER", Type.GetType("System.String")));//欠瓶


                    while (reader.Read())
                    {
                        DataRow dr = dt.NewRow();

                        dr["o.id"] = reader[0];//定单ID
                        dr["o.no"] = reader[1];//定单号
                        dr["c.client_name"] = reader[2];//客户姓名
                        dr["c.mobile"] = reader[3];//客户电话ca.name
                        dr["ca.name"] = reader[4];//客户区域
                        dr["c.address"] = reader[5];//客户地址
                        dr["p.name"] = reader[6];//产品名字
                        dr["o.price"] = reader[7];//产品单价
                        dr["o.aount"] = reader[8];//购买数量
                        dr["o.cope_money"] = reader[9];//应付金额
                        dr["o.fact_money"] = reader[10];//实付金额
                        dr["o.insert_date_time"] = reader[11];//下单时间
                        dr["o.payment_date_time"] = reader[12];//付款时间
                        //dr["o.status"] = reader[13];//状态
                        dr["o.TACK_BOTTLEER"] = reader[13];//取瓶人
                        dr["o.DELI_BOTTLEER"] = reader[14];//送瓶人
                        dr["o.MOME"] = reader[15];
                        dr["o.BOTTLE"] = reader[16];
                        dr["o.TACK_NUMBER"] = reader[17];

                        dt.Rows.Add(dr);
                    }
                    ds.Tables.Add(dt);
                }
            }



			//默认查询
            if (area == "" && day.ToShortDateString() == "1900-1-1" && month.ToShortDateString() == "1900-1-1" && startTime.ToShortDateString() == "1900-1-1" && overTime.ToShortDateString() == "1900-1-1" && mobile == "" && dayNumber == 0 && address == "" && notDelivery == false && NotMoney == false && qian_money == false && qian_bottle == false)
			{
				using (SqlDataReader reader = sqlhelp.GetSqlDataReader(sqlcmd7))
				{
					DataTable dt = new DataTable("Orders");

					dt.Columns.Add(new DataColumn("o.id", Type.GetType("System.String")));//定单ID
					dt.Columns.Add(new DataColumn("o.no", Type.GetType("System.String")));//定单号
					dt.Columns.Add(new DataColumn("c.client_name", Type.GetType("System.String")));//客户姓名
					dt.Columns.Add(new DataColumn("c.mobile", Type.GetType("System.String")));//客户电话
					dt.Columns.Add(new DataColumn("ca.name", Type.GetType("System.String")));//客户区域 
					dt.Columns.Add(new DataColumn("c.address", Type.GetType("System.String")));//客户地址
					dt.Columns.Add(new DataColumn("p.name", Type.GetType("System.String")));//产品名字
					dt.Columns.Add(new DataColumn("o.price", Type.GetType("System.String")));//产品单价
					dt.Columns.Add(new DataColumn("o.aount", Type.GetType("System.String")));//购买数量
					dt.Columns.Add(new DataColumn("o.cope_money", Type.GetType("System.String")));//应付金额
					dt.Columns.Add(new DataColumn("o.fact_money", Type.GetType("System.String")));//实付金额
					dt.Columns.Add(new DataColumn("o.insert_date_time", Type.GetType("System.String")));//下单时间
					dt.Columns.Add(new DataColumn("o.payment_date_time", Type.GetType("System.String")));//付款时间
					//dt.Columns.Add(new DataColumn("o.status", Type.GetType("System.String")));//状态
					dt.Columns.Add(new DataColumn("o.TACK_BOTTLEER", Type.GetType("System.String")));//取瓶人
					dt.Columns.Add(new DataColumn("o.DELI_BOTTLEER", Type.GetType("System.String")));//送瓶人
                    dt.Columns.Add(new DataColumn("o.MOME", Type.GetType("System.String")));//备注
                    dt.Columns.Add(new DataColumn("o.BOTTLE", Type.GetType("System.String")));//应急
                    dt.Columns.Add(new DataColumn("o.TACK_NUMBER", Type.GetType("System.String")));//欠瓶


					while (reader.Read())
					{
						DataRow dr = dt.NewRow();

						dr["o.id"] = reader[0];//定单ID
						dr["o.no"] = reader[1];//定单号
						dr["c.client_name"] = reader[2];//客户姓名
						dr["c.mobile"] = reader[3];//客户电话ca.name
						dr["ca.name"] = reader[4];//客户区域
						dr["c.address"] = reader[5];//客户地址
						dr["p.name"] = reader[6];//产品名字
						dr["o.price"] = reader[7];//产品单价
						dr["o.aount"] = reader[8];//购买数量
						dr["o.cope_money"] = reader[9];//应付金额
						dr["o.fact_money"] = reader[10];//实付金额
						dr["o.insert_date_time"] = reader[11];//下单时间
						dr["o.payment_date_time"] = reader[12];//付款时间
						//dr["o.status"] = reader[13];//状态
						dr["o.TACK_BOTTLEER"] = reader[13];//取瓶人
						dr["o.DELI_BOTTLEER"] = reader[14];//送瓶人
                        dr["o.MOME"] = reader[15];
                        dr["o.BOTTLE"] = reader[16];
                        dr["o.TACK_NUMBER"] = reader[17];

						dt.Rows.Add(dr);
					}
					ds.Tables.Add(dt);
				}
			}
			return ds;
		}

        /// <summary>
        /// 根据ID删除一个客户
        /// </summary>
        /// <param name="id"></param>
        public void DeleteClient(string id)
        {
            DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
            string sqlstr = "delete CLIENT where id = '"+id+"'";
            sqlhelp.RunSql(sqlstr);
        }

        /// <summary>
        /// 得到客户信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public SqlDataReader GetClientInfo(string id)
        {
            string sqlstr = "select client_name,mobile,address,mome from CLIENT where id = '"+id+"'";
            DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
            return sqlhelp.GetSqlDataReader(sqlstr);
        }

        /// <summary>
        /// 修改客户信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public void UpdataClientInfo(string name,string mobile,string address,string mome,string id)
        {
            string sqlstr = "update CLIENT set CLIENT.CLIENT_NAME = '"+name+"',CLIENT.MOBILE='"+mobile+"',CLIENT.ADDRESS='"+address+"',CLIENT.MOME='"+mome+"' where CLIENT.Id = '"+id+"'";
            DataBaseDrHelp sqlhelp = new DataBaseDrHelp();
            sqlhelp.RunSql(sqlstr);
        }
	}
}
