public List <SysOrgProvinceModel> DataTableToList(DataTable dt) { List <SysOrgProvinceModel> list = new List <SysOrgProvinceModel>(); int count = dt.Rows.Count; if (count > 0) { for (int i = 0; i < count; i++) { SysOrgProvinceModel item = this.dal.DataRowToModel(dt.Rows[i]); if (item != null) { list.Add(item); } } } return(list); }
public SysOrgProvinceModel DataRowToModel(DataRow row) { SysOrgProvinceModel sysOrgProvinceModel = new SysOrgProvinceModel(); if (row != null) { sysOrgProvinceModel.ID = int.Parse(row["ID"].ToString()); if ((row["Code"] != null) && (row["Code"] != DBNull.Value)) { sysOrgProvinceModel.Code = row["Code"].ToString(); } if ((row["Name"] != null) && (row["Name"] != DBNull.Value)) { sysOrgProvinceModel.Name = row["Name"].ToString(); } } return(sysOrgProvinceModel); }
public bool Add(SysOrgProvinceModel model) { StringBuilder builder = new StringBuilder(); builder.Append("insert into SYS_ORG_PROVINCE("); builder.Append("ID,Code,Name)"); builder.Append(" values ("); builder.Append("@ID,@Code,@Name)"); MySqlParameter[] cmdParms = new MySqlParameter[] { new MySqlParameter("@ID", MySqlDbType.Int32, 4), new MySqlParameter("@Code", MySqlDbType.String), new MySqlParameter("@Name", MySqlDbType.String) }; cmdParms[0].Value = model.ID; cmdParms[1].Value = model.Code; cmdParms[2].Value = model.Name; return(MySQLHelper.ExecuteSql(builder.ToString(), cmdParms) > 0); }
public bool Update(SysOrgProvinceModel model) { StringBuilder builder = new StringBuilder(); builder.Append("update SYS_ORG_PROVINCE set "); builder.Append("ID=@ID,"); builder.Append("Code=@Code,"); builder.Append("Name=@Name"); builder.Append(" where "); MySqlParameter[] cmdParms = new MySqlParameter[] { new MySqlParameter("@ID", MySqlDbType.Int32, 4), new MySqlParameter("@Code", MySqlDbType.String), new MySqlParameter("@Name", MySqlDbType.String) }; cmdParms[0].Value = model.ID; cmdParms[1].Value = model.Code; cmdParms[2].Value = model.Name; return(MySQLHelper.ExecuteSql(builder.ToString(), cmdParms) > 0); }
public bool Update(SysOrgProvinceModel model) { return(this.dal.Update(model)); }
public bool Add(SysOrgProvinceModel model) { return(this.dal.Add(model)); }