public int AddNewCenter(CenterModel Emp) { SqlConnection connection = new SqlConnection("Server=Tanmoy-pc; Database=Wedding Management; User Id=sa; Password=1238628257"); connection.Open(); string query = "INSERT INTO CenterList(CenterId, CenterName, capacity, location, cost, FoodCatering, Status ) VALUES('" + Emp.CenterId + "', '" + Emp.CenterName + "', '" + Emp.CenterCapacity + "', '" + Emp.CenterLocation + "','" + Emp.CenterCost + "','" + Emp.FoodCatering + "','" + "Available" + "')"; SqlCommand cmd = new SqlCommand(query, connection); int i = cmd.ExecuteNonQuery(); connection.Close(); return(i); }
private void Add_Button_Click_1(object sender, RoutedEventArgs e) { string centerName = Convert.ToString(Center_Name_textBox.Text); string centerCapacity = Convert.ToString(Center_Capacity_textBox.Text); string centerLocation = Convert.ToString(Center_Location_textBox.Text); string centerCost = Convert.ToString(Center_Cost_textBox.Text); string centerCatering = Convert.ToString(Center_Catering_textBox.Text); CenterJobs.CenterModel newCenter = new CenterJobs.CenterModel(CenterModel.id(), centerName, centerCapacity, centerLocation, centerCost, centerCatering); CenterJobs.CenterService cs = new CenterJobs.CenterService(); int i = cs.AddNewCenter(newCenter); MainWindow mw = new MainWindow(); mw.centerDataGrid.ItemsSource = cs.LoadData(); this.Close(); }