Пример #1
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (listViewDealPP.SelectedItems.Count == 1)
            {
                DealSetPP dealSet = listViewDealPP.SelectedItems[0].Tag as DealSetPP;

                dealSet.IdAgent          = Convert.ToInt32(comboBoxAgent.SelectedItem.ToString().Split('.')[0]);
                dealSet.IdClient         = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
                dealSet.IdProgramProduct = Convert.ToInt32(comboBoxPP.SelectedItem.ToString().Split('.')[0]);
                dealSet.Amount           = Convert.ToInt32(textBoxAmount.Text);
                dealSet.TotalPrice       = Convert.ToInt32(textBoxTotalPrice.Text);
                Program.entities1c.SaveChanges();
                ShowDealPP();
            }
        }
Пример #2
0
 private void listViewDealPP_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewDealPP.SelectedItems.Count == 1)
     {
         DealSetPP dealSet = listViewDealPP.SelectedItems[0].Tag as DealSetPP;
         comboBoxAgent.SelectedIndex  = comboBoxAgent.FindString(dealSet.IdAgent.ToString());
         comboBoxClient.SelectedIndex = comboBoxClient.FindString(dealSet.IdClient.ToString());
         comboBoxPP.SelectedIndex     = comboBoxPP.FindString(dealSet.IdProgramProduct.ToString());
         textBoxAmount.Text           = dealSet.Amount.ToString();
         textBoxTotalPrice.Text       = dealSet.TotalPrice.ToString();
     }
     else
     {
         comboBoxAgent.SelectedItem  = null;
         comboBoxClient.SelectedItem = null;
         comboBoxPP.SelectedItem     = null;
         textBoxAmount.Text          = "";
         textBoxTotalPrice.Text      = "";
     }
 }
Пример #3
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (comboBoxAgent.SelectedItem != null && comboBoxClient.SelectedItem != null && comboBoxPP.SelectedItem != null && textBoxAmount.Text.Length > 0 && textBoxTotalPrice.Text.Length > 0)
            {
                DealSetPP dealSet = new DealSetPP();

                dealSet.IdAgent          = Convert.ToInt32(comboBoxAgent.SelectedItem.ToString().Split('.')[0]);
                dealSet.IdClient         = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
                dealSet.IdProgramProduct = Convert.ToInt32(comboBoxPP.SelectedItem.ToString().Split('.')[0]);
                dealSet.Amount           = Convert.ToInt32(textBoxAmount.Text);
                dealSet.TotalPrice       = Convert.ToInt32(textBoxTotalPrice.Text);
                Program.entities1c.DealSetPP.Add(dealSet);
                Program.entities1c.SaveChanges();
                ShowDealPP();
            }
            else
            {
                MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewDealPP.SelectedItems.Count == 1)
         {
             DealSetPP dealSet = listViewDealPP.SelectedItems[0].Tag as DealSetPP;
             Program.entities1c.DealSetPP.Remove(dealSet);
             Program.entities1c.SaveChanges();
             ShowDealPP();
         }
         comboBoxAgent.SelectedItem  = null;
         comboBoxClient.SelectedItem = null;
         comboBoxPP.SelectedItem     = null;
         textBoxAmount.Text          = "";
         textBoxTotalPrice.Text      = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }