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 buttonAdd_Click(object sender, EventArgs e) { AgentSet agentSet = new AgentSet(); agentSet.FirstName = textBoxFirstName.Text; agentSet.LastName = textBoxLastName.Text; agentSet.MiddleName = textBoxMiddleName.Text; agentSet.Phone = textBoxPhone.Text; agentSet.Salary = Convert.ToInt32(textBoxSalary.Text); agentSet.PersentSales = Convert.ToDouble(textBoxPercentSales.Text); Program.lazur.AgentSet.Add(agentSet); Program.lazur.SaveChanges(); ShowAgent(); }
private void buttonEdit_Click(object sender, EventArgs e) { if (listViewAgent.SelectedItems.Count == 1) { AgentSet agentSet = listViewAgent.SelectedItems[0].Tag as AgentSet; agentSet.FirstName = textBoxFirstName.Text; agentSet.LastName = textBoxLastName.Text; agentSet.MiddleName = textBoxMiddleName.Text; agentSet.Phone = textBoxPhone.Text; agentSet.Salary = Convert.ToInt32(textBoxSalary.Text); agentSet.PersentSales = Convert.ToDouble(textBoxPercentSales.Text); Program.lazur.SaveChanges(); ShowAgent(); } }
private void listViewAgent_SelectedIndexChanged(object sender, EventArgs e) { if (listViewAgent.SelectedItems.Count == 1) { AgentSet agentSet = listViewAgent.SelectedItems[0].Tag as AgentSet; textBoxFirstName.Text = agentSet.FirstName; textBoxLastName.Text = agentSet.LastName; textBoxMiddleName.Text = agentSet.MiddleName; textBoxPhone.Text = agentSet.Phone; textBoxSalary.Text = agentSet.Salary.ToString(); textBoxPercentSales.Text = agentSet.PersentSales.ToString(); } else { textBoxFirstName.Text = ""; textBoxLastName.Text = ""; textBoxMiddleName.Text = ""; textBoxPhone.Text = ""; textBoxSalary.Text = ""; textBoxPercentSales.Text = ""; } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (listViewAgent.SelectedItems.Count == 1) { AgentSet agentSet = listViewAgent.SelectedItems[0].Tag as AgentSet; Program.lazur.AgentSet.Remove(agentSet); Program.lazur.SaveChanges(); ShowAgent(); } textBoxFirstName.Text = ""; textBoxLastName.Text = ""; textBoxMiddleName.Text = ""; textBoxPhone.Text = ""; textBoxSalary.Text = ""; textBoxPercentSales.Text = ""; } catch { MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }