Пример #1
0
        private async void employeesBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            BusyForm mBusyForm = new BusyForm();

            mBusyForm.Show(this);

            try
            {
                foreach (Employees employees in (List <Employees>)employeesBindingSource.DataSource)
                {
                    Employees employee = new Employees()
                    {
                        Id               = employees.Id,
                        FirstName        = employees.FirstName,
                        LastName         = employees.LastName,
                        Gender           = employees.Gender,
                        EmployeesDetails = new EmployeesDetails()
                        {
                            JobTitle     = employees.EmployeesDetails.JobTitle,
                            Salary       = employees.EmployeesDetails.Salary,
                            Id           = employees.Id,
                            DepartmentId = employees.EmployeesDetails.DepartmentId
                        }
                    };
                    int result = await ClientDB.SaveEmployeeAsync(employee);
                }
                mBusyForm.Close();
            }
            catch (Exception ex)
            {
                mBusyForm.Close();
                MessageBox.Show(this, ex.Message);
            }
        }
Пример #2
0
        private async void departmentsBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            BusyForm mBusyForm = new BusyForm();

            mBusyForm.Show(this);

            try
            {
                foreach (Departments departments in (List <Departments>)departmentsBindingSource.DataSource)
                {
                    Departments department = new Departments()
                    {
                        Id       = departments.Id,
                        Name     = departments.Name,
                        Location = departments.Location
                    };
                    int result = await ClientDB.SaveDepartmentAsync(department);
                }
                mBusyForm.Close();
            }
            catch (Exception ex)
            {
                mBusyForm.Close();
                MessageBox.Show(this, ex.Message);
            }
        }
Пример #3
0
        private async void bSave_Click(object sender, EventArgs e)
        {
            BusyForm mBusyForm = new BusyForm();

            mBusyForm.Show(this);

            try
            {
                Employees employee = new Employees()
                {
                    Id               = (int)cbEmployees.SelectedValue,
                    FirstName        = tbFirstName.Text,
                    LastName         = tbLastName.Text,
                    Gender           = tbGender.Text,
                    EmployeesDetails = new EmployeesDetails()
                    {
                        JobTitle     = tbJobTitle.Text,
                        Salary       = int.Parse(tbSalary.Text),
                        Id           = (int)cbEmployees.SelectedValue,
                        DepartmentId = (int)cbDepartments.SelectedValue
                    }
                };
                int result = await ClientDB.SaveEmployeeAsync(employee);

                mBusyForm.Close();
            }
            catch (Exception ex)
            {
                mBusyForm.Close();
                MessageBox.Show(this, ex.Message);
            }
        }
Пример #4
0
        private async void cbEmployees_SelectedIndexChanged(object sender, EventArgs ev)
        {
            BusyForm mBusyForm = new BusyForm();

            mBusyForm.Show(this);

            try
            {
                Employees        e  = (Employees)cbEmployees.SelectedItem;
                EmployeesDetails ed = await ClientDB.GetEmployeeDetailsAsync((int)cbEmployees.SelectedValue);

                if (ed != null)
                {
                    tbFirstName.Text            = e.FirstName;
                    tbLastName.Text             = e.LastName;
                    tbGender.Text               = e.Gender;
                    tbJobTitle.Text             = ed.JobTitle;
                    tbSalary.Text               = ed.Salary.ToString();
                    cbDepartments.SelectedValue = ed.DepartmentId;

                    Departments d = await ClientDB.GetDepartmentAsync(ed.DepartmentId);

                    cbDepartments.SelectedValue = d.Id;
                }
                mBusyForm.Close();
            }
            catch (Exception ex)
            {
                mBusyForm.Close();
                MessageBox.Show(this, ex.Message);
            }
        }
Пример #5
0
        /// <summary><c>ComputeXmlToJson</c> is an function preparing the task that will call the
        /// "XmlToJson" function on the webservice.
        /// This function also handles the display of the BusyForm
        /// </summary>
        public async void ComputeXmlToJson()
        {
            BusyForm mBusyForm = new BusyForm();

            mBusyForm.Show(this);

            Task <string> xmlToJsonTask = XmlToJsonAsync(tbEntryXml.Text);
            string        result        = await xmlToJsonTask;

            tbResult.Text = result;
            BuildTreeView(result);

            mBusyForm.Close();
        }
Пример #6
0
        /// <summary><c>ComputeFibonacci</c> is a function preparing the task that will call the
        /// "Fibonacci" function on the webservice. This function also handles the display of the
        /// BusyForm.
        /// </summary>
        public async void ComputeFibonacci()
        {
            BusyForm mBusyForm = new BusyForm();

            mBusyForm.Show(this);

            try
            {
                Task <decimal> fibonacciTask = FibonacciAsync(decimal.ToInt32(nudNumber.Value));
                decimal        fibonacci     = await fibonacciTask;

                mBusyForm.Close();
                MessageBox.Show(this, fibonacci.ToString());
            }
            catch (Exception ex)
            {
                mBusyForm.Close();
                MessageBox.Show(this, ex.Message);
            }
        }