/// <summary> /// 得到一个对象实体 /// </summary> public KSOA.Model.Admin_KSCustomer DataRowToModel(DataRow row) { KSOA.Model.Admin_KSCustomer model=new KSOA.Model.Admin_KSCustomer(); if (row != null) { if(row["ID"]!=null && row["ID"].ToString()!="") { model.ID=int.Parse(row["ID"].ToString()); } if(row["RoleID"]!=null) { model.RoleID=row["RoleID"].ToString(); } if(row["RealName"]!=null) { model.RealName=row["RealName"].ToString(); } if(row["CusName"]!=null) { model.CusName=row["CusName"].ToString(); } if(row["Gender"]!=null) { model.Gender=row["Gender"].ToString(); } if(row["Age"]!=null && row["Age"].ToString()!="") { model.Age=int.Parse(row["Age"].ToString()); } if(row["CusPwd"]!=null) { model.CusPwd=row["CusPwd"].ToString(); } if(row["CusEmail"]!=null) { model.CusEmail=row["CusEmail"].ToString(); } if(row["CusPhoneNum"]!=null) { model.CusPhoneNum=row["CusPhoneNum"].ToString(); } if(row["QQ"]!=null) { model.QQ=row["QQ"].ToString(); } if(row["IsDelete"]!=null && row["IsDelete"].ToString()!="") { if((row["IsDelete"].ToString()=="1")||(row["IsDelete"].ToString().ToLower()=="true")) { model.IsDelete=true; } else { model.IsDelete=false; } } if(row["AddTime"]!=null && row["AddTime"].ToString()!="") { model.AddTime=DateTime.Parse(row["AddTime"].ToString()); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public KSOA.Model.Admin_KSCustomer GetModel(int ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 ID,RoleID,RealName,CusName,Gender,Age,CusPwd,CusEmail,CusPhoneNum,QQ,IsDelete,AddTime from Admin_KSCustomer "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int,4) }; parameters[0].Value = ID; KSOA.Model.Admin_KSCustomer model=new KSOA.Model.Admin_KSCustomer(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }