Пример #1
0
        private void ButtonAdd_Click(object sender, EventArgs e)
        {
            AgentSet agentSet = new AgentSet();

            agentSet.FirstName  = textBoxFirstName.Text;
            agentSet.MiddleName = textBoxMiddleName.Text;
            agentSet.LastName   = textBoxLastName.Text;
            agentSet.DealShare  = Convert.ToInt32(textBoxDealShare.Text);
            Program.wftDb.AgentSet.Add(agentSet);
            Program.wftDb.SaveChanges();
            ShowAgent();
        }
Пример #2
0
 private void ButtonEdit_Click(object sender, EventArgs e)
 {
     if (listViewAgent.SelectedItems.Count == 1)
     {
         AgentSet agentSet = listViewAgent.SelectedItems[0].Tag as AgentSet;
         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 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);
     }
 }