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.wftDb.SupplySet.Add(supply); // Program.wftDb.SaveChanges(); ShowSupplySet(); } else { MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
void Deductions() { if (comboBoxSupply.SelectedItem != null && comboBoxDemand.SelectedItem != null) { SupplySet supplySet = 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 = supplySet.Price * 0.03; textBoxCustomerCompanyDeductions.Text = customerCompanyDeductions.ToString("0.00"); if (demand.AgentSet.DealShare != null) { double agentCustomerDeductions = customerCompanyDeductions * Convert.ToDouble(demand.AgentSet.DealShare) / 100.00; textBoxAgentCustomerDeductions.Text = agentCustomerDeductions.ToString("0.00"); } else { double agentCustomerDeductions = customerCompanyDeductions * 0.45; textBoxAgentCustomerDeductions.Text = agentCustomerDeductions.ToString("0.00"); } } if (comboBoxSupply.SelectedItem != null) { SupplySet supplySet = Program.wftDb.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 = 38000 + supplySet.Price * 0.01; textBoxSellerCompanyDeductions.Text = sellerCompanyDeductions.ToString("0.00"); } else { sellerCompanyDeductions = 38000 + supplySet.Price * 0.02; textBoxSellerCompanyDeductions.Text = sellerCompanyDeductions.ToString("0.00"); } if (supplySet.AgentSet.DealShare != null) { double agentSellerDeductions = sellerCompanyDeductions * Convert.ToDouble(supplySet.AgentSet.DealShare) / 100.00; textBoxAgentSellerDeductions.Text = agentSellerDeductions.ToString("0.00"); } else { double agentSellerDeductions = sellerCompanyDeductions * 0.45; textBoxAgentSellerDeductions.Text = agentSellerDeductions.ToString("0.00"); } } else { textBoxSellerCompanyDeductions.Text = ""; textBoxAgentSellerDeductions.Text = ""; textBoxCustomerCompanyDeductions.Text = ""; textBoxAgentCustomerDeductions.Text = ""; } }
private void buttonDel_Click(object sender, EventArgs e) { //пробуем совершить действие try { //если в listView выбран элемент if (listViewSupplySet.SelectedItems.Count == 1) { //ищем элемент из таблицы по тегу SupplySet supply = listViewSupplySet.SelectedItems[0].Tag as SupplySet; //удаляем из модели БД Program.wftDb.SupplySet.Remove(supply); //сохраняем изменения Program.wftDb.SaveChanges(); //отображаем обновленный список ShowSupplySet(); } //очищаем все поля comboBoxAgents.SelectedItem = null; comboBoxClients.SelectedItem = null; comboBoxRealEstate.SelectedItem = null; textBoxPrice.Text = ""; } //если возникает какая-то ошибка catch { MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void buttonAdd_Click(object sender, EventArgs e) { if (comboBoxAgents.SelectedItem != null && comboBoxClients.SelectedItem != null && comboBoxRealEstates.SelectedItem != null && textBoxPrice.Text != "") { //Новый экземпляр класса Предложение SupplySet supply = new SupplySet(); //Из выбранной строки в comboBoxAgents отделяем ID риелтора(после него точка) и делаем ссылку supply.IdAgent supply.IdAgent = Convert.ToInt32(comboBoxAgents.SelectedItem.ToString().Split('.')[0]); //Так же отделяем ID клиента supply.IdClient = Convert.ToInt32(comboBoxClients.SelectedItem.ToString().Split('.')[0]); //И ID недвижимости supply.IdRealEstate = Convert.ToInt32(comboBoxRealEstates.SelectedItem.ToString().Split('.')[0]); //Цена на недвижимость обычно большая, лучше хранить в Int64 supply.Price = Convert.ToInt64(textBoxPrice.Text); //Добавляем новое предложение supply в таблицу SupplySet Program.wftDB.SupplySet.Add(supply); //Сохраняем изменения Program.wftDB.SaveChanges(); ShowSupplySet(); } else { MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void buttonAdd_Click(object sender, EventArgs e) { //проверяем, что все поля (раскрывающихся списков и текстового поля) были заполнены if (comboBoxAgents.SelectedItem != null && comboBoxClients.SelectedItem != null && comboBoxRealEstate != null && textBoxPrice.Text != "") { //создаем новый экземпляр класса Предложение SupplySet supply = new SupplySet(); //из выбранной строки в comboBoxAgents отделяем Id риелтора (он отделен точкой) и делаем ссылку supply.IdAgent supply.idAgent = Convert.ToInt32(comboBoxAgents.SelectedItem.ToString().Split('.')[0]); //точно такжем отделяем и заносим id клиента supply.idClient = Convert.ToInt32(comboBoxClients.SelectedItem.ToString().Split('.')[0]); //отделяем и заносим id объекта недвижимости supply.idRealEstate = Convert.ToInt32(comboBoxRealEstate.SelectedItem.ToString().Split('.')[0]); //цена объекта недвижимости чаще всего превосходит миллион, поэтому используем Int64 supply.Price = Convert.ToInt64(textBoxPrice.Text); //добавляем в таблицу SupplySet новый объект недвижимости supply Program.wftDb.SupplySet.Add(supply); //сохраняем изменения в модели wftDb Program.wftDb.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.wftDb.SupplySet.Remove(supply); // Program.wftDb.SaveChanges(); // ShowSupplySet(); } // comboBoxAgents.SelectedItem = null; comboBoxClients.SelectedItem = null; comboBoxRealEstate.SelectedItem = null; textBoxPrice.Text = ""; } catch { MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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.wftDb.SupplySet.Add(supply); Program.wftDb.SaveChanges(); }
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.SelectedItem.ToString().Split('.')[0]); supply.Price = Convert.ToInt64(textBoxPrice.Text); Program.wftDb.SaveChanges(); ShowSupplySet(); } }
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(comboBoxRealEstates.SelectedItem.ToString().Split('.')[0]); supply.Price = Convert.ToInt64(textBoxPrice.Text); //Сохраняем изменения Program.wftDB.SaveChanges(); ShowSupplySet(); } }
private void listViewSupplySet_SelectedIndexChanged(object sender, EventArgs e) { if (listViewSupplySet.SelectedItems.Count == 1) { SupplySet supply = listViewSupplySet.SelectedItems[0].Tag as SupplySet; comboBoxAgents.SelectedIndex = comboBoxAgents.FindString(supply.IdAgent.ToString()); comboBoxClients.SelectedIndex = comboBoxClients.FindString(supply.IdClient.ToString()); comboBoxRealEstate.SelectedIndex = comboBoxRealEstate.FindString(supply.IdRealEstate.ToString()); } else { comboBoxAgents.SelectedItem = null; comboBoxClients.SelectedItem = null; comboBoxRealEstate.SelectedItem = null; textBoxPrice.Text = ""; } }
private void buttonEdit_Click(object sender, EventArgs e) { //если в listView выбран элемент 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.SelectedItem.ToString().Split('.')[0]); supply.Price = Convert.ToInt64(textBoxPrice.Text); //сохраняем изменения в модели wftDb Program.wftDb.SaveChanges(); ShowSupplySet(); } }
private void buttonAdd_Click(object sender, EventArgs e) { if (comboBoxAgents.SelectedItem != null && comboBoxClients.SelectedItem != null && comboBoxRealEstate.SelectedItem != null && textBoxPrice.Text != " ") {//создаем новый эл в класс предложений SupplySet supply = new SupplySet(); //отделяем id и делаем ссылку на суппле 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.wftDB.SupplySet.Add(supply); Program.wftDB.SaveChanges(); ShowSupplySet(); } else { MessageBox.Show("данные не выбраны", "ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void buttonEdit_Click(object sender, EventArgs e) { if (comboBoxAgents.SelectedItem != null && comboBoxClients.SelectedItem != null && comboBoxRealEstate.SelectedItem != null && textBoxPrice.Text != " ") { 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.SelectedItem.ToString().Split('.')[0]); supply.Price = Convert.ToInt64(textBoxPrice.Text); Program.wftDB.SaveChanges(); ShowSupplySet(); } } else { MessageBox.Show("данные не выбраны", "ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void listViewSupplySet_SelectedIndexChanged(object sender, EventArgs e) { if (listViewSupplySet.SelectedItems.Count == 1) { SupplySet supply = listViewSupplySet.SelectedItems[0].Tag as SupplySet; //находим в comboBoxAgents необходимую строку по Id риелтора и задаём её отображение comboBox-у comboBoxAgents.SelectedIndex = comboBoxAgents.FindString(supply.IdAgent.ToString()); //точно так же поступаем с comboBoxClients и comboBoxRealEstate comboBoxClients.SelectedIndex = comboBoxClients.FindString(supply.IdClient.ToString()); comboBoxRealEstate.SelectedIndex = comboBoxRealEstate.FindString(supply.IdRealEstate.ToString()); textBoxPrice.Text = supply.Price.ToString(); } else { comboBoxAgents.SelectedItem = null; comboBoxClients.SelectedItem = null; comboBoxRealEstate.SelectedItem = null; textBoxPrice.Text = ""; } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (listViewSupplySet.SelectedItems.Count == 1) { SupplySet supply = listViewSupplySet.SelectedItems[0].Tag as SupplySet; Program.wftDB.SupplySet.Remove(supply); Program.wftDB.SaveChanges(); ShowSupplySet(); } comboBoxAgents.SelectedItem = null; comboBoxClients.SelectedItem = null; comboBoxRealEstate.SelectedItem = null; } catch { MessageBox.Show("данные не удаляются", "ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void listViewSupplySet_SelectedIndexChanged(object sender, EventArgs e) { if (listViewSupplySet.SelectedItems.Count == 1) { //Ищем элемент по тегу SupplySet supply = listViewSupplySet.SelectedItems[0].Tag as SupplySet; //Ищем в comboBoxAgents строку по ID риелтора и отображаем её comboBoxAgents.SelectedIndex = comboBoxAgents.FindString(supply.IdAgent.ToString()); //Тоже для comboBoxClients и comboBoxRealEstates comboBoxClients.SelectedIndex = comboBoxClients.FindString(supply.IdClient.ToString()); comboBoxRealEstates.SelectedIndex = comboBoxRealEstates.FindString(supply.IdRealEstate.ToString()); textBoxPrice.Text = supply.Price.ToString(); } else { comboBoxAgents.SelectedItem = null; comboBoxClients.SelectedItem = null; comboBoxRealEstates.SelectedItem = null; textBoxPrice.Text = ""; } }
private void buttonEdit_Click(object sender, EventArgs e) { if (listViewSupplySet.SelectedItems.Count == 1) { try { SupplySet supply = listViewSupplySet.SelectedItems[0].Tag as SupplySet; if (comboBoxAgents.Text == "" || comboBoxClients.Text == "" || comboBoxRealEstate.Text == "" || textBoxPrice.Text == "") { throw new Exception("Обязательные поля не были заполнены!"); } 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.wftDb.SaveChanges(); ShowSupplySet(); } catch (Exception ex) { MessageBox.Show("" + ex.Message, "Внимание!", 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.wftDB.SupplySet.Remove(supply); //Сохраняем изменения Program.wftDB.SaveChanges(); //Обновляем список ShowSupplySet(); } } catch { MessageBox.Show("Невозможно удалить запись, возможно она используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void buttonAdd_Click(object sender, EventArgs e) { //проверяем, все ли поля заполнены if (comboBoxAgents.SelectedItem != null && comboBoxClients != null && comboBoxRealEstate != null && textBoxPrice.Text != "") { //создаём новый экземпляр класса предложение SupplySet supply = new SupplySet(); //из выбранных строк в comboBox-ах отделяем Id риелтора( он отделён точкой) и делаем ссылку в supply.IdAgent supply.IdAgent = Convert.ToInt32(comboBoxAgents.SelectedItem.ToString().Split('.')[0]); supply.IdClient = Convert.ToInt32(comboBoxClients.SelectedItem.ToString().Split('.')[0]); //отделяем и заносим Id объекта недвижимости supply.IdRealEstate = Convert.ToInt32(comboBoxRealEstate.SelectedItem.ToString().Split('.')[0]); //цена объекта недвижимости чаще всего превосходит миллион, поэтому исп. Int64 supply.Price = Convert.ToInt64(textBoxPrice.Text); Program.epDb.SupplySet.Add(supply); Program.epDb.SaveChanges(); ShowSupplySet(); } else { MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void listViewSupplySet_SelectedIndexChanged(object sender, EventArgs e) { //если в listView выбран элемент if (listViewSupplySet.SelectedItems.Count == 1) { //ищем элемент из таблицы по тегу SupplySet supply = listViewSupplySet.SelectedItems[0].Tag as SupplySet; //указываем, что может быть изменено //находим в comboBoxAgents необходимую строку по id риелтора из supply.idAgent и задаем ее отображение comboBox-у comboBoxAgents.SelectedIndex = comboBoxAgents.FindString(supply.idAgent.ToString()); //точно также поступаем с comboBoxClients и comboBoxRealEstate comboBoxClients.SelectedIndex = comboBoxClients.FindString(supply.idClient.ToString()); comboBoxRealEstate.SelectedIndex = comboBoxRealEstate.FindString(supply.idRealEstate.ToString()); textBoxPrice.Text = supply.Price.ToString(); } else { //если не выбран ни один элемент, то задаем пустые элементы comboBoxAgents.SelectedItem = null; comboBoxClients.SelectedItem = null; comboBoxRealEstate.SelectedItem = null; textBoxPrice.Text = ""; } }
void Deductions() { if (comboBoxSupply.SelectedItem != null && comboBoxDemand.SelectedItem != null) { //Находим в базе предложение и потребность с выбраными номерами SupplySet supplySet = Program.wftDB.SupplySet.Find(Convert.ToInt32(comboBoxSupply.SelectedItem.ToString().Split('.')[0])); DemandSet demandSet = Program.wftDB.DemandSet.Find(Convert.ToInt32(comboBoxDemand.SelectedItem.ToString().Split('.')[0])); //Расчитываем отчисления компании для клиента-покупателя (3% от стоимости) и выводим в textBoxCustomerCompanyDeductions double customerCompanyDeductions = supplySet.Price * 0.03; textBoxCustomerCompanyDeductions.Text = customerCompanyDeductions.ToString("0.00"); //Расчитываем отчисления риелтору для клиента-покупателя (комиссия указана в AgentsSet) и выводим в textBoxAgentCustomerDeductions if (demandSet.AgentsSet.Share != 0) { double AgentCustomerDeductions = customerCompanyDeductions * Convert.ToDouble(demandSet.AgentsSet.Share) / 100.00; textBoxAgentCustomerDeductions.Text = AgentCustomerDeductions.ToString("0.00"); } //Если же комиссия не указана, берем 45% else { double AgentCustomerDeductions = customerCompanyDeductions * 0.45; textBoxAgentCustomerDeductions.Text = AgentCustomerDeductions.ToString("0.00"); } } else { textBoxCustomerCompanyDeductions.Text = ""; textBoxAgentCustomerDeductions.Text = ""; } if (comboBoxSupply.SelectedItem != null) { //Находим в базе предложение c выбраным номером SupplySet supplySet = Program.wftDB.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"); } //Расчитываем отчисления риелтору для клиента-продавца (комиссия указана в AgentsSet) и выводим в textBoxAgentSellerDeductions if (supplySet.AgentsSet.Share != 0) { double AgentSellerDeductions = sellerCompanyDeductions * Convert.ToDouble(supplySet.AgentsSet.Share) / 100.00; textBoxAgentSellerDeductions.Text = AgentSellerDeductions.ToString("0.00"); } //Если же комиссия не указана, берем 45% else { double AgentSellerDeductions = sellerCompanyDeductions * 0.45; textBoxAgentSellerDeductions.Text = AgentSellerDeductions.ToString("0.00"); } } else { textBoxCustomerCompanyDeductions.Text = ""; textBoxAgentCustomerDeductions.Text = ""; textBoxAgentSellerDeductions.Text = ""; textBoxSellerCompanyDeductions.Text = ""; } }
void Deductions() { if (comboBoxSupply.SelectedItem != null && comboBoxDemand.SelectedItem != null) { //находим в базе предложение и потребность с выбранными номерами SupplySet supplySet = Program.wftDb.SupplySet.Find(Convert.ToInt32(comboBoxSupply.SelectedItem.ToString().Split('.')[0])); DemandSet demandSet = Program.wftDb.DemandSet.Find(Convert.ToInt32(comboBoxDemand.SelectedItem.ToString().Split('.')[0])); //расчитываем отчисления компании для клиента-покупателя (3% от стоимости недвижимости), выводим в textCustomerCompanyDeductions double customerCompanyDeductions = supplySet.Price * 0.03; textCustomerCompanyDeductions.Text = customerCompanyDeductions.ToString("0.00"); //расчитываем отчисления компании для клиента-покупателя (комиссия указана в таблице AgentsSet), выводим в textBoxAgentCustomerDeductions if (demandSet.AgentsSet.Share != null) { double agentCustomerDeductions = customerCompanyDeductions * Convert.ToDouble(demandSet.AgentsSet.Share) / 100.00; textBoxAgentCustomerDeductions.Text = agentCustomerDeductions.ToString("0.00"); } else { //если комиссия не указана, то автоматически берется 45% double agentCustomerDeductions = customerCompanyDeductions * 0.45; textBoxAgentCustomerDeductions.Text = agentCustomerDeductions.ToString("0.00"); } } else { textCustomerCompanyDeductions.Text = ""; textBoxAgentCustomerDeductions.Text = ""; } if (comboBoxSupply.SelectedItem != null) { //находим в базе предложение с выбранным номером SupplySet supplySet = Program.wftDb.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"); } //расчитываем отчисления риелтору для клиент-покупателя (комиссия указана в таблице AgentsSet) if (supplySet.AgentsSet.Share != null) { double agentSellerDeductions = sellerCompanyDeductions * Convert.ToDouble(supplySet.AgentsSet.Share) / 100.00; textBoxAgentSellerDeductions.Text = agentSellerDeductions.ToString("0.00"); } else { //если комиссия не указана, то автоматически берется 45% double agentSellerDeductions = sellerCompanyDeductions * 0.45; textBoxAgentSellerDeductions.Text = agentSellerDeductions.ToString("0.00"); } } else { textBoxSellerCompanyDeductions.Text = ""; textBoxAgentSellerDeductions.Text = ""; textCustomerCompanyDeductions.Text = ""; textBoxAgentCustomerDeductions.Text = ""; } }