Esempio n. 1
0
        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();
            }
        }
Esempio n. 2
0
 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);
     }
 }
Esempio n. 3
0
 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());
         textBoxPrice.Text = supply.Price.ToString();
     }
     else
     {
         comboBoxAgents.SelectedItem     = null;
         comboBoxClients.SelectedItem    = null;
         comboBoxRealEstate.SelectedItem = null;
         textBoxPrice.Text = "";
     }
 }
Esempio n. 4
0
 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);
     }
 }
Esempio n. 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   = "";
            }
        }