Exemple #1
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.AgentSet.DealShare != null)
                {
                    double agentCustomerDeductions = customerCompanyDeductions * Convert.ToDouble(demand.AgentSet.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.RealEstateSet.Type == 0)
                {
                    sallerCompanyDeductions            = 36000 + supply.Price * 0.01;
                    textBoxSallerCompanyDeduction.Text = sallerCompanyDeductions.ToString("0.00");
                }
                else if (supply.RealEstateSet.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.AgentSet.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 (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 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 = "";
     }
 }
 private void ButtonAdd_Click(object sender, EventArgs e)
 {
     if (comboBoxAgents.SelectedItem != null && comboBoxClients.SelectedItem != null && comboBoxRealEstate.SelectedItem != 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);
     }
 }
 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();
         }
         comboBoxAgents.SelectedItem     = null;
         comboBoxClients.SelectedItem    = null;
         comboBoxRealEstate.SelectedItem = null;
         textBoxPrice.Text = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }