public DataTable GetAllName(AIOSubInfoType subInfoType) { string table = AIOConstant.GetTableName(subInfoType); string column = AIOConstant.GetColumnName(subInfoType); string sql = "SELECT * FROM " + table + " ORDER BY " + column + " ASC"; return(ExecuteSelect(sql)); }
public void UpdateName(string ID, string name, AIOSubInfoType subInfoType) { string table = AIOConstant.GetTableName(subInfoType); string column = AIOConstant.GetColumnName(subInfoType); string sql = "UPDATE " + table + " SET " + column + " = ? WHERE ID = ?"; OleDbCommand cmd = CreateSqlWithParam(sql, new string[] { name, ID }); ExecuteCommand(cmd); }
public void InsertName(string name, AIOSubInfoType subInfoType) { string table = AIOConstant.GetTableName(subInfoType); string id = GenerateSubInfoID(subInfoType); string sql = "INSERT INTO " + table + " VALUES(?, ?)"; OleDbCommand cmd = CreateSqlWithParam(sql, new string[] { id, name }); ExecuteCommand(cmd); }
public void DeleteName(string ID, AIOSubInfoType subInfoType) { string table = AIOConstant.GetTableName(subInfoType); string sql = "DELETE FROM " + table + " WHERE ID = '" + ID + "'"; try { ExecuteDelete(sql); } catch (Exception e) { MessageBox.Show(e.Message); } }
public string GenerateSubInfoID(AIOSubInfoType subInfoType) { string table = AIOConstant.GetTableName(subInfoType); string sql = "SELECT MAX(ID) FROM " + table; OleDbCommand cmd = new OleDbCommand(sql, cn); object res = cmd.ExecuteScalar(); int id; if (Convert.IsDBNull(res) == false) { id = Convert.ToInt32(res); } else { id = 0; } id++; return(id.ToString("000000")); }
//SubInfo------------------------------------------------------ public bool IsDuplicateName(string name, AIOSubInfoType subInfoType) { string table = AIOConstant.GetTableName(subInfoType); string column = AIOConstant.GetColumnName(subInfoType); string sql = "SELECT COUNT(*) FROM " + table + " WHERE " + column + " = ?"; OleDbCommand cmd = CreateSqlWithParam(sql, new string[] { name }); cmd.Connection = cn; int num = (int)cmd.ExecuteScalar(); if (num > 0) { return(true); } else { return(false); } }