private void buttonAdd_Click(object sender, EventArgs e) { TovarSet tovar = new TovarSet(); tovar.Name = textBoxName.Text; tovar.Material = textBoxMaterial.Text; tovar.Lenght = Convert.ToDouble(textBoxLenght.Text); tovar.Width = Convert.ToDouble(textBoxWidth.Text); tovar.Height = Convert.ToDouble(textBoxHeight.Text); tovar.Price = Convert.ToInt32(textBoxPrice.Text); if (comboBoxType.SelectedIndex == 0) { tovar.Type = 0; } else if (comboBoxType.SelectedIndex == 1) { tovar.Type = 1; } else { tovar.Type = 2; } Program.lazur.TovarSet.Add(tovar); Program.lazur.SaveChanges(); ShowTovar(); }
void Price() { if (comboBoxAgent.SelectedItem != null && comboBoxClient.SelectedItem != null && comboBoxTovar.SelectedItem != null) { AgentSet agent = Program.lazur.AgentSet.Find(Convert.ToInt32(comboBoxAgent.SelectedItem.ToString().Split('.')[0])); ClientSet client = Program.lazur.ClientSet.Find(Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0])); TovarSet tovar = Program.lazur.TovarSet.Find(Convert.ToInt32(comboBoxTovar.SelectedItem.ToString().Split('.')[0])); double percentShop = tovar.Price * 0.05; textBoxPercentShop.Text = percentShop.ToString("0.00"); if (agent.PersentSales != null) { double percentAgent = tovar.Price * Convert.ToDouble(agent.PersentSales) / 100.00; textBoxPercentAgent.Text = percentAgent.ToString("0.00"); } else { double percentAgent = tovar.Price * 0.03; textBoxPercentAgent.Text = percentAgent.ToString("0.00"); } } else { textBoxPercentAgent.Text = ""; textBoxPercentShop.Text = ""; } }
private void buttonEdit_Click(object sender, EventArgs e) { if (comboBoxType.SelectedIndex == 0) { if (listViewDivan.SelectedItems.Count == 1) { TovarSet tovar = listViewDivan.SelectedItems[0].Tag as TovarSet; tovar.Name = textBoxName.Text; tovar.Material = textBoxMaterial.Text; tovar.Lenght = Convert.ToDouble(textBoxLenght.Text); tovar.Width = Convert.ToDouble(textBoxWidth.Text); tovar.Height = Convert.ToDouble(textBoxHeight.Text); tovar.Price = Convert.ToInt32(textBoxPrice.Text); Program.lazur.SaveChanges(); ShowTovar(); } } else if (comboBoxType.SelectedIndex == 1) { if (listViewKreslo.SelectedItems.Count == 1) { TovarSet tovar = listViewKreslo.SelectedItems[0].Tag as TovarSet; tovar.Name = textBoxName.Text; tovar.Material = textBoxMaterial.Text; tovar.Lenght = Convert.ToDouble(textBoxLenght.Text); tovar.Width = Convert.ToDouble(textBoxWidth.Text); tovar.Height = Convert.ToDouble(textBoxHeight.Text); tovar.Price = Convert.ToInt32(textBoxPrice.Text); Program.lazur.SaveChanges(); ShowTovar(); } } else { if (listViewKrovat.SelectedItems.Count == 1) { TovarSet tovar = listViewKrovat.SelectedItems[0].Tag as TovarSet; tovar.Name = textBoxName.Text; tovar.Material = textBoxMaterial.Text; tovar.Lenght = Convert.ToDouble(textBoxLenght.Text); tovar.Width = Convert.ToDouble(textBoxWidth.Text); tovar.Height = Convert.ToDouble(textBoxHeight.Text); tovar.Price = Convert.ToInt32(textBoxPrice.Text); Program.lazur.SaveChanges(); ShowTovar(); } } }
private void listViewKrovat_SelectedIndexChanged(object sender, EventArgs e) { if (listViewKrovat.SelectedItems.Count == 1) { TovarSet tovar = listViewKrovat.SelectedItems[0].Tag as TovarSet; textBoxName.Text = tovar.Name; textBoxMaterial.Text = tovar.Material; textBoxLenght.Text = tovar.Lenght.ToString(); textBoxWidth.Text = tovar.Width.ToString(); textBoxHeight.Text = tovar.Height.ToString(); textBoxPrice.Text = tovar.Price.ToString(); } else { textBoxName.Text = ""; textBoxMaterial.Text = ""; textBoxLenght.Text = ""; textBoxWidth.Text = ""; textBoxHeight.Text = ""; textBoxPrice.Text = ""; } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (comboBoxType.SelectedIndex == 0) { if (listViewDivan.SelectedItems.Count == 1) { TovarSet tovar = listViewDivan.SelectedItems[0].Tag as TovarSet; Program.lazur.TovarSet.Remove(tovar); Program.lazur.SaveChanges(); ShowTovar(); } textBoxName.Text = ""; textBoxMaterial.Text = ""; textBoxLenght.Text = ""; textBoxWidth.Text = ""; textBoxHeight.Text = ""; textBoxPrice.Text = ""; } else if (comboBoxType.SelectedIndex == 1) { if (listViewKreslo.SelectedItems.Count == 1) { TovarSet tovar = listViewKreslo.SelectedItems[0].Tag as TovarSet; Program.lazur.TovarSet.Remove(tovar); Program.lazur.SaveChanges(); ShowTovar(); } textBoxName.Text = ""; textBoxMaterial.Text = ""; textBoxLenght.Text = ""; textBoxWidth.Text = ""; textBoxHeight.Text = ""; textBoxPrice.Text = ""; } else { if (listViewKrovat.SelectedItems.Count == 1) { TovarSet tovar = listViewKrovat.SelectedItems[0].Tag as TovarSet; Program.lazur.TovarSet.Remove(tovar); Program.lazur.SaveChanges(); ShowTovar(); } textBoxName.Text = ""; textBoxMaterial.Text = ""; textBoxLenght.Text = ""; textBoxWidth.Text = ""; textBoxHeight.Text = ""; textBoxPrice.Text = ""; } } catch { MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }