예제 #1
0
        private void buttonEditService_Click(object sender, EventArgs e)
        {
            try
            {
                MedicalServicesRow currentSelectedValue = (MedicalServicesRow)((DataRowView)medicalServicesBindingSource.Current).Row;

                DataSet dataSet = new DataSet();
                adapter.SelectCommand = new SqlCommand("SELECT * FROM MedicalServices where 1 = 2", connection);
                adapter.Fill(dataSet, "MedicalServices");

                SqlCommand command = new SqlCommand("UPDATE MedicalServices SET ServiceName=@serviceName, ServiceDescription= @serviceDescription, Price= @price " +
                                                    "WHERE MedicalServiceID=@serviceID", connection);

                adapter.InsertCommand = command;
                adapter.InsertCommand.Parameters.AddWithValue("@serviceID", currentSelectedValue.MedicalServiceID);
                adapter.InsertCommand.Parameters.AddWithValue("@serviceName", textBoxAdministrationServiceName.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@serviceDescription", textBoxAdministrationServiceDescription.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@price", textBoxAdministrationServicePrice.Text);

                adapter.InsertCommand = command;
                adapter.SelectCommand = command;
                adapter.Fill(dataSet, "MedicalServices");
                adapter.Update(dataSet, "MedicalServices");

                MessageBox.Show("Zapisano.");
                textBoxAdministrationServiceName.Clear();
                textBoxAdministrationServiceDescription.Clear();
                textBoxAdministrationServicePrice.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Spróbuj ponownie.");
            }
        }
예제 #2
0
        private void medicalServicesDataGridView_SelectionChanged(object sender, EventArgs e)
        {
            MedicalServicesRow currentSelectedValue = (MedicalServicesRow)((DataRowView)medicalServicesBindingSource.Current).Row;

            textBoxAdministrationServiceName.Text        = currentSelectedValue.ServiceName.ToString();
            textBoxAdministrationServiceDescription.Text = currentSelectedValue.ServiceDescription.ToString();
            textBoxAdministrationServicePrice.Text       = currentSelectedValue.Price.ToString();
        }