public List<Zone> GetAllZonesCheckedListView() { SqlConnection connection = new SqlConnection(databaseConString); string query = "SELECT * FROM tbl_zone"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); List<Zone> zoneList = new List<Zone>(); while (reader.Read()) { Zone zones = new Zone(); zones.ZoneId = int.Parse(reader["zone_id"].ToString()); zones.ZoneCode = reader["zone_code"].ToString(); zones.ZoneName = reader["zone_name"].ToString(); zoneList.Add(zones); } reader.Close(); connection.Close(); return zoneList; }
public List<Zone> GetAllZoneVisitorNumberListBox() { SqlConnection connection = new SqlConnection(databaseConString); string query = "SELECT * FROM tbl_zone"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); List<Zone> zoneList = new List<Zone>(); while (reader.Read()) { Zone zones = new Zone(); zones.ZoneId = int.Parse(reader["zone_id"].ToString()); zones.ZoneName = reader["zone_name"].ToString(); //Visitor visitors = new Visitor(); //visitors.VisitorId = int.Parse(reader["visitor_id"].ToString()); //visitors.VisitorName = reader["visitor_name"].ToString(); //visitors.VisitorEmail = reader["visitor_email"].ToString(); //visitors.ContactNumber = reader["visitor_contactNo"].ToString(); //visitors.VisitorZoneId = reader["visitor_zoneId"].ToString(); //visitors.visitorZoneName = reader["zone_name"].ToString(); zoneList.Add(zones); } reader.Close(); connection.Close(); return zoneList; }
public string Save(Zone zones) { bool checkZoneCodeAndName = IsZoneCodeAndNameExists(zones.ZoneCode,zones.ZoneName); if (checkZoneCodeAndName) { return "Zone Allready Exists!"; } if (zoneEntryGateway.Save(zones) > 0) { return "Added Successfully!"; } else { return "Could Not Added!"; } }
private void saveButton_Click(object sender, EventArgs e) { if (zoneCodeTextBox.Text == "" || zoneNameTextBox.Text == "") { MessageBox.Show("All fields are required!"); } else { Zone zones = new Zone(); zones.ZoneCode = zoneCodeTextBox.Text; zones.ZoneName = zoneNameTextBox.Text; MessageBox.Show(zoneEntryManager.Save(zones)); ClearAllTextBoxes(); LoadAllZonesListView(); } }
public Zone GetZoneCodeAndName(string zoneCode, string zoneName) { SqlConnection connection = new SqlConnection(databaseConString); string query = "SELECT * FROM tbl_zone WHERE zone_code = '" + zoneCode + "' OR zone_name = '" + zoneName + "'"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); Zone zones = null; while (reader.Read()) { if (zones == null) { zones = new Zone(); } zones.ZoneCode = reader["zone_code"].ToString(); zones.ZoneName = reader["zone_name"].ToString(); } reader.Close(); connection.Close(); return zones; }
public int Save(Zone zones) { SqlConnection connection = new SqlConnection(databaseConString); string query = "INSERT INTO tbl_zone VALUES ('" + zones.ZoneCode + "','" + zones.ZoneName + "')"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); int rowAffected = command.ExecuteNonQuery(); connection.Close(); return rowAffected; }