コード例 #1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            MenedzherSet menedzherSet = new MenedzherSet();

            menedzherSet.FirstName  = textBoxFirstName.Text;
            menedzherSet.MiddleName = textBoxMiddleName.Text;
            menedzherSet.LastName   = textBoxLastName.Text;
            menedzherSet.Email      = textBoxEmail.Text;
            Program.kontragenty.MenedzherSet.Add(menedzherSet);
            Program.kontragenty.SaveChanges();
            ShowMenedzher();
        }
コード例 #2
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewMenedzher.SelectedItems.Count == 1)
     {
         MenedzherSet menedzherSet = listViewMenedzher.SelectedItems[0].Tag as MenedzherSet;
         menedzherSet.FirstName  = textBoxFirstName.Text;
         menedzherSet.MiddleName = textBoxMiddleName.Text;
         menedzherSet.LastName   = textBoxLastName.Text;
         menedzherSet.Email      = textBoxEmail.Text;
         Program.kontragenty.SaveChanges();
         ShowMenedzher();
     }
 }
コード例 #3
0
 private void listViewMenedzher_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewMenedzher.SelectedItems.Count == 1)
     {
         MenedzherSet menedzherSet = listViewMenedzher.SelectedItems[0].Tag as MenedzherSet;
         textBoxFirstName.Text  = menedzherSet.FirstName;
         textBoxMiddleName.Text = menedzherSet.MiddleName;
         textBoxLastName.Text   = menedzherSet.LastName;
         textBoxEmail.Text      = menedzherSet.Email;
     }
     else
     {
         textBoxFirstName.Text  = "";
         textBoxMiddleName.Text = "";
         textBoxLastName.Text   = "";
         textBoxEmail.Text      = "";
     }
 }
コード例 #4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewMenedzher.SelectedItems.Count == 1)
         {
             MenedzherSet menedzherSet = listViewMenedzher.SelectedItems[0].Tag as MenedzherSet;
             Program.kontragenty.MenedzherSet.Remove(menedzherSet);
             Program.kontragenty.SaveChanges();
             ShowMenedzher();
         }
         textBoxFirstName.Text  = "";
         textBoxMiddleName.Text = "";
         textBoxLastName.Text   = "";
         textBoxEmail.Text      = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }