public bool Delete(Object obj) { bool returnResult = false; if (obj is Transaction) { Transaction castObj = (Transaction)obj; string sql = "DELETE FROM TRANSACTION_TABLE WHERE TRANSACTION_INDEX = " + castObj.Index; returnResult = excuteQuery(sql); // 해당 거래명의 인덱스를 가진 값은 모두 삭제 sql = "DELETE FROM COST_ITEM_TABLE WHERE TRANSACTION_INDEX = " + castObj.Index; returnResult = excuteQuery(sql); } else if (obj is CostItem) { CostItem castObj = (CostItem)obj; string sql = "DELETE FROM COST_ITEM_TABLE WHERE COST_ITEM_INDEX = " + castObj.CostItemIndex; returnResult = excuteQuery(sql); } else if (obj is User) { User castObj = (User)obj; string sql = "DELETE FROM TRANSACTION_USER_TABLE WHERE USER_ID = '" + castObj.Id + "'"; returnResult = excuteQuery(sql); } getAllTables(); return(returnResult); }
public bool Update(Object obj) { bool returnResult = false; if (obj is Transaction) { Transaction castObj = (Transaction)obj; if (isRowExist(castObj.Index, 0)) { string sql = "UPDATE TRANSACTION_TABLE SET CUSTOMER_NAME = '" + castObj.CustomerName + "', TRANSACTION_NAME = '" + castObj.TransactionName + "', TRANSACTION_DATE = '" + castObj.TransactionDate + "', SUPPLY_PRICE = " + castObj.SupplyPrice + ", TRANSACTION_CODE = '" + castObj.TransactionCode + "' WHERE TRANSACTION_INDEX =" + castObj.Index; returnResult = excuteQuery(sql); } } else if (obj is CostItem) { CostItem castObj = (CostItem)obj; if (isRowExist(castObj.CostItemIndex, 1)) { string sql = "UPDATE COST_ITEM_TABLE SET SUPPLIER = '" + castObj.Supplier + "', SUM = " + castObj.Sum + ", NOTE = '" + castObj.Note + "' WHERE COST_ITEM_INDEX =" + castObj.CostItemIndex; returnResult = excuteQuery(sql); } } else if (obj is User) { User castObj = (User)obj; string sql = "UPDATE TRANSACTION_USER_TABLE SET USER_PASSWORD = '******', USER_AUTHORITY = " + castObj.Authority + ", DEPARTMENT = " + castObj.Department + "WHERE USER_ID = '" + castObj.Id + "'"; returnResult = excuteQuery(sql); } getAllTables(); return(returnResult); }
public bool Insert(Object obj) { bool returnResult = false; if (obj is Transaction) { Transaction castObj = (Transaction)obj; string sql = "INSERT INTO TRANSACTION_TABLE VALUES (" + castObj.Index + ", '" + castObj.CustomerName + "', '" + castObj.TransactionName + "', '" + castObj.TransactionDate + "', " + castObj.SupplyPrice + ", " + castObj.Department + ", '" + castObj.TransactionCode + "')"; returnResult = excuteQuery(sql); } else if (obj is CostItem) { CostItem castObj = (CostItem)obj; string sql = "INSERT INTO COST_ITEM_TABLE VALUES (" + castObj.CostItemIndex + ", " + castObj.TransactionIndex + ", '" + castObj.Supplier + "', '" + castObj.Sum + "', NULL, NULL, NULL, '" + castObj.Note + "')"; returnResult = excuteQuery(sql); } else if (obj is User) { User castObj = (User)obj; string sql = "INSERT INTO TRANSACTION_USER_TABLE VALUES ('" + castObj.Id + "', '" + castObj.Password + "', " + castObj.Authority + ", " + castObj.Department + ", 'logout')"; returnResult = excuteQuery(sql); } getAllTables(); return(returnResult); }