Beispiel #1
0
        private void AgentBookings_Load(object sender, EventArgs e)
        {
            listView1.Items.Clear();
            List <Agent> agentList;

            try
            {
                agentList = CampusDatabase.GetAgent();
                if (agentList.Count > 0)
                {
                    //MessageBox.Show("good", "OK");
                    for (int i = 0; i < agentList.Count; i++)
                    {
                        Agent agent = agentList[i];
                        listView1.Items.Add(agent.AgentName);
                        listView1.Items[i].SubItems.Add(agent.OfficeLocation);
                        listView1.Items[i].SubItems.Add(agent.NumSales.ToString());
                        listView1.Items[i].SubItems.Add(agent.TotalSales.ToString());
                    }
                }
                else
                {
                    MessageBox.Show("There are no any agents.", "Alert");
                }
            }
            catch (Exception e1)
            { MessageBox.Show(e1.Message, e1.GetType().ToString()); }
        }
Beispiel #2
0
        private void AddAgent_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'cAMPUSDataSet.OFFICE' table. You can move, or remove it, as needed.
            this.oFFICETableAdapter.Fill(this.cAMPUSDataSet.OFFICE);
            listView1.Items.Clear();
            List <Agent> agentList;

            try
            {
                agentList = CampusDatabase.GetAgent();
                if (agentList.Count > 0)
                {
                    //MessageBox.Show("good", "OK");
                    for (int i = 0; i < agentList.Count; i++)
                    {
                        Agent agent = agentList[i];
                        listView1.Items.Add(agent.AgentName);
                        listView1.Items[i].SubItems.Add(agent.OfficeLocation);
                        listView1.Items[i].SubItems.Add(agent.NumSales.ToString());
                        listView1.Items[i].SubItems.Add(agent.TotalSales.ToString());
                    }
                }
                else
                {
                    MessageBox.Show("There are no any agents.", "Alert");
                }
            }
            catch (Exception e1)
            { MessageBox.Show(e1.Message, e1.GetType().ToString()); }
        }
Beispiel #3
0
        private void butSearch_Click(object sender, EventArgs e)
        {
            List <Sale>   sales      = CampusDatabase.GetSale(Convert.ToInt32(cbAgent.SelectedValue), Convert.ToInt32(cbDestination.SelectedValue), textBox1.Text, textBox2.Text);
            SearchResults resultForm = new SearchResults(sales);

            resultForm.Show();
        }
Beispiel #4
0
 private void butDelete_Click(object sender, EventArgs e)
 {
     //the saleId store in subitem[5] of listView1
     CampusDatabase.DeleteSale(Convert.ToInt32(listView1.Items[0].SubItems[5].Text));
     MessageBox.Show("the sale has been deleted!", "Alert");
     this.Close();
 }
Beispiel #5
0
 private void bSubmit_Click(object sender, EventArgs e)
 {
     CampusDatabase.AddAgent(txtAgentName.Text, Convert.ToInt32(cbOfficeLocation.SelectedValue));
     //cannot convert from object to int
     //cbOfficeLocation.SelectedValuea is an object data type;
     //CampusDatabase.AddAgent(txtAgentName.Text, cbOfficeLocation.SelectedValue);
     txtAgentName.Clear();
     MessageBox.Show("Agent Added!", "Alert");
     //refresh form1
     this.AddAgent_Load(this, null);
 }
Beispiel #6
0
        private void SearchSales_Load(object sender, EventArgs e)
        {
            cbAgent.Items.Clear();
            cbDestination.Items.Clear();
            List <Agent>       agentList       = CampusDatabase.GetAgent();
            List <Destination> destinationList = CampusDatabase.GetDestination();

            try
            {
                if (agentList.Count > 0)
                {
                    agentList.Insert(0, new Asisgnment6.Agent()
                    {
                        AgentID = 0, AgentName = "All Agents"
                    });
                    cbAgent.DataSource    = agentList;
                    cbAgent.DisplayMember = "AgentName";
                    cbAgent.ValueMember   = "AgentId";
                }
                else
                {
                    MessageBox.Show("There are no agents", "Alert");
                }
                if (destinationList.Count > 0)
                {
                    destinationList.Insert(0, new Asisgnment6.Destination()
                    {
                        DestinationId = 0, DestinationName = "All Destinations"
                    });
                    cbDestination.DataSource    = destinationList;
                    cbDestination.DisplayMember = "DestinationName";
                    cbDestination.ValueMember   = "DestinationId";
                }
                else
                {
                    MessageBox.Show("There are no Destinations", "Alert");
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.Message, e1.GetType().ToString());
            }
        }
Beispiel #7
0
        private void UpdateSale_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'cAMPUSDataSet8.AGENT' table. You can move, or remove it, as needed.
            this.aGENTTableAdapter1.Fill(this.cAMPUSDataSet8.AGENT);
            // TODO: This line of code loads data into the 'cAMPUSDataSet7.AGENT' table. You can move, or remove it, as needed.
            this.aGENTTableAdapter.Fill(this.cAMPUSDataSet7.AGENT);
            // TODO: This line of code loads data into the 'cAMPUSDataSet6.DESTINATION' table. You can move, or remove it, as needed.
            this.dESTINATIONTableAdapter.Fill(this.cAMPUSDataSet6.DESTINATION);
            Sale sale = CampusDatabase.GetSale(saleId);

            listView1.Items.Clear();

            try
            {
                //display the sale on listView1
                if (sale != null)
                {
                    listView1.Items.Add(sale.SaleDate.ToShortDateString());
                    listView1.Items[0].SubItems.Add(sale.Amount.ToString());
                    listView1.Items[0].SubItems.Add(sale.DestinationName);
                    listView1.Items[0].SubItems.Add(sale.AgentName);
                    listView1.Items[0].SubItems.Add(sale.OfficeLocation);
                    listView1.Items[0].SubItems.Add(sale.SaleId.ToString());
                    cbAgent.SelectedValue       = sale.AgentKey;
                    cbDestinaiton.SelectedValue = sale.DestinationKey;
                }
                else
                {
                    MessageBox.Show("the sale ID is not exist.", "Alert");
                }
            }
            catch (Exception e1)
            { MessageBox.Show(e1.Message, e1.GetType().ToString()); }



            //show amount
            txtAmount.Text = sale.Amount.ToString();
            //show date
            labDate.Text = sale.SaleDate.ToLongDateString();
            //showdate
            monthCalendar1.SetDate(sale.SaleDate);
        }
Beispiel #8
0
 private void bSubmit_Click(object sender, EventArgs e)
 {
     CampusDatabase.AddSale(monthCalendar1.SelectionStart, Convert.ToInt32(cbAgent.SelectedValue), Convert.ToInt32(cbDestinaiton.SelectedValue), Convert.ToDecimal(txtAmount.Text));
     txtAmount.Clear();
     MessageBox.Show("New Sale Added!", "Alert");
 }
Beispiel #9
0
 private void butUpdate_Click(object sender, EventArgs e)
 {
     CampusDatabase.UpdateSale(saleId, monthCalendar1.SelectionStart, Convert.ToInt32(cbAgent.SelectedValue), Convert.ToInt32(cbDestinaiton.SelectedValue), Convert.ToDecimal(txtAmount.Text));
     MessageBox.Show("the sale has been updated!", "Alert");
     this.Close();
 }