コード例 #1
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     try
     {
         иелтор agentSet = new  иелтор();
         agentSet.FirstName  = textBoxFirstName.Text;
         agentSet.MiddleName = textBoxMiddleName.Text;
         agentSet.LastName   = textBoxLastName.Text;
         agentSet.DealShare  = Convert.ToInt32(textBoxDealShare.Text);
         if (agentSet.FirstName == "" || agentSet.MiddleName == "" || agentSet.LastName == "")
         {
             throw new Exception("Не заполнены поля имени, фамилии или отчества");
         }
         if (agentSet.DealShare < 0 || agentSet.DealShare > 100)
         {
             throw new Exception("Поле *Доля коммиссии* должно содержать процент (от 0 до 100)");
         }
         Program.wftDb.иелтор.Add(agentSet);
         Program.wftDb.SaveChanges();
         ShowAgent();
     }
     catch (Exception ex)
     {
         MessageBox.Show("" + ex.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #2
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewAgent.SelectedItems.Count == 1)
     {
         иелтор agentSet = listViewAgent.SelectedItems[0].Tag as  иелтор;
         agentSet.FirstName  = textBoxFirstName.Text;
         agentSet.MiddleName = textBoxMiddleName.Text;
         agentSet.LastName   = textBoxLastName.Text;
         agentSet.DealShare  = Convert.ToInt32(textBoxDealShare.Text);
         Program.wftDb.SaveChanges();
         ShowAgent();
     }
 }
コード例 #3
0
 private void listViewAgent_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewAgent.SelectedItems.Count == 1)
     {
         иелтор agentSet = listViewAgent.SelectedItems[0].Tag as  иелтор;
         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  = "";
     }
 }
コード例 #4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewAgent.SelectedItems.Count == 1)
         {
             иелтор agentSet = listViewAgent.SelectedItems[0].Tag as  иелтор;
             Program.wftDb.иелтор.Remove(agentSet);
             Program.wftDb.SaveChanges();
             ShowAgent();
         }
         textBoxFirstName.Text  = "";
         textBoxMiddleName.Text = "";
         textBoxLastName.Text   = "";
         textBoxDealShare.Text  = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }