//李兰兰专用,不能删 private DisNoteTB GetAllDisNoteTBBySql1(string strsql) { //填充数据集 DataTable dt = DBHelper.GetTable(strsql); DisNoteTB DNte = new DisNoteTB(); //遍历数组 foreach (DataRow row in dt.Rows) { DNte.Nid = Convert.ToInt32(row["Nid"]); DNte.CusID = Convert.ToInt32(row["CusID"]); DNte.Cid = Convert.ToInt32(row["Cid"]); DNte.BeginNo = (long)row["BeginNo"]; DNte.EndNo = (long)row["EndNo"]; DNte.Dtime = Convert.ToDateTime(row["Dtime"]); DNte.Sum = Convert.ToDouble(row["Sum"]); object obj = row["IsSet"]; int cnt = Convert.ToInt32(obj); string isSets = ""; if (cnt == 0) { isSets = "否"; } if (cnt == 1) { isSets = "是"; } DNte.IsSet = isSets; DNte.Remark = row["Remark"].ToString(); DNte.CarrieCompany = CCom.GetCompanyByid(Convert.ToInt32(row["Cid"])); DNte.Customer = Cums.GetCusmoerByid(Convert.ToInt32(row["CusID"])); } return(DNte); }
//遍历数组,拿出数据 private static List <SentTB> GetSentTBBySql(string strsql) { CustomersService cs = new CustomersService(); CarrieCompanyService ccs = new CarrieCompanyService(); List <SentTB> list = new List <SentTB>(); DataTable table = DBHelper.GetTable(strsql); foreach (DataRow row in table.Rows) { SentTB st = new SentTB(); st.Sid = Convert.ToInt32(row["sid"]); st.CusID = Convert.ToInt32(row["cusid"]); st.Cid = Convert.ToInt32(row["cid"]); st.CSid = Convert.ToInt64(row["csid"]); st.Kilo = Convert.ToDouble(row["kilo"]); st.Price = Convert.ToDouble(row["price"]); st.BeginDate = Convert.ToDateTime(row["begindate"]); st.Remark = row["remark"].ToString(); st.cust = cs.GetCusmoerByid(Convert.ToInt32(row["cusid"])); st.company = ccs.GetCompanyByid(Convert.ToInt32(row["cid"])); list.Add(st); } return(list); }
//自定义方法 private List <RegisterTB> GetAllRegisterTBBySql(string strsql) { //实例化范集合 List <RegisterTB> allRegisterTB = new List <RegisterTB>(); //填充数据集 DataTable dt = DBHelper.GetTable(strsql); //遍历集合 foreach (DataRow row in dt.Rows) { //实例化类 RegisterTB reg = new RegisterTB(); reg.Rid = Convert.ToInt32(row["Rid"]); reg.Cid = Convert.ToInt32(row["Cid"]); reg.BeginNo = (long)row["BeginNo"]; reg.EndNo = (long)row["EndNo"]; reg.Buydate = Convert.ToDateTime(row["BuyDate"]); reg.Remark = (row["Remark"] == DBNull.Value) ? "" : row["Remark"].ToString(); reg.CCompany = CCom.GetCompanyByid(Convert.ToInt32(row["Cid"])); allRegisterTB.Add(reg); } return(allRegisterTB); }
//根据sql语句得到信息 public static List <CustomerSentTB> GetAllBySql(string strsql) { CustomersService cst = new CustomersService(); CarrieCompanyService ccs = new CarrieCompanyService(); List <CustomerSentTB> all = new List <CustomerSentTB>(); DataTable ds = DBHelper.GetTable(strsql); foreach (DataRow row in ds.Rows) { CustomerSentTB cs = new CustomerSentTB(); cs.CSid = Convert.ToInt32(row["csid"]); cs.Rid = (long)row["rid"]; //cs.cusid = Convert.ToInt32(row["cusid"]); cs.cusid = row["cusid"] != DBNull.Value ? Convert.ToInt32(row["cusid"]) : 0; //cs.Cid = Convert.ToInt32(row["cid"]); cs.Cid = row["cid"] != DBNull.Value ? Convert.ToInt32(row["cid"]) : 0; if (cs.cusid != 0) { cs.customer = cst.GetCusmoerByid(Convert.ToInt32(row["cusid"])); cs.carriecompany = ccs.GetCompanyByid(Convert.ToInt32(row["cid"])); } cs.Destination = row["destination"].ToString(); cs.Kilo = Convert.ToDouble(row["kilo"]); cs.Price = Convert.ToDouble(row["price"]); cs.Resdate = Convert.ToDateTime(row["resdate"]); cs.IsSet = (row["isset"].ToString()); if (cs.IsSet == "true") { cs.IsSet = "是"; } else { cs.IsSet = "否"; } cs.Remark = row["remark"].ToString(); all.Add(cs); } return(all); }
//根据sql语句查询 private static List <CustomerPriceTB> GetCustomersBySql(string strsql) { CustomersService cs = new CustomersService(); CarrieCompanyService ccs = new CarrieCompanyService(); List <CustomerPriceTB> list = new List <CustomerPriceTB>(); DataTable table = DBHelper.GetTable(strsql); foreach (DataRow row in table.Rows) { CustomerPriceTB cp = new CustomerPriceTB(); cp.Cpid = Convert.ToInt32(row["cpid"]); cp.carriecomapny = ccs.GetCompanyByid(Convert.ToInt32(row["cid"])); cp.customer = cs.GetCusmoerByid(Convert.ToInt32(row["cusid"])); cp.CusID = Convert.ToInt32(row["cusid"]); cp.Cid = Convert.ToInt32(row["cid"]); cp.CpName = row["cpname"].ToString(); cp.PNo = row["pno"].ToString(); cp.Remark = row["remark"].ToString(); list.Add(cp); } return(list); }