/// <summary> /// 得到一个对象实体 /// </summary> public DataEntity.Model.Order GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 "); strSql.Append(" ID,CustID,ContractID,CustName,ContractName,WHF,WHNX,OrderDate,State,CustGM,CustLevel,CustCWS,Remark,eg1,eg2,eg3,eg4,eg5 "); strSql.Append(" from [Order] "); strSql.Append(" where ID=" + ID + ""); DataEntity.Model.Order model = new DataEntity.Model.Order(); DataSet ds = DbHelperSQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "") { model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } if (ds.Tables[0].Rows[0]["CustID"] != null && ds.Tables[0].Rows[0]["CustID"].ToString() != "") { model.CustID = int.Parse(ds.Tables[0].Rows[0]["CustID"].ToString()); } if (ds.Tables[0].Rows[0]["ContractID"] != null && ds.Tables[0].Rows[0]["ContractID"].ToString() != "") { model.ContractID = int.Parse(ds.Tables[0].Rows[0]["ContractID"].ToString()); } if (ds.Tables[0].Rows[0]["CustName"] != null && ds.Tables[0].Rows[0]["CustName"].ToString() != "") { model.CustName = ds.Tables[0].Rows[0]["CustName"].ToString(); } if (ds.Tables[0].Rows[0]["ContractName"] != null && ds.Tables[0].Rows[0]["ContractName"].ToString() != "") { model.ContractName = ds.Tables[0].Rows[0]["ContractName"].ToString(); } if (ds.Tables[0].Rows[0]["WHF"] != null && ds.Tables[0].Rows[0]["WHF"].ToString() != "") { model.WHF = decimal.Parse(ds.Tables[0].Rows[0]["WHF"].ToString()); } if (ds.Tables[0].Rows[0]["WHNX"] != null && ds.Tables[0].Rows[0]["WHNX"].ToString() != "") { model.WHNX = decimal.Parse(ds.Tables[0].Rows[0]["WHNX"].ToString()); } if (ds.Tables[0].Rows[0]["OrderDate"] != null && ds.Tables[0].Rows[0]["OrderDate"].ToString() != "") { model.OrderDate = DateTime.Parse(ds.Tables[0].Rows[0]["OrderDate"].ToString()); } if (ds.Tables[0].Rows[0]["State"] != null && ds.Tables[0].Rows[0]["State"].ToString() != "") { model.State = ds.Tables[0].Rows[0]["State"].ToString(); } if (ds.Tables[0].Rows[0]["CustGM"] != null && ds.Tables[0].Rows[0]["CustGM"].ToString() != "") { model.CustGM = ds.Tables[0].Rows[0]["CustGM"].ToString(); } if (ds.Tables[0].Rows[0]["CustLevel"] != null && ds.Tables[0].Rows[0]["CustLevel"].ToString() != "") { model.CustLevel = ds.Tables[0].Rows[0]["CustLevel"].ToString(); } if (ds.Tables[0].Rows[0]["CustCWS"] != null && ds.Tables[0].Rows[0]["CustCWS"].ToString() != "") { model.CustCWS = int.Parse(ds.Tables[0].Rows[0]["CustCWS"].ToString()); } if (ds.Tables[0].Rows[0]["Remark"] != null && ds.Tables[0].Rows[0]["Remark"].ToString() != "") { model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString(); } if (ds.Tables[0].Rows[0]["eg1"] != null && ds.Tables[0].Rows[0]["eg1"].ToString() != "") { model.eg1 = int.Parse(ds.Tables[0].Rows[0]["eg1"].ToString()); } if (ds.Tables[0].Rows[0]["eg2"] != null && ds.Tables[0].Rows[0]["eg2"].ToString() != "") { model.eg2 = int.Parse(ds.Tables[0].Rows[0]["eg2"].ToString()); } if (ds.Tables[0].Rows[0]["eg3"] != null && ds.Tables[0].Rows[0]["eg3"].ToString() != "") { model.eg3 = ds.Tables[0].Rows[0]["eg3"].ToString(); } if (ds.Tables[0].Rows[0]["eg4"] != null && ds.Tables[0].Rows[0]["eg4"].ToString() != "") { model.eg4 = ds.Tables[0].Rows[0]["eg4"].ToString(); } if (ds.Tables[0].Rows[0]["eg5"] != null && ds.Tables[0].Rows[0]["eg5"].ToString() != "") { model.eg5 = ds.Tables[0].Rows[0]["eg5"].ToString(); } return model; } else { return null; } }
/// <summary> /// 获得数据列表 /// </summary> public List<DataEntity.Model.Order> DataTableToList(DataTable dt) { List<DataEntity.Model.Order> modelList = new List<DataEntity.Model.Order>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { DataEntity.Model.Order model; for (int n = 0; n < rowsCount; n++) { model = new DataEntity.Model.Order(); if(dt.Rows[n]["ID"]!=null && dt.Rows[n]["ID"].ToString()!="") { model.ID=int.Parse(dt.Rows[n]["ID"].ToString()); } if(dt.Rows[n]["CustID"]!=null && dt.Rows[n]["CustID"].ToString()!="") { model.CustID=int.Parse(dt.Rows[n]["CustID"].ToString()); } if(dt.Rows[n]["ContractID"]!=null && dt.Rows[n]["ContractID"].ToString()!="") { model.ContractID=int.Parse(dt.Rows[n]["ContractID"].ToString()); } if(dt.Rows[n]["CustName"]!=null && dt.Rows[n]["CustName"].ToString()!="") { model.CustName=dt.Rows[n]["CustName"].ToString(); } if(dt.Rows[n]["ContractName"]!=null && dt.Rows[n]["ContractName"].ToString()!="") { model.ContractName=dt.Rows[n]["ContractName"].ToString(); } if(dt.Rows[n]["WHF"]!=null && dt.Rows[n]["WHF"].ToString()!="") { model.WHF=decimal.Parse(dt.Rows[n]["WHF"].ToString()); } if(dt.Rows[n]["WHNX"]!=null && dt.Rows[n]["WHNX"].ToString()!="") { model.WHNX=decimal.Parse(dt.Rows[n]["WHNX"].ToString()); } if(dt.Rows[n]["OrderDate"]!=null && dt.Rows[n]["OrderDate"].ToString()!="") { model.OrderDate=DateTime.Parse(dt.Rows[n]["OrderDate"].ToString()); } if(dt.Rows[n]["State"]!=null && dt.Rows[n]["State"].ToString()!="") { model.State=dt.Rows[n]["State"].ToString(); } if(dt.Rows[n]["CustGM"]!=null && dt.Rows[n]["CustGM"].ToString()!="") { model.CustGM=dt.Rows[n]["CustGM"].ToString(); } if(dt.Rows[n]["CustLevel"]!=null && dt.Rows[n]["CustLevel"].ToString()!="") { model.CustLevel=dt.Rows[n]["CustLevel"].ToString(); } if(dt.Rows[n]["CustCWS"]!=null && dt.Rows[n]["CustCWS"].ToString()!="") { model.CustCWS=int.Parse(dt.Rows[n]["CustCWS"].ToString()); } if(dt.Rows[n]["Remark"]!=null && dt.Rows[n]["Remark"].ToString()!="") { model.Remark=dt.Rows[n]["Remark"].ToString(); } if(dt.Rows[n]["eg1"]!=null && dt.Rows[n]["eg1"].ToString()!="") { model.eg1=int.Parse(dt.Rows[n]["eg1"].ToString()); } if(dt.Rows[n]["eg2"]!=null && dt.Rows[n]["eg2"].ToString()!="") { model.eg2=int.Parse(dt.Rows[n]["eg2"].ToString()); } if(dt.Rows[n]["eg3"]!=null && dt.Rows[n]["eg3"].ToString()!="") { model.eg3=dt.Rows[n]["eg3"].ToString(); } if(dt.Rows[n]["eg4"]!=null && dt.Rows[n]["eg4"].ToString()!="") { model.eg4=dt.Rows[n]["eg4"].ToString(); } if(dt.Rows[n]["eg5"]!=null && dt.Rows[n]["eg5"].ToString()!="") { model.eg5=dt.Rows[n]["eg5"].ToString(); } modelList.Add(model); } } return modelList; }