Beispiel #1
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewDeal.SelectedItems.Count == 1)
     {
         DealSet deal = listViewDeal.SelectedItems[0].Tag as DealSet;
         deal.Id_Agent  = Convert.ToInt32(comboBoxAgent.SelectedItem.ToString().Split('.')[0]);
         deal.Id_Client = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
         deal.Price     = Convert.ToInt64(textBoxSale.Text);
         Program.wftDb.SaveChanges();
         ShowDealSet();
     }
 }
Beispiel #2
0
 private void listViewDeal_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewDeal.SelectedItems.Count == 1)
     {
         DealSet deal = listViewDeal.SelectedItems[0].Tag as DealSet;
         comboBoxAgent.SelectedIndex  = comboBoxAgent.FindString(deal.Id_Agent.ToString());
         comboBoxClient.SelectedIndex = comboBoxClient.FindString(deal.Id_Client.ToString());
         textBoxSale.Text             = deal.Price.ToString();
     }
     else
     {
         comboBoxAgent.SelectedItem  = null;
         comboBoxClient.SelectedItem = null;
         textBoxSale.Text            = "";
     }
 }
Beispiel #3
0
        private void buttonDel_Click(object sender, EventArgs e)
        {
            try
            {
                if (listViewDeal.SelectedItems.Count == 1)
                {
                    DealSet deal = listViewDeal.SelectedItems[0].Tag as DealSet;
                    Program.wftDb.DealSet.Remove(deal);
                    Program.wftDb.SaveChanges();
                    ShowDealSet();
                }
                comboBoxAgent.SelectedItem  = null;
                comboBoxClient.SelectedItem = null;
                textBoxSale.Text            = "";
            }

            catch
            {
                MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #4
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (comboBoxAgent.SelectedItem != null && comboBoxClient.SelectedItem != null && textBoxSale.Text != "")
            {
                DealSet deal = new DealSet();

                deal.Id_Agent = Convert.ToInt32(comboBoxAgent.SelectedItem.ToString().Split('.')[0]);

                deal.Id_Client = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);

                deal.Price = Convert.ToInt64(textBoxSale.Text);

                Program.wftDb.DealSet.Add(deal);

                Program.wftDb.SaveChanges();

                ShowDealSet();
            }
            else
            {
                MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }