/// <summary> /// 增加一条数据 /// </summary> public bool Add(XHD.Model.hr_group_info model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into hr_group_info("); strSql.Append("Id,Group_Code,Group_Name,Group_CreatDate,Group_UserId,Gropu_Address)"); strSql.Append(" values ("); strSql.Append("@Id,@Group_Code,@Group_Name,@Group_CreatDate,@Group_UserId,@Gropu_Address)"); MySqlParameter[] parameters = { new MySqlParameter("@Id", MySqlDbType.Int32, 11), new MySqlParameter("@Group_Code", MySqlDbType.VarChar, 10), new MySqlParameter("@Group_Name", MySqlDbType.VarChar, 100), new MySqlParameter("@Group_CreatDate", MySqlDbType.DateTime), new MySqlParameter("@Group_UserId", MySqlDbType.VarChar, 10), new MySqlParameter("@Gropu_Address", MySqlDbType.VarChar, 100) }; parameters[0].Value = model.Id; parameters[1].Value = model.Group_Code; parameters[2].Value = model.Group_Name; parameters[3].Value = model.Group_CreatDate; parameters[4].Value = model.Group_UserId; parameters[5].Value = model.Gropu_Address; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public XHD.Model.hr_group_info DataRowToModel(DataRow row) { XHD.Model.hr_group_info model = new XHD.Model.hr_group_info(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["Group_Code"] != null) { model.Group_Code = row["Group_Code"].ToString(); } if (row["Group_Name"] != null) { model.Group_Name = row["Group_Name"].ToString(); } if (row["Group_CreatDate"] != null && row["Group_CreatDate"].ToString() != "") { model.Group_CreatDate = DateTime.Parse(row["Group_CreatDate"].ToString()); } if (row["Group_UserId"] != null) { model.Group_UserId = row["Group_UserId"].ToString(); } if (row["Gropu_Address"] != null) { model.Gropu_Address = row["Gropu_Address"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(XHD.Model.hr_group_info model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update hr_group_info set "); strSql.Append("Group_Code=@Group_Code,"); strSql.Append("Group_Name=@Group_Name,"); strSql.Append("Group_CreatDate=@Group_CreatDate,"); strSql.Append("Group_UserId=@Group_UserId,"); strSql.Append("Gropu_Address=@Gropu_Address"); strSql.Append(" where Id=@Id "); MySqlParameter[] parameters = { new MySqlParameter("@Group_Code", MySqlDbType.VarChar, 10), new MySqlParameter("@Group_Name", MySqlDbType.VarChar, 100), new MySqlParameter("@Group_CreatDate", MySqlDbType.DateTime), new MySqlParameter("@Group_UserId", MySqlDbType.VarChar, 10), new MySqlParameter("@Gropu_Address", MySqlDbType.VarChar, 100), new MySqlParameter("@Id", MySqlDbType.Int32, 11) }; parameters[0].Value = model.Group_Code; parameters[1].Value = model.Group_Name; parameters[2].Value = model.Group_CreatDate; parameters[3].Value = model.Group_UserId; parameters[4].Value = model.Gropu_Address; parameters[5].Value = model.Id; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public XHD.Model.hr_group_info GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id,Group_Code,Group_Name,Group_CreatDate,Group_UserId,Gropu_Address from hr_group_info "); strSql.Append(" where Id=@Id "); MySqlParameter[] parameters = { new MySqlParameter("@Id", MySqlDbType.Int32, 11) }; parameters[0].Value = Id; XHD.Model.hr_group_info model = new XHD.Model.hr_group_info(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }