private void SaveDefaultValue() { string insertQuery = "insert into [Default](Product, Source,Destination,Type) values('{0}','{1}','{2}','{3}')"; string updateQuery = "update [Default] set Product='{0}', Source='{1}', Destination='{2}', Type='{3}'"; string selectQuery = "select count(*) from [Default]"; int cnt = 0; string query = string.Empty; string value = string.Empty; using (var db = new DBEngine()) { cnt = (int)db.ExecuteScalar(string.Format(selectQuery), null); } if (cnt > 0) { query = updateQuery; } else { query = insertQuery; } using (var db = new DBEngine()) { db.ExecuteNonQuery(string.Format(query, cmbCommodity.SelectedItem.ToString(), cmbSource.SelectedItem.ToString(), cmbDestination.SelectedItem.ToString(), lstWagonType.SelectedItem.ToString())); } }
private int ScreenCommonRecordCount() { string selectQuery = "select count(*) from ScreenCommon"; int cnt = 0; using (var db = new DBEngine()) { cnt = (int)db.ExecuteScalar(string.Format(selectQuery), null); } return(cnt); }