コード例 #1
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     try
     {
         RealtorsSet RealtorSet = new RealtorsSet();
         //делаем ссылку на объект, который хранится в textBox-ax
         RealtorSet.FirstName  = textBoxFirstName.Text;
         RealtorSet.MiddleName = textBoxMiddleName.Text;
         RealtorSet.LastName   = textBoxLastName.Text;
         if (textBoxDealShare.Text != "")
         {
             RealtorSet.DealShare = Convert.ToInt32(textBoxDealShare.Text);
         }
         if ((RealtorSet.DealShare < 0) || (RealtorSet.DealShare > 100))
         {
             throw new Exception("Доля должна находиться в диапазоне от 0 до 100");
         }
         Program.wftDb.RealtorsSet.Add(RealtorSet);
         //сохраняем изменения в модели wftDb
         Program.wftDb.SaveChanges();
         ShowRealtor();
     }
     catch (Exception expection)
     {
         MessageBox.Show(expection.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #2
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            RealtorsSet realtorSet = new RealtorsSet();

            realtorSet.FirstName  = textBoxFirstName.Text;
            realtorSet.MiddleName = textBoxMiddleName.Text;
            realtorSet.LastName   = textBoxLastName.Text;
            realtorSet.DealShare  = Convert.ToInt32(textBoxDealShare.Text);
            Program.wftDb.RealtorsSet.Add(realtorSet);
            Program.wftDb.SaveChanges();
            ShowRealtor();
        }
コード例 #3
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewRealtor.SelectedItems.Count == 1)
     {
         RealtorsSet realtorSet = listViewRealtor.SelectedItems[0].Tag as RealtorsSet;
         realtorSet.FirstName  = textBoxFirstName.Text;
         realtorSet.MiddleName = textBoxMiddleName.Text;
         realtorSet.LastName   = textBoxLastName.Text;
         realtorSet.DealShare  = Convert.ToInt32(textBoxDealShare.Text);
         Program.wftDb.SaveChanges();
         ShowRealtor();
     }
 }
コード例 #4
0
 private void listViewRealtor_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewRealtor.SelectedItems.Count == 1)
     {
         RealtorsSet realtorSet = listViewRealtor.SelectedItems[0].Tag as RealtorsSet;
         textBoxFirstName.Text  = realtorSet.FirstName;
         textBoxMiddleName.Text = realtorSet.MiddleName;
         textBoxLastName.Text   = realtorSet.LastName;
         textBoxDealShare.Text  = Convert.ToString(realtorSet.DealShare);
     }
     else
     {
         textBoxFirstName.Text  = "";
         textBoxMiddleName.Text = "";
         textBoxLastName.Text   = "";
         textBoxDealShare.Text  = "";
     }
 }
コード例 #5
0
 private void listViewRealtor_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewRealtor.SelectedItems.Count == 1)
     {
         RealtorsSet RealtorSet = listViewRealtor.SelectedItems[0].Tag as RealtorsSet;
         RealtorSet.FirstName  = textBoxFirstName.Text;
         RealtorSet.MiddleName = textBoxMiddleName.Text;
         RealtorSet.LastName   = textBoxLastName.Text;
         if (textBoxDealShare.Text != "")
         {
             RealtorSet.DealShare = Convert.ToInt32(textBoxDealShare.Text);
         }
     }
     else
     {
         textBoxFirstName.Text  = "";
         textBoxMiddleName.Text = "";
         textBoxLastName.Text   = "";
         textBoxDealShare.Text  = "";
     }
 }
コード例 #6
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewRealtor.SelectedItems.Count == 1)
         {
             RealtorsSet RealtorSet = listViewRealtor.SelectedItems[0].Tag as RealtorsSet;
             Program.wftDb.RealtorsSet.Remove(RealtorSet);
             Program.wftDb.SaveChanges();
             ShowRealtor();
         }
         textBoxFirstName.Text  = "";
         textBoxMiddleName.Text = "";
         textBoxLastName.Text   = "";
         textBoxDealShare.Text  = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }