void Deductions() { if (comboBoxSupply.SelectedItem != null && comboBoxDemand.SelectedItem != null) { SupplySet supplySet = Program.RPE.SupplySet.Find(Convert.ToInt32(comboBoxSupply.SelectedItem.ToString().Split('.')[0])); DemandSet demandSet = Program.RPE.DemandSet.Find(Convert.ToInt32(comboBoxDemand.SelectedItem.ToString().Split('.')[0])); double customerCompanyDeductions = supplySet.Price * 0.03; textCustomerCompanyDeductions.Text = customerCompanyDeductions.ToString("0.00"); if (demandSet.AgentsSet.DealShare != null) { double agentCustomerDeductions = customerCompanyDeductions * Convert.ToDouble(demandSet.AgentsSet.DealShare) / 100.00; textBoxAgentCustomerDeductions.Text = agentCustomerDeductions.ToString("0.00"); } else { double agentCustomerDeductions = customerCompanyDeductions * 0.45; textBoxAgentCustomerDeductions.Text = agentCustomerDeductions.ToString("0.00"); } } else { textCustomerCompanyDeductions.Text = ""; textBoxAgentCustomerDeductions.Text = ""; } if (comboBoxSupply.SelectedItem != null) { SupplySet supplySet = Program.RPE.SupplySet.Find(Convert.ToInt32(comboBoxSupply.SelectedItem.ToString().Split('.')[0])); double sellerCompanyDeductions; if (supplySet.RealEstateSet.Type == 0) { sellerCompanyDeductions = 36000 + supplySet.Price * 0.01; textBoxSellerCompanyDeductions.Text = sellerCompanyDeductions.ToString("0.00"); } else if (supplySet.RealEstateSet.Type == 1) { sellerCompanyDeductions = 30000 + supplySet.Price * 0.01; textBoxSellerCompanyDeductions.Text = sellerCompanyDeductions.ToString("0.00"); } else { sellerCompanyDeductions = 30000 + supplySet.Price * 0.02; textBoxSellerCompanyDeductions.Text = sellerCompanyDeductions.ToString("0.00"); } if (supplySet.AgentsSet.DealShare != null) { double agentSellerDeductions = sellerCompanyDeductions * Convert.ToDouble(supplySet.AgentsSet.DealShare) / 100.00; textBoxAgentSellerDeductions.Text = agentSellerDeductions.ToString("0.00"); } else { double agentSellerDeductins = sellerCompanyDeductions * 0.45; textBoxAgentSellerDeductions.Text = agentSellerDeductins.ToString("0.00"); } } }
private void buttonEdit_Click(object sender, EventArgs e) { if (listViewSupplySet.SelectedItems.Count == 1) { SupplySet supply = listViewSupplySet.SelectedItems[0].Tag as SupplySet; supply.idAgent = Convert.ToInt32(comboBoxAgents.SelectedItem.ToString().Split('.')[0]); supply.idClient = Convert.ToInt32(comboBoxClients.SelectedItem.ToString().Split('.')[0]); supply.idRealEstate = Convert.ToInt32(comboBoxRealEstate.ToString().Split('.')[0]); supply.Price = Convert.ToInt64(textBoxPrice.Text); Program.RPE.SaveChanges(); ShowSupplySet(); } }
private void buttonAdd_Click(object sender, EventArgs e) { if (comboBoxAgents.SelectedItem != null && comboBoxClients.SelectedItem != null && comboBoxRealEstate != null && textBoxPrice.Text != "") { SupplySet supply = new SupplySet(); supply.idAgent = Convert.ToInt32(comboBoxAgents.SelectedItem.ToString().Split('.')[0]); supply.idClient = Convert.ToInt32(comboBoxClients.SelectedItem.ToString().Split('.')[0]); supply.idRealEstate = Convert.ToInt32(comboBoxRealEstate.SelectedItem.ToString().Split('.')[0]); supply.Price = Convert.ToInt64(textBoxPrice.Text); Program.RPE.SupplySet.Add(supply); Program.RPE.SaveChanges(); ShowSupplySet(); } else { MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (listViewSupplySet.SelectedItems.Count == 1) { SupplySet supply = listViewSupplySet.SelectedItems[0].Tag as SupplySet; Program.RPE.SupplySet.Remove(supply); Program.RPE.SaveChanges(); ShowSupplySet(); } comboBoxAgents.SelectedItem = null; comboBoxClients.SelectedItem = null; comboBoxRealEstate.SelectedItem = null; textBoxPrice.Text = ""; } catch { MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }