Example #1
0
 private void ButtonEdit_Click(object sender, EventArgs e)
 {
     if (listViewAgent.SelectedItems.Count == 1)
     {
         try
         {
             Agentset agentset = listViewAgent.SelectedItems[0].Tag as Agentset;
             agentset.FirstName  = textBoxFirstName.Text;
             agentset.MiddleName = textBoxMiddleName.Text;
             agentset.LastName   = textBoxLastName.Text;
             if (textBoxDealShare.Text != "")
             {
                 agentset.DealShare = Convert.ToInt32(textBoxDealShare.Text);
             }
             else
             {
                 agentset.DealShare = null;
             }
             if (agentset.DealShare < 0 || agentset.DealShare > 100)
             {
                 throw new Exception("Доля от комиссии может принимать значение от 0 до 100");
             }
             if (agentset.FirstName == "" || agentset.MiddleName == "" || agentset.LastName == "")
             {
                 throw new Exception("Заполните поля 'ФАМИЛИЯ', 'ИМЯ', 'ОТЧЕСТВО'!");
             }
             Program.wftDb.SaveChanges();
             ShowAgent();
         }
         catch (Exception ex)
         {
             MessageBox.Show("" + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Example #2
0
 private void ListViewAgent_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewAgent.SelectedItems.Count == 1)
     {
         Agentset agentset = listViewAgent.SelectedItems[0].Tag as Agentset;
         textBoxFirstName.Text  = agentset.FirstName;
         textBoxMiddleName.Text = agentset.MiddleName;
         textBoxLastName.Text   = agentset.LastName;
         textBoxDealShare.Text  = agentset.DealShare.ToString();
     }
     else
     {
         textBoxFirstName.Text  = "";
         textBoxMiddleName.Text = "";
         textBoxLastName.Text   = "";
         textBoxDealShare.Text  = "";
     }
 }
Example #3
0
        private void ButtonDel_Click(object sender, EventArgs e)
        {
            try
            {
                if (listViewAgent.SelectedItems.Count == 1)
                {
                    Agentset agentset = listViewAgent.SelectedItems[0].Tag as Agentset;
                    Program.wftDb.Agentset.Remove(agentset);
                    Program.wftDb.SaveChanges();
                    ShowAgent();
                }

                textBoxFirstName.Text  = "";
                textBoxMiddleName.Text = "";
                textBoxLastName.Text   = "";
                textBoxDealShare.Text  = "";
            }
            catch
            {
                MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }