Esempio n. 1
0
 private void EditButton_Click(object sender, EventArgs e)
 {
     if (ServicesDataGrid.CurrentCell != null)
     {
         int            row      = ServicesDataGrid.CurrentCell.RowIndex;
         string         name     = Convert.ToString(ServicesDataGrid[1, row].Value);
         int            price    = Convert.ToInt32(ServicesDataGrid[2, row].Value);
         AddServiceForm editForm = new AddServiceForm {
             ServiceName = name, Price = price
         };
         editForm.ShowDialog();
         if (editForm.DialogResult == DialogResult.OK)
         {
             name  = editForm.ServiceName;
             price = editForm.Price;
             string queryText = "UPDATE services SET servicename='" + name + "',price=" + Convert.ToString(price);
             ExecuteQuery(queryText);
             ShowServices();
         }
     }
     else
     {
         MessageBox.Show("Не выбрана запись для редактирования", "Ошибка!", MessageBoxButtons.OK);
     }
 }
Esempio n. 2
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            AddServiceForm addForm = new AddServiceForm();

            addForm.ShowDialog();
            if (addForm.DialogResult == DialogResult.OK)
            {
                string serviceName = addForm.ServiceName;
                int    price       = addForm.Price;
                string queryText   = "INSERT INTO services (servicename,price) VALUES ('" + serviceName + "'," + Convert.ToString(price) + ")";
                ExecuteQuery(queryText);
                ShowServices();
            }
        }