コード例 #1
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewReport.SelectedItems.Count == 1)
     {
         ReportsSet reportSet = listViewReport.SelectedItems[0].Tag as ReportsSet;
         reportSet.IdClient       = Convert.ToInt32(comboBoxIdClient.SelectedItem.ToString().Split('.')[0]);
         reportSet.IdNameService  = Convert.ToInt32(comboBoxIdNameService.SelectedItem.ToString().Split('.')[0]);
         reportSet.IdConsultation = Convert.ToInt32(comboBoxIdConsultation.SelectedItem.ToString().Split('.')[0]);
         reportSet.Price          = Convert.ToInt32(textBoxPrice.Text);
         Program.wftDb.SaveChanges();
         ShowReport();
     }
 }
コード例 #2
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (comboBoxIdClient.SelectedItem != null && comboBoxIdNameService.SelectedItem != null)
     {
         ReportsSet reportSet = new ReportsSet();
         reportSet.IdClient       = Convert.ToInt32(comboBoxIdClient.SelectedItem.ToString().Split('.')[0]);
         reportSet.IdNameService  = Convert.ToInt32(comboBoxIdNameService.SelectedItem.ToString().Split('.')[0]);
         reportSet.IdConsultation = Convert.ToInt32(comboBoxIdConsultation.SelectedItem.ToString().Split('.')[0]);
         reportSet.Price          = Convert.ToInt32(textBoxPrice.Text);
         Program.wftDb.ReportsSet.Add(reportSet);
         Program.wftDb.SaveChanges();
         ShowReport();
     }
     else
     {
         MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
コード例 #3
0
 private void listViewReport_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewReport.SelectedItems.Count == 1)
     {
         ReportsSet reportSett = listViewReport.SelectedItems[0].Tag as ReportsSet;
         comboBoxIdClient.SelectedIndex       = comboBoxIdClient.FindString(reportSett.IdClient.ToString());
         comboBoxIdNameService.SelectedIndex  = comboBoxIdNameService.FindString(reportSett.IdNameService.ToString());
         comboBoxIdConsultation.SelectedIndex = comboBoxIdConsultation.FindString(reportSett.IdConsultation.ToString());
         textBoxPrice.Text = reportSett.Price.ToString();
     }
     else
     {
         comboBoxIdClient.SelectedItem       = null;
         comboBoxIdNameService.SelectedItem  = null;
         comboBoxIdConsultation.SelectedItem = null;
         textBoxPrice.Text = "";
     }
 }
コード例 #4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewReport.SelectedItems.Count == 1)
         {
             ReportsSet reportSett = listViewReport.SelectedItems[0].Tag as ReportsSet;
             Program.wftDb.ReportsSet.Remove(reportSett);
             Program.wftDb.SaveChanges();
             ShowReport();
         }
         comboBoxIdClient.SelectedItem       = null;
         comboBoxIdNameService.SelectedItem  = null;
         comboBoxIdConsultation.SelectedItem = null;
         textBoxPrice.Text = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }