private void listViewHouse_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewHouse.SelectedItems.Count == 1)
     {
         DemandSet demand = listViewHouse.SelectedItems[0].Tag as DemandSet;
         comboBoxAgent.SelectedIndex  = comboBoxAgent.FindString(demand.IdAgent.ToString());
         comboBoxClient.SelectedIndex = comboBoxClient.FindString(demand.IdClient.ToString());
         textBoxMinPrice.Text         = demand.MinPrice.ToString();
         textBoxMaxPrice.Text         = demand.MaxPrice.ToString();
         textBoxMinArea.Text          = demand.MinArea.ToString();
         textBoxMaxArea.Text          = demand.MaxArea.ToString();
         textBoxMinFloors.Text        = demand.MinFloors.ToString();
         textBoxMaxFloors.Text        = demand.MaxFloors.ToString();
     }
     else
     {
         comboBoxAgent.SelectedItem  = null;
         comboBoxClient.SelectedItem = null;
         textBoxMinArea.Text         = "";
         textBoxMaxArea.Text         = "";
         textBoxMinPrice.Text        = "";
         textBoxMaxPrice.Text        = "";
         textBoxMinFloors.Text       = "";
         textBoxMaxFloors.Text       = "";
     }
 }
Example #2
0
        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 (comboBoxType.SelectedIndex == 0)
            {
                if (listViewApartment.SelectedItems.Count == 1)
                {
                    DemandSet demand = listViewApartment.SelectedItems[0].Tag as DemandSet;
                    demand.IdAgent  = Convert.ToInt32(comboBoxAgent.SelectedItem.ToString().Split('.')[0]);
                    demand.IdClient = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
                    demand.MinPrice = Convert.ToInt32(textBoxMinPrice.Text);
                    demand.MaxPrice = Convert.ToInt32(textBoxMaxPrice.Text);
                    demand.MinArea  = Convert.ToInt32(textBoxMinArea.Text);
                    demand.MaxArea  = Convert.ToInt32(textBoxMaxArea.Text);
                    demand.MinRooms = Convert.ToInt32(textBoxMinRooms.Text);
                    demand.MaxRooms = Convert.ToInt32(textBoxMaxRooms.Text);
                    demand.MinFloor = Convert.ToInt32(textBoxMinFloor.Text);
                    demand.MaxFloor = Convert.ToInt32(textBoxMaxFloor.Text);
                    Program.wftDb.SaveChanges();
                    ShowDemands();
                }
            }
            if (comboBoxType.SelectedIndex == 1)
            {
                if (listViewHouse.SelectedItems.Count == 1)
                {
                    DemandSet demand = listViewHouse.SelectedItems[0].Tag as DemandSet;

                    demand.IdAgent   = Convert.ToInt32(comboBoxAgent.SelectedItem.ToString().Split('.')[0]);
                    demand.IdClient  = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
                    demand.MinPrice  = Convert.ToInt32(textBoxMinPrice.Text);
                    demand.MaxPrice  = Convert.ToInt32(textBoxMaxPrice.Text);
                    demand.MinArea   = Convert.ToInt32(textBoxMinArea.Text);
                    demand.MaxArea   = Convert.ToInt32(textBoxMaxArea.Text);
                    demand.MinFloors = Convert.ToInt32(textBoxMinFloors.Text);
                    demand.MaxFloors = Convert.ToInt32(textBoxMaxFloors.Text);
                    Program.wftDb.SaveChanges();
                    ShowDemands();
                }
            }
            else
            {
                if (listViewLand.SelectedItems.Count == 1)
                {
                    DemandSet demand = listViewLand.SelectedItems[0].Tag as DemandSet;
                    demand.IdAgent  = Convert.ToInt32(comboBoxAgent.SelectedItem.ToString().Split('.')[0]);
                    demand.IdClient = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
                    demand.MinPrice = Convert.ToInt32(textBoxMinPrice.Text);
                    demand.MaxPrice = Convert.ToInt32(textBoxMaxPrice.Text);
                    demand.MinArea  = Convert.ToInt32(textBoxMinArea.Text);
                    demand.MaxArea  = Convert.ToInt32(textBoxMaxArea.Text);
                    Program.wftDb.SaveChanges();
                    ShowDemands();
                }
            }
        }
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (comboBoxAgent.SelectedItem != null && comboBoxClient.SelectedItem != null && comboBoxType.SelectedItem != null)
     {
         DemandSet demand = new DemandSet();
         demand.IdAgent  = Convert.ToInt32(comboBoxAgent.SelectedItem.ToString().Split('.')[0]);
         demand.IdClient = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
         demand.MinPrice = Convert.ToInt32(textBoxMinPrice.Text);
         demand.MaxPrice = Convert.ToInt32(textBoxMaxPrice.Text);
         demand.MinArea  = Convert.ToInt32(textBoxMinArea.Text);
         demand.MaxArea  = Convert.ToInt32(textBoxMaxArea.Text);
         if (comboBoxType.SelectedIndex == 0)
         {
             demand.Type     = 0;
             demand.MinRooms = Convert.ToInt32(textBoxMinRooms.Text);
             demand.MinFloor = Convert.ToInt32(textBoxMinFloor.Text);
             demand.MaxRooms = Convert.ToInt32(textBoxMaxRooms.Text);
             demand.MaxFloor = Convert.ToInt32(textBoxMaxFloor.Text);
         }
         else if (comboBoxType.SelectedIndex == 1)
         {
             demand.Type      = 1;
             demand.MinFloors = Convert.ToInt32(textBoxMinFloors.Text);
             demand.MaxFloors = Convert.ToInt32(textBoxMaxFloors.Text);
         }
         else
         {
             demand.Type = 2;
         }
         Program.wftDb.DemandSet.Add(demand);
         Program.wftDb.SaveChanges();
         ShowDemands();
     }
     else
     {
         MessageBox.Show("Данные не выбраны", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (comboBoxType.SelectedIndex == 0)
         {
             if (listViewApartment.SelectedItems.Count == 1)
             {
                 DemandSet demand = listViewApartment.SelectedItems[0].Tag as DemandSet;
                 Program.wftDb.DemandSet.Remove(demand);
                 Program.wftDb.SaveChanges();
                 ShowDemands();
             }
             comboBoxAgent.SelectedItem  = null;
             comboBoxClient.SelectedItem = null;
             textBoxMinArea.Text         = "";
             textBoxMaxArea.Text         = "";
             textBoxMinPrice.Text        = "";
             textBoxMaxPrice.Text        = "";
             textBoxMinRooms.Text        = "";
             textBoxMaxRooms.Text        = "";
             textBoxMinFloor.Text        = "";
             textBoxMaxFloor.Text        = "";
         }
         else if (comboBoxType.SelectedIndex == 1)
         {
             if (listViewHouse.SelectedItems.Count == 1)
             {
                 DemandSet demand = listViewHouse.SelectedItems[0].Tag as DemandSet;
                 Program.wftDb.DemandSet.Remove(demand);
                 Program.wftDb.SaveChanges();
                 ShowDemands();
             }
             comboBoxAgent.SelectedItem  = null;
             comboBoxClient.SelectedItem = null;
             textBoxMinArea.Text         = "";
             textBoxMaxArea.Text         = "";
             textBoxMinPrice.Text        = "";
             textBoxMaxPrice.Text        = "";
             textBoxMinFloors.Text       = "";
             textBoxMaxFloors.Text       = "";
         }
         else
         {
             if (listViewLand.SelectedItems.Count == 1)
             {
                 DemandSet demand = listViewLand.SelectedItems[0].Tag as DemandSet;
                 Program.wftDb.DemandSet.Remove(demand);
                 Program.wftDb.SaveChanges();
                 ShowDemands();
             }
             comboBoxAgent.SelectedItem  = null;
             comboBoxClient.SelectedItem = null;
             textBoxMinArea.Text         = "";
             textBoxMaxArea.Text         = "";
             textBoxMinPrice.Text        = "";
             textBoxMaxPrice.Text        = "";
         }
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }