コード例 #1
0
 private void buttonEditInfo_Click(object sender, EventArgs e)
 {
     if (listViewConsultInvest.SelectedItems.Count == 1)
     {
         ConsultInvest ci = listViewConsultInvest.SelectedItems[0].Tag as ConsultInvest;
         ci.NamesurnameSotr = Convert.ToString(textBoxNameSotr.Text);
         ci.IdUser          = Convert.ToInt32(comboBoxNameUser.SelectedItem.ToString().Split('.')[0]);
         ci.PlaceInvest     = Convert.ToString(textBoxPlaceInvest.Text);
         ci.ActualInvest    = Convert.ToInt32(comboBoxActualInvest.Text);
         ci.ColInvest       = Convert.ToString(textBoxColInvest.Text);
         Program.ADb.SaveChanges();
         ShowInvest();
     }
 }
コード例 #2
0
 private void buttonAddInfo_Click(object sender, EventArgs e)
 {
     if (comboBoxNameUser.SelectedItem != null && comboBoxActualInvest.SelectedItem != null)
     {
         ConsultInvest ci = new ConsultInvest();
         ci.NamesurnameSotr = Convert.ToString(textBoxNameSotr.Text);
         ci.IdUser          = Convert.ToInt32(comboBoxNameUser.SelectedItem.ToString().Split('.')[0]);
         ci.PlaceInvest     = Convert.ToString(textBoxPlaceInvest.Text);
         ci.ActualInvest    = Convert.ToInt32(comboBoxActualInvest.Text);
         ci.ColInvest       = Convert.ToString(textBoxColInvest.Text);
         Program.ADb.ConsultInvest.Add(ci);
         Program.ADb.SaveChanges();
         ShowInvest();
     }
     else
     {
         MessageBox.Show("Данные не выбраны", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
コード例 #3
0
 private void listViewConsultInvest_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewConsultInvest.SelectedItems.Count == 1)
     {
         ConsultInvest ci = listViewConsultInvest.SelectedItems[0].Tag as ConsultInvest;
         textBoxNameSotr.Text           = ci.NamesurnameSotr.ToString();
         comboBoxNameUser.SelectedIndex = comboBoxNameUser.FindString(ci.IdUser.ToString());
         comboBoxActualInvest.Text      = ci.ActualInvest.ToString();
         textBoxPlaceInvest.Text        = ci.PlaceInvest.ToString();
         textBoxColInvest.Text          = ci.ColInvest.ToString();
     }
     else
     {
         textBoxNameSotr.Text          = "";
         comboBoxNameUser.SelectedItem = null;
         textBoxPlaceInvest.Text       = "";
         textBoxColInvest.Text         = "";
     }
 }
コード例 #4
0
 private void buttonDelInfo_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewConsultInvest.SelectedItems.Count == 1)
         {
             ConsultInvest ci = listViewConsultInvest.SelectedItems[0].Tag as ConsultInvest;
             Program.ADb.ConsultInvest.Remove(ci);
             Program.ADb.SaveChanges();
             ShowInvest();
         }
         textBoxNameSotr.Text          = "";
         comboBoxNameUser.SelectedItem = null;
         textBoxPlaceInvest.Text       = "";
         textBoxColInvest.Text         = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }