Beispiel #1
0
        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 buttonDel_Click(object sender, EventArgs e)
        {
            try
            {
                if (listView.SelectedItems.Count == 1)
                {
                    DemandSet demandSet = listView.SelectedItems[0].Tag as DemandSet;

                    Program.RPE.DemandSet.Remove(demandSet);

                    Program.RPE.SaveChanges();

                    ShowClient();
                }
            }
            catch
            {
                MessageBox.Show("Невозможно удалить, эта запись используется.", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            DemandSet demandSet = new DemandSet();

            demandSet.idAgent   = Convert.ToInt32(comboBoxAgent.Text.Split('.')[0]);
            demandSet.idClient  = Convert.ToInt32(comboBoxClient.Text.Split('.')[0]);
            demandSet.Type      = textboxType.Text;
            demandSet.MinPrice  = Convert.ToInt32(PriceMin.Text);
            demandSet.MaxPrice  = Convert.ToInt32(PriceMax.Text);
            demandSet.MinArea   = Convert.ToInt32(AreaMin.Text);
            demandSet.MaxArea   = Convert.ToInt32(AreaMax.Text);
            demandSet.MinRooms  = Convert.ToInt32(RoomsMin.Text);
            demandSet.MaxRooms  = Convert.ToInt32(RoomsMax.Text);
            demandSet.MinFloor  = Convert.ToInt32(FloorMin.Text);
            demandSet.MaxFloor  = Convert.ToInt32(FloorMax.Text);
            demandSet.MinFloors = Convert.ToInt32(FloorsMin.Text);
            demandSet.MaxFloors = Convert.ToInt32(FloorsMax.Text);

            Program.RPE.DemandSet.Add(demandSet);
            Program.RPE.SaveChanges();
            ShowClient();
        }
        private void listView_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listView.SelectedItems.Count == 1)
            {
                DemandSet clientsSet = listView.SelectedItems[0].Tag as DemandSet;

                comboBoxAgent.Text  = clientsSet.idAgent.ToString();
                comboBoxClient.Text = clientsSet.idClient.ToString();
                textboxType.Text    = clientsSet.Type;
                PriceMin.Text       = clientsSet.MinPrice.ToString();
                PriceMax.Text       = clientsSet.MaxPrice.ToString();
                AreaMin.Text        = clientsSet.MinArea.ToString();
                AreaMax.Text        = clientsSet.MaxArea.ToString();
                RoomsMin.Text       = clientsSet.MinRooms.ToString();
                RoomsMax.Text       = clientsSet.MaxRooms.ToString();
                FloorMin.Text       = clientsSet.MinFloor.ToString();
                FloorMax.Text       = clientsSet.MaxFloors.ToString();
                FloorsMin.Text      = clientsSet.MinFloors.ToString();
                FloorsMax.Text      = clientsSet.MaxFloors.ToString();
            }
            else
            {
                comboBoxAgent.Text  = "";
                comboBoxClient.Text = "";
                textboxType.Text    = "";
                PriceMin.Text       = "";
                PriceMax.Text       = "";
                AreaMin.Text        = "";
                AreaMax.Text        = "";
                RoomsMin.Text       = "";
                RoomsMax.Text       = "";
                FloorMin.Text       = "";
                FloorMax.Text       = "";
                FloorsMin.Text      = "";
                FloorsMax.Text      = "";
            }
        }
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (listView.SelectedItems.Count == 1)
            {
                DemandSet demandSet = listView.SelectedItems[0].Tag as DemandSet;

                demandSet.idAgent   = Convert.ToInt32(comboBoxAgent.Text);
                demandSet.idClient  = Convert.ToInt32(comboBoxClient.Text);
                demandSet.Type      = textboxType.Text;
                demandSet.MinPrice  = Convert.ToInt32(PriceMin.Text);
                demandSet.MaxPrice  = Convert.ToInt32(PriceMax.Text);
                demandSet.MinArea   = Convert.ToInt32(AreaMin.Text);
                demandSet.MaxArea   = Convert.ToInt32(AreaMax.Text);
                demandSet.MinRooms  = Convert.ToInt32(RoomsMin.Text);
                demandSet.MaxRooms  = Convert.ToInt32(RoomsMax.Text);
                demandSet.MinFloor  = Convert.ToInt32(FloorMin.Text);
                demandSet.MaxFloor  = Convert.ToInt32(FloorMax.Text);
                demandSet.MinFloors = Convert.ToInt32(FloorsMin.Text);
                demandSet.MaxFloors = Convert.ToInt32(FloorsMax.Text);

                Program.RPE.SaveChanges();
                ShowClient();
            }
        }