void Deductions() { if (comboBoxSupply.SelectedItem != null && comboBoxDemand.SelectedItem != null) { SupplySet supply = Program.wftDb.SupplySet.Find(Convert.ToInt32(comboBoxSupply.SelectedItem.ToString().Split('.')[0])); DemandSet demand = Program.wftDb.DemandSet.Find(Convert.ToInt32(comboBoxDemand.SelectedItem.ToString().Split('.')[0])); double customerCompanyDeductions = supply.Price * 0.03; textBoxCustomerCompanyDeduction.Text = customerCompanyDeductions.ToString("0.00"); if (demand.иелтор.DealShare != null) { double agentCustomerDeductions = customerCompanyDeductions * Convert.ToDouble(demand.иелтор.DealShare) / 100.00; textBoxAgentCustomerDeduction.Text = agentCustomerDeductions.ToString("0.00"); } else { double agentCustomerDeductions = customerCompanyDeductions * 0.45; textBoxAgentCustomerDeduction.Text = agentCustomerDeductions.ToString("0.00"); } } else { textBoxCustomerCompanyDeduction.Text = ""; textBoxAgentCustomerDeduction.Text = ""; } if (comboBoxSupply.SelectedItem != null) { SupplySet supply = Program.wftDb.SupplySet.Find(Convert.ToInt32(comboBoxSupply.SelectedItem.ToString().Split('.')[0])); double sallerCompanyDeductions; if (supply.Недвижимость.Type == 0) { sallerCompanyDeductions = 36000 + supply.Price * 0.01; textBoxSallerCompanyDeduction.Text = sallerCompanyDeductions.ToString("0.00"); } else if (supply.Недвижимость.Type == 1) { sallerCompanyDeductions = 30000 + supply.Price * 0.01; textBoxSallerCompanyDeduction.Text = sallerCompanyDeductions.ToString("0.00"); } else { sallerCompanyDeductions = 30000 + supply.Price * 0.02; textBoxSallerCompanyDeduction.Text = sallerCompanyDeductions.ToString("0.00"); } if (supply.иелтор.DealShare != null) { double agentSallerDeductions = sallerCompanyDeductions * 0.45; textBoxAgentSallerDeduction.Text = agentSallerDeductions.ToString("0.00"); } else { textBoxSallerCompanyDeduction.Text = ""; textBoxAgentSallerDeduction.Text = ""; textBoxCustomerCompanyDeduction.Text = ""; textBoxAgentCustomerDeduction.Text = ""; } } }
private void buttonEdit_Click(object sender, EventArgs e) { if (listViewSupply.SelectedItems.Count == 1) { SupplySet supply = listViewSupply.SelectedItems[0].Tag as SupplySet; supply.IdAgent = Convert.ToInt32(comboBoxAgent.SelectedItem.ToString().Split('.')[0]); supply.IdClient = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]); supply.IdRealEstate = Convert.ToInt32(comboBoxRealEstate.SelectedItem.ToString().Split('.')[0]); supply.Price = Convert.ToInt64(textBoxPrice.Text); Program.wftDb.SaveChanges(); ShowSupplySet(); } }
private void buttonAdd_Click(object sender, EventArgs e) { if (comboBoxAgent.SelectedItem != null && comboBoxClient.SelectedItem != null && comboBoxRealEstate.SelectedItem != null && textBoxPrice.Text != "") { SupplySet supply = new SupplySet(); supply.IdAgent = Convert.ToInt32(comboBoxAgent.SelectedItem.ToString().Split('.')[0]); supply.IdClient = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]); supply.IdRealEstate = Convert.ToInt32(comboBoxRealEstate.SelectedItem.ToString().Split('.')[0]); supply.Price = Convert.ToInt64(textBoxPrice.Text); Program.wftDb.SupplySet.Add(supply); Program.wftDb.SaveChanges(); ShowSupplySet(); } else { MessageBox.Show("Данные не выбраны", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void listViewSupply_SelectedIndexChanged(object sender, EventArgs e) { if (listViewSupply.SelectedItems.Count == 1) { SupplySet supply = listViewSupply.SelectedItems[0].Tag as SupplySet; comboBoxAgent.SelectedIndex = comboBoxAgent.FindString(supply.IdAgent.ToString()); comboBoxClient.SelectedIndex = comboBoxClient.FindString(supply.IdClient.ToString()); comboBoxRealEstate.SelectedIndex = comboBoxRealEstate.FindString(supply.IdRealEstate.ToString()); textBoxPrice.Text = supply.Price.ToString(); } else { comboBoxAgent.SelectedItem = null; comboBoxClient.SelectedItem = null; comboBoxRealEstate.SelectedItem = null; textBoxPrice.Text = ""; } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (listViewSupply.SelectedItems.Count == 1) { SupplySet supply = listViewSupply.SelectedItems[0].Tag as SupplySet; Program.wftDb.SupplySet.Remove(supply); Program.wftDb.SaveChanges(); } comboBoxAgent.SelectedItem = null; comboBoxClient.SelectedItem = null; comboBoxRealEstate.SelectedItem = null; textBoxPrice.Text = ""; } catch { MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }