Exemplo n.º 1
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (listViewDealITS.SelectedItems.Count == 1)
            {
                DealSetITS dealSet = listViewDealITS.SelectedItems[0].Tag as DealSetITS;

                dealSet.IdAgent    = Convert.ToInt32(comboBoxAgent.SelectedItem.ToString().Split('.')[0]);
                dealSet.IdClient   = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
                dealSet.IdIts      = Convert.ToInt32(comboBoxITS.SelectedItem.ToString().Split('.')[0]);
                dealSet.Amount     = Convert.ToInt32(textBoxAmount.Text);
                dealSet.TotalPrice = Convert.ToInt32(textBoxTotalPrice.Text);
                Program.entities1c.SaveChanges();
                ShowDealITS();
            }
        }
Exemplo n.º 2
0
 private void listViewDealITS_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewDealITS.SelectedItems.Count == 1)
     {
         DealSetITS dealSet = listViewDealITS.SelectedItems[0].Tag as DealSetITS;
         comboBoxAgent.SelectedIndex  = comboBoxAgent.FindString(dealSet.IdAgent.ToString());
         comboBoxClient.SelectedIndex = comboBoxClient.FindString(dealSet.IdClient.ToString());
         comboBoxITS.SelectedIndex    = comboBoxITS.FindString(dealSet.IdIts.ToString());
         textBoxAmount.Text           = dealSet.Amount.ToString();
         textBoxTotalPrice.Text       = dealSet.TotalPrice.ToString();
     }
     else
     {
         comboBoxAgent.SelectedItem  = null;
         comboBoxClient.SelectedItem = null;
         comboBoxITS.SelectedItem    = null;
         textBoxAmount.Text          = "";
         textBoxTotalPrice.Text      = "";
     }
 }
Exemplo n.º 3
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (comboBoxAgent.SelectedItem != null && comboBoxClient.SelectedItem != null && comboBoxITS.SelectedItem != null && textBoxAmount.Text.Length > 0 && textBoxTotalPrice.Text.Length > 0)
            {
                DealSetITS dealSet = new DealSetITS();

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