Ejemplo n.º 1
0
        // Loads the form.
        private void frmAddTicket_Load(object sender, EventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.GetType().Name == "frmPhone")
                {
                    Form frmOpenPhone = form;
                    frmOpenPhone.Top  = this.Top;
                    frmOpenPhone.Left = this.Right;
                }
            }

            List <string> clientIDs = Client.GetClientIDs();

            if (clientIDs.Count != 0)
            {
                bs.DataSource = clientIDs;

                cmbClient.DataSource = bs.DataSource;

                Dictionary <int, string> typesOfServices     = Service.GetTypesOfServices();
                List <string>            listTypesOfServices = new List <string>();

                foreach (KeyValuePair <int, string> item in typesOfServices)
                {
                    listTypesOfServices.Add(item.Key.ToString() + " - " + item.Value);
                }

                bs.DataSource = listTypesOfServices;

                cmbTypeOfService.DataSource = bs.DataSource;

                List <int> technicianIDs = Technician.GetAvailableTechnicianIDs();

                if (cmbProduct.Items.Count == 0)
                {
                    cmbProduct.Enabled      = false;
                    btnSubmitTicket.Enabled = false;
                }

                if (technicianIDs.Count == 0)
                {
                    cmbTechnician.Enabled             = false;
                    lblTechniciansUnavailable.Visible = true;
                }

                bs.DataSource = technicianIDs;

                cmbTechnician.DataSource = bs.DataSource;
            }
            else
            {
                btnSubmitTicket.Enabled = false;
            }
        }
Ejemplo n.º 2
0
        // Gets all orders and technicians from the database.
        private void frmAssignTechnicians_Load(object sender, EventArgs e)
        {
            // Searches for the phone form. If it's open, the phone's form's position is adjusted.
            foreach (Form form in Application.OpenForms)
            {
                if (form.GetType().Name == "frmPhone")
                {
                    Form frmOpenPhone = form;
                    frmOpenPhone.Top  = this.Top;
                    frmOpenPhone.Left = this.Right;
                }
            }

            bool delivered = true;
            bool installed = false;
            bool assigned  = false;

            List <int> orderIDs = Order.GetOrderIDs(delivered, installed, assigned);

            if (orderIDs.Count != 0)
            {
                bs.DataSource       = orderIDs;
                cmbOrder.DataSource = bs.DataSource;

                if (orderID != 0)
                {
                    for (int i = 0; i < orderIDs.Count; i++)
                    {
                        if (int.Parse(cmbOrder.Items[i].ToString()) == orderID)
                        {
                            cmbOrder.SelectedIndex = i;
                        }
                    }
                }

                List <int> technicianIDs = Technician.GetAvailableTechnicianIDs();

                if (technicianIDs.Count == 0)
                {
                    btnAddInstallation.Enabled        = false;
                    cmbTechnician.Enabled             = false;
                    lblTechniciansUnavailable.Visible = true;
                }

                bs.DataSource            = technicianIDs;
                cmbTechnician.DataSource = bs.DataSource;
            }
            else
            {
                btnAddInstallation.Enabled = false;
            }
        }