Beispiel #1
0
        private void listViewDemandSet_Apartment_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewDemandSet_Apartment.SelectedItems.Count == 1)
            {
                DemandSet demand = listViewDemandSet_Apartment.SelectedItems[0].Tag as DemandSet;

                comboBoxAgent.SelectedIndex  = comboBoxAgent.FindString(demand.IdAgent.ToString());
                comboBoxClient.SelectedIndex = comboBoxClient.FindString(demand.IdClient.ToString());
                textBoxMinArea.Text          = demand.MinArea.ToString();
                textBoxMaxArea.Text          = demand.MaxArea.ToString();
                textBoxMinPrice.Text         = demand.MinPrice.ToString();
                textBoxMaxPrice.Text         = demand.MaxPrice.ToString();
                textBoxMinRooms.Text         = demand.MinRooms.ToString();
                textBoxMaxRooms.Text         = demand.MaxRooms.ToString();
                textBoxMinFloor.Text         = demand.MinFloor.ToString();
                textBoxMaxFloor.Text         = demand.MaxFloor.ToString();
            }
            else
            {
                textBoxMinArea.Text  = "";
                textBoxMaxArea.Text  = "";
                textBoxMinPrice.Text = "";
                textBoxMaxPrice.Text = "";
                textBoxMinRooms.Text = "";
                textBoxMaxRooms.Text = "";
                textBoxMinFloor.Text = "";
                textBoxMaxFloor.Text = "";
            }
        }
Beispiel #2
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            DemandSet demand = new DemandSet();

            demand.IdAgent  = Convert.ToInt32(comboBoxAgent.SelectedItem.ToString().Split('.')[0]);
            demand.IdClient = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
            demand.MinArea  = Convert.ToDouble(textBoxMinArea.Text);
            demand.MaxArea  = Convert.ToDouble(textBoxMaxArea.Text);
            demand.MinPrice = Convert.ToInt64(textBoxMinPrice.Text);
            demand.MaxPrice = Convert.ToInt64(textBoxMaxPrice.Text);


            if (comboBoxType.SelectedIndex == 0)
            {
                demand.Type     = 0;
                demand.MinRooms = Convert.ToInt32(textBoxMinRooms.Text);
                demand.MaxRooms = Convert.ToInt32(textBoxMaxRooms.Text);
                demand.MinFloor = Convert.ToInt32(textBoxMinFloor.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();
            ShowDemandSet();
        }
Beispiel #3
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (comboBoxType.SelectedIndex == 0)
         {
             if (listViewDemandSet_Apartment.SelectedItems.Count == 1)
             {
                 DemandSet demand = listViewDemandSet_Apartment.SelectedItems[0].Tag as DemandSet;
                 Program.wftDb.DemandSet.Remove(demand);
                 Program.wftDb.SaveChanges();
                 ShowDemandSet();
             }
             textBoxMinArea.Text  = "";
             textBoxMaxArea.Text  = "";
             textBoxMinPrice.Text = "";
             textBoxMaxPrice.Text = "";
             textBoxMinRooms.Text = "";
             textBoxMaxRooms.Text = "";
             textBoxMinFloor.Text = "";
             textBoxMaxFloor.Text = "";
         }
         else if (comboBoxType.SelectedIndex == 1)
         {
             if (listViewDemandSet_House.SelectedItems.Count == 1)
             {
                 DemandSet demand = listViewDemandSet_House.SelectedItems[0].Tag as DemandSet;
                 Program.wftDb.DemandSet.Remove(demand);
                 Program.wftDb.SaveChanges();
                 ShowDemandSet();
             }
             textBoxMinArea.Text   = "";
             textBoxMaxArea.Text   = "";
             textBoxMinPrice.Text  = "";
             textBoxMaxPrice.Text  = "";
             textBoxMinFloors.Text = "";
             textBoxMaxFloors.Text = "";
         }
         else
         {
             if (listViewDemandSet_Land.SelectedItems.Count == 1)
             {
                 DemandSet demand = listViewDemandSet_Land.SelectedItems[0].Tag as DemandSet;
                 Program.wftDb.DemandSet.Remove(demand);
                 Program.wftDb.SaveChanges();
                 ShowDemandSet();
             }
             textBoxMinArea.Text  = "";
             textBoxMaxArea.Text  = "";
             textBoxMinPrice.Text = "";
             textBoxMaxPrice.Text = "";
         }
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись уже используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #4
0
        private void listViewDemandSet_House_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewDemandSet_House.SelectedItems.Count == 1)
            {
                DemandSet demand = listViewDemandSet_House.SelectedItems[0].Tag as DemandSet;

                textBoxMinArea.Text   = demand.MinArea.ToString();
                textBoxMaxArea.Text   = demand.MaxArea.ToString();
                textBoxMinPrice.Text  = demand.MinPrice.ToString();
                textBoxMaxPrice.Text  = demand.MaxPrice.ToString();
                textBoxMinFloors.Text = demand.MinFloors.ToString();
                textBoxMaxFloors.Text = demand.MaxFloors.ToString();
            }
            else
            {
                textBoxMinArea.Text   = "";
                textBoxMaxArea.Text   = "";
                textBoxMinPrice.Text  = "";
                textBoxMaxPrice.Text  = "";
                textBoxMinFloors.Text = "";
                textBoxMaxFloors.Text = "";
            }
        }
Beispiel #5
0
        void Deductions()
        {
            if (comboBoxSupply.SelectedItem != null && comboBoxDemand.SelectedItem != null)
            {
                SupplySet supplySet
                    = Program.wftDb.SupplySet.Find(Convert.ToInt32(comboBoxSupply.SelectedItem.ToString().Split('.')[0]));
                DemandSet demanвSet
                    = Program.wftDb.DemandSet.Find(Convert.ToInt32(comboBoxDemand.SelectedItem.ToString().Split('.')[0]));

                double customerCompanyDeductions = supplySet.Price * 0.03;
                textBoxCustomerCompanyDeductions.Text = customerCompanyDeductions.ToString("0.00");

                if (demanвSet.AgentSet.DealShare != null)
                {
                    double agentCustomerDeductions = customerCompanyDeductions * Convert.ToDouble(demanвSet.AgentSet.DealShare) / 100.00;
                    textBoxAgentCustomerDeductions.Text = agentCustomerDeductions.ToString("0.00");
                }
                else
                {
                    double agentCustomerDeductions = customerCompanyDeductions * 0.45;
                    textBoxAgentCustomerDeductions.Text = agentCustomerDeductions.ToString("0.00");
                }
            }
            else
            {
                textBoxCustomerCompanyDeductions.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");
                }
                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   = "";
            }
        }
Beispiel #6
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (comboBoxType.SelectedIndex == 0)
            {
                if (listViewDemandSet_Apartment.SelectedItems.Count == 1)
                {
                    DemandSet demand = listViewDemandSet_Apartment.SelectedItems[0].Tag as DemandSet;

                    demand.IdAgent  = Convert.ToInt32(comboBoxAgent.SelectedItem.ToString().Split('.')[0]);
                    demand.IdClient = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
                    demand.MinArea  = Convert.ToDouble(textBoxMinArea.Text);
                    demand.MaxArea  = Convert.ToDouble(textBoxMaxArea.Text);
                    demand.MinPrice = Convert.ToInt64(textBoxMinPrice.Text);
                    demand.MaxPrice = Convert.ToInt64(textBoxMaxPrice.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();
                    ShowDemandSet();
                }
            }
            else if (comboBoxType.SelectedIndex == 1)
            {
                if (listViewDemandSet_House.SelectedItems.Count == 1)
                {
                    DemandSet demand = listViewDemandSet_House.SelectedItems[0].Tag as DemandSet;

                    demand.IdAgent   = Convert.ToInt32(comboBoxAgent.SelectedItem.ToString().Split('.')[0]);
                    demand.IdClient  = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
                    demand.MinArea   = Convert.ToDouble(textBoxMinArea.Text);
                    demand.MaxArea   = Convert.ToDouble(textBoxMaxArea.Text);
                    demand.MinPrice  = Convert.ToInt64(textBoxMinPrice.Text);
                    demand.MaxPrice  = Convert.ToInt64(textBoxMaxPrice.Text);
                    demand.MinFloors = Convert.ToInt32(textBoxMinFloors.Text);
                    demand.MaxFloors = Convert.ToInt32(textBoxMaxFloors.Text);

                    Program.wftDb.SaveChanges();
                    ShowDemandSet();
                }
            }
            else
            {
                if (listViewDemandSet_Land.SelectedItems.Count == 1)
                {
                    DemandSet demand = listViewDemandSet_Land.SelectedItems[0].Tag as DemandSet;

                    comboBoxAgent.SelectedIndex  = comboBoxAgent.FindString(demand.IdAgent.ToString());
                    comboBoxClient.SelectedIndex = comboBoxClient.FindString(demand.IdClient.ToString());
                    demand.IdAgent  = Convert.ToInt32(comboBoxAgent.SelectedItem.ToString().Split('.')[0]);
                    demand.IdClient = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
                    demand.MinArea  = Convert.ToDouble(textBoxMinArea.Text);
                    demand.MaxArea  = Convert.ToDouble(textBoxMaxArea.Text);
                    demand.MinPrice = Convert.ToInt64(textBoxMinPrice.Text);
                    demand.MaxPrice = Convert.ToInt64(textBoxMaxPrice.Text);

                    Program.wftDb.SaveChanges();
                    ShowDemandSet();
                }
            }
        }