/// <summary> /// 得到一个对象实体 /// </summary> public Client GetModel(int Cli_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Cli_ID,Cli_Code,Cli_zhiwen,Cli_Name,Cli_PicName,Cli_Phone,Cli_PhoneTwo,Cli_faxes,Cli_CityCode,Cli_TypeName,Cli_area,Cli_Address,Cli_LinkMan,Cli_Company,Cli_TypeCode,Cli_DiscountCode,Cli_Bankaccounts,Cli_OpenBank,Cli_Olddata,Cli_Oldreturn,Cli_Newoutdata,Cli_Newintodata,Cli_Createdata,Cli_Limit,Cli_RemainLimit,Cli_ClearLimitdate,Cli_ShouldMoney,Cli_GetMoney,Cli_PreMoney,Cli_Remark,Cli_safetone,Cli_safettwo,Cli_Enable from T_Client "); strSql.Append(" where Cli_ID=@Cli_ID"); SqlParameter[] parameters = { new SqlParameter("@Cli_ID", SqlDbType.Int, 4) }; parameters[0].Value = Cli_ID; Client model = new Client(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public yonghuModel GetModelByUsername(string username) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 nc_uid,nvc_username,nvc_pwd,int_right,dt_register from yonghu "); strSql.Append(" where nvc_username=@nvc_username "); SqlParameter[] parameters = { new SqlParameter("@nvc_username", SqlDbType.NVarChar, 50) }; parameters[0].Value = username; yonghuModel model = new yonghuModel(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Admin GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,UserName,PassWord,ReallyName,Birthday,Address,PostCode,Email,HomePhone,MobilePhone,QQ,ICQ,RegTime,Sex,IP,BlogID,SuperAdmin from Admin "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; Admin model = new Admin(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
public DataSet GetList(string strWhere, int CompleteCaseNum) { StringBuilder strSql = new StringBuilder(); strSql.Append("select "); if (CompleteCaseNum >= 0) { strSql.Append(" top ((select count(*) from V_TaskDetailSimple where TD_Status in ('Pending','InProgress')"); if (strWhere != "") { strSql.Append(" and "); strSql.Append(strWhere); } strSql.Append(string.Format(")+{0})", CompleteCaseNum)); } strSql.Append(" * from V_TaskDetailSimple where TD_IsDelete='0' "); if (strWhere != "") { strSql.Append(" and "); strSql.Append(strWhere); } strSql.Append(" Order by CHARINDEX(TD_Status,'Pending,InProgress,Complete'),TD_CardType DESC,TD_TimeEnd DESC"); return(DbHelperSQL.Query(strSql.ToString())); }
/// <summary> /// 得到一个对象实体 /// </summary> public tb_DeviceOUT GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,deviceId,amount,userId1,useFor,gDate,userId2,bDate,userId3,remark,createUser,createDate,updateUser,updateDate,temp1,temp2 from tb_DeviceOUT "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; tb_DeviceOUT model = new tb_DeviceOUT(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Material GetModel(int Ma_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Ma_ID,Ma_PicName,Ma_Name,Ma_Model,Ma_RFID,Ma_Barcode,Ma_Code,Ma_TypeID,Ma_TypeName,Ma_Price,Ma_PriceA,Ma_PriceB,Ma_PriceC,Ma_PriceD,Ma_PriceE,Ma_CreateDate,Ma_Supplier,Ma_SupID,Ma_zhujima,Ma_Unit,Ma_InPrice,Ma_OutPrice,Ma_InDate,Ma_Remark,Ma_Enable,Ma_Clear,Ma_Safeyone,Ma_Safetytwo from T_Material "); strSql.Append(" where Ma_ID=@Ma_ID"); SqlParameter[] parameters = { new SqlParameter("@Ma_ID", SqlDbType.Int, 4) }; parameters[0].Value = Ma_ID; Material model = new Material(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Href GetModel(int HrefID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 HrefID,Name,Url from Href "); strSql.Append(" where HrefID=@HrefID"); SqlParameter[] parameters = { new SqlParameter("@HrefID", SqlDbType.Int, 4) }; parameters[0].Value = HrefID; Href model = new Href(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public tb_DrugCheck GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,drugCode,drugName,drugId,drugInId,drugOutId,outDate,unit,amountIN,amountOUT,amount,riskLevel,checkDate,checkUser,checkUserId,auditstatus,auditUser,auditUserId,remark,isDelete,createUser,createDate,updateUser,updateDate from tb_DrugCheck "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; tb_DrugCheck model = new tb_DrugCheck(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.DeptType GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from Sys_DepartmentInfo "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; Model.DeptType model = new Model.DeptType(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.article_attribute_field GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,name,title,control_type,data_type,data_length,data_place,item_option,default_value,is_required,is_password,is_html,editor_type,valid_tip_msg,valid_error_msg,valid_pattern,sort_id,is_sys"); strSql.Append(" from " + databaseprefix + "article_attribute_field "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Model.article_attribute_field model = new Model.article_attribute_field(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } model.name = ds.Tables[0].Rows[0]["name"].ToString(); model.title = ds.Tables[0].Rows[0]["title"].ToString(); model.control_type = ds.Tables[0].Rows[0]["control_type"].ToString(); model.data_type = ds.Tables[0].Rows[0]["data_type"].ToString(); if (ds.Tables[0].Rows[0]["data_length"].ToString() != "") { model.data_length = int.Parse(ds.Tables[0].Rows[0]["data_length"].ToString()); } if (ds.Tables[0].Rows[0]["data_place"].ToString() != "") { model.data_place = int.Parse(ds.Tables[0].Rows[0]["data_place"].ToString()); } model.item_option = ds.Tables[0].Rows[0]["item_option"].ToString(); model.default_value = ds.Tables[0].Rows[0]["default_value"].ToString(); if (ds.Tables[0].Rows[0]["is_required"].ToString() != "") { model.is_required = int.Parse(ds.Tables[0].Rows[0]["is_required"].ToString()); } if (ds.Tables[0].Rows[0]["is_password"].ToString() != "") { model.is_password = int.Parse(ds.Tables[0].Rows[0]["is_password"].ToString()); } if (ds.Tables[0].Rows[0]["is_html"].ToString() != "") { model.is_html = int.Parse(ds.Tables[0].Rows[0]["is_html"].ToString()); } if (ds.Tables[0].Rows[0]["editor_type"].ToString() != "") { model.editor_type = int.Parse(ds.Tables[0].Rows[0]["editor_type"].ToString()); } model.valid_tip_msg = ds.Tables[0].Rows[0]["valid_tip_msg"].ToString(); model.valid_error_msg = ds.Tables[0].Rows[0]["valid_error_msg"].ToString(); model.valid_pattern = ds.Tables[0].Rows[0]["valid_pattern"].ToString(); if (ds.Tables[0].Rows[0]["sort_id"].ToString() != "") { model.sort_id = int.Parse(ds.Tables[0].Rows[0]["sort_id"].ToString()); } if (ds.Tables[0].Rows[0]["is_sys"].ToString() != "") { model.is_sys = int.Parse(ds.Tables[0].Rows[0]["is_sys"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 根据频道的名称查询ID /// </summary> public Model.channel GetModel(string channel_name) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,category_id,name,title,is_albums,is_attach,is_group_price,page_size,sort_id from " + databaseprefix + "channel "); strSql.Append(" where name=@name "); SqlParameter[] parameters = { new SqlParameter("@name", SqlDbType.VarChar, 250) }; parameters[0].Value = channel_name; Model.channel model = new Model.channel(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { #region 父表信息 if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["category_id"].ToString() != "") { model.category_id = int.Parse(ds.Tables[0].Rows[0]["category_id"].ToString()); } model.name = ds.Tables[0].Rows[0]["name"].ToString(); model.title = ds.Tables[0].Rows[0]["title"].ToString(); if (ds.Tables[0].Rows[0]["is_albums"].ToString() != "") { model.is_albums = int.Parse(ds.Tables[0].Rows[0]["is_albums"].ToString()); } if (ds.Tables[0].Rows[0]["is_attach"].ToString() != "") { model.is_attach = int.Parse(ds.Tables[0].Rows[0]["is_attach"].ToString()); } if (ds.Tables[0].Rows[0]["is_group_price"].ToString() != "") { model.is_group_price = int.Parse(ds.Tables[0].Rows[0]["is_group_price"].ToString()); } if (ds.Tables[0].Rows[0]["page_size"].ToString() != "") { model.page_size = int.Parse(ds.Tables[0].Rows[0]["page_size"].ToString()); } if (ds.Tables[0].Rows[0]["sort_id"].ToString() != "") { model.sort_id = int.Parse(ds.Tables[0].Rows[0]["sort_id"].ToString()); } #endregion 父表信息end #region 子表信息 StringBuilder strSql2 = new StringBuilder(); strSql2.Append("select id,channel_id,field_id from " + databaseprefix + "channel_field "); strSql2.Append(" where channel_id=@channel_id "); SqlParameter[] parameters2 = { new SqlParameter("@channel_id", SqlDbType.Int, 4) }; parameters2[0].Value = model.id; DataSet ds2 = DbHelperSQL.Query(strSql2.ToString(), parameters2); if (ds2.Tables[0].Rows.Count > 0) { int i = ds2.Tables[0].Rows.Count; List <Model.channel_field> models = new List <Model.channel_field>(); Model.channel_field modelt; for (int n = 0; n < i; n++) { modelt = new Model.channel_field(); if (ds2.Tables[0].Rows[n]["id"].ToString() != "") { modelt.id = int.Parse(ds2.Tables[0].Rows[n]["id"].ToString()); } if (ds2.Tables[0].Rows[n]["channel_id"].ToString() != "") { modelt.channel_id = int.Parse(ds2.Tables[0].Rows[n]["channel_id"].ToString()); } if (ds2.Tables[0].Rows[n]["field_id"].ToString() != "") { modelt.field_id = int.Parse(ds2.Tables[0].Rows[n]["field_id"].ToString()); } models.Add(modelt); } model.channel_fields = models; } #endregion 子表信息end return(model); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.Book GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,Title,Author,PublisherId,PublishDate,ISBN,WordsCount,UnitPrice,ContentDescription,AurhorDescription,EditorComment,TOC,CategoryId,Clicks from Books "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; Model.Book model = new Model.Book(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } model.Title = ds.Tables[0].Rows[0]["Title"].ToString(); model.Author = ds.Tables[0].Rows[0]["Author"].ToString(); if (ds.Tables[0].Rows[0]["PublisherId"].ToString() != "") { // model.PublisherId = int.Parse(ds.Tables[0].Rows[0]["PublisherId"].ToString()); int PublisherId = int.Parse(ds.Tables[0].Rows[0]["PublisherId"].ToString()); model.Publisher = publisherServices.GetModel(PublisherId); } if (ds.Tables[0].Rows[0]["PublishDate"].ToString() != "") { model.PublishDate = DateTime.Parse(ds.Tables[0].Rows[0]["PublishDate"].ToString()); } model.ISBN = ds.Tables[0].Rows[0]["ISBN"].ToString(); if (ds.Tables[0].Rows[0]["WordsCount"].ToString() != "") { model.WordsCount = int.Parse(ds.Tables[0].Rows[0]["WordsCount"].ToString()); } if (ds.Tables[0].Rows[0]["UnitPrice"].ToString() != "") { model.UnitPrice = decimal.Parse(ds.Tables[0].Rows[0]["UnitPrice"].ToString()); } model.ContentDescription = ds.Tables[0].Rows[0]["ContentDescription"].ToString(); model.AurhorDescription = ds.Tables[0].Rows[0]["AurhorDescription"].ToString(); model.EditorComment = ds.Tables[0].Rows[0]["EditorComment"].ToString(); model.TOC = ds.Tables[0].Rows[0]["TOC"].ToString(); if (ds.Tables[0].Rows[0]["CategoryId"].ToString() != "") { int CategoryId = int.Parse(ds.Tables[0].Rows[0]["CategoryId"].ToString()); model.Category = categoryServices.GetModel(CategoryId); } if (ds.Tables[0].Rows[0]["Clicks"].ToString() != "") { model.Clicks = int.Parse(ds.Tables[0].Rows[0]["Clicks"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.article_comment GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,channel_id,article_id,parent_id,user_id,user_name,user_ip,content,is_lock,add_time,is_reply,reply_content,reply_time"); strSql.Append(" from " + databaseprefix + "article_comment "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Model.article_comment model = new Model.article_comment(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["channel_id"].ToString() != "") { model.channel_id = int.Parse(ds.Tables[0].Rows[0]["channel_id"].ToString()); } if (ds.Tables[0].Rows[0]["article_id"].ToString() != "") { model.article_id = int.Parse(ds.Tables[0].Rows[0]["article_id"].ToString()); } if (ds.Tables[0].Rows[0]["parent_id"].ToString() != "") { model.parent_id = int.Parse(ds.Tables[0].Rows[0]["parent_id"].ToString()); } if (ds.Tables[0].Rows[0]["user_id"].ToString() != "") { model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString()); } model.user_name = ds.Tables[0].Rows[0]["user_name"].ToString(); model.user_ip = ds.Tables[0].Rows[0]["user_ip"].ToString(); model.content = ds.Tables[0].Rows[0]["content"].ToString(); if (ds.Tables[0].Rows[0]["is_lock"].ToString() != "") { model.is_lock = int.Parse(ds.Tables[0].Rows[0]["is_lock"].ToString()); } if (ds.Tables[0].Rows[0]["add_time"].ToString() != "") { model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString()); } if (ds.Tables[0].Rows[0]["is_reply"].ToString() != "") { model.is_reply = int.Parse(ds.Tables[0].Rows[0]["is_reply"].ToString()); } model.reply_content = ds.Tables[0].Rows[0]["reply_content"].ToString(); if (ds.Tables[0].Rows[0]["reply_time"].ToString() != "") { model.reply_time = DateTime.Parse(ds.Tables[0].Rows[0]["reply_time"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.users GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from " + databaseprefix + "users "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Model.users model = new Model.users(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["group_id"].ToString() != "") { model.group_id = int.Parse(ds.Tables[0].Rows[0]["group_id"].ToString()); } if (ds.Tables[0].Rows[0]["express_id"].ToString() != "") { model.express_id = int.Parse(ds.Tables[0].Rows[0]["express_id"].ToString()); } model.user_name = ds.Tables[0].Rows[0]["user_name"].ToString(); model.password = ds.Tables[0].Rows[0]["password"].ToString(); model.salt = ds.Tables[0].Rows[0]["salt"].ToString(); model.email = ds.Tables[0].Rows[0]["email"].ToString(); model.nick_name = ds.Tables[0].Rows[0]["nick_name"].ToString(); model.avatar = ds.Tables[0].Rows[0]["avatar"].ToString(); model.sex = ds.Tables[0].Rows[0]["sex"].ToString(); if (ds.Tables[0].Rows[0]["birthday"].ToString() != "") { model.birthday = DateTime.Parse(ds.Tables[0].Rows[0]["birthday"].ToString()); } model.telphone = ds.Tables[0].Rows[0]["telphone"].ToString(); model.mobile = ds.Tables[0].Rows[0]["mobile"].ToString(); model.qq = ds.Tables[0].Rows[0]["qq"].ToString(); model.address = ds.Tables[0].Rows[0]["address"].ToString(); model.safe_question = ds.Tables[0].Rows[0]["safe_question"].ToString(); model.safe_answer = ds.Tables[0].Rows[0]["safe_answer"].ToString(); if (ds.Tables[0].Rows[0]["amount"].ToString() != "") { model.amount = decimal.Parse(ds.Tables[0].Rows[0]["amount"].ToString()); } if (ds.Tables[0].Rows[0]["point"].ToString() != "") { model.point = int.Parse(ds.Tables[0].Rows[0]["point"].ToString()); } if (ds.Tables[0].Rows[0]["exp"].ToString() != "") { model.exp = int.Parse(ds.Tables[0].Rows[0]["exp"].ToString()); } if (ds.Tables[0].Rows[0]["status"].ToString() != "") { model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString()); } if (ds.Tables[0].Rows[0]["reg_time"].ToString() != "") { model.reg_time = DateTime.Parse(ds.Tables[0].Rows[0]["reg_time"].ToString()); } model.reg_ip = ds.Tables[0].Rows[0]["reg_ip"].ToString(); model.wechat = ds.Tables[0].Rows[0]["wechat"].ToString(); model.companyaddress = ds.Tables[0].Rows[0]["companyaddress"].ToString(); model.companyid = ds.Tables[0].Rows[0]["companyid"].ToString(); model.companyname = ds.Tables[0].Rows[0]["companyname"].ToString(); model.taxid = ds.Tables[0].Rows[0]["taxid"].ToString(); return(model); } else { return(null); } }