//Main logic//
        //Get logic//

        /// <summary>
        /// Populate the data grid with information about all existing workers in the database
        /// </summary>
        private void PopulateDataGridViewDefault()
        {
            dataGridView.Rows.Clear();
            WorkerBusiness workerBusiness = new WorkerBusiness();
            var            workersList    = workerBusiness.GetAllWorkers();

            DataPopulator(workersList);
        }
        /// <summary>
        /// Populate the data grid with information about workers with given last name
        /// </summary>
        private void PopulateDataGridViewGetWorkersByLastName()
        {
            dataGridView.Rows.Clear();
            WorkerBusiness workerBusiness = new WorkerBusiness();
            var            workersList    = workerBusiness.GetWorkersByLastName(txtGet.Text);

            DataPopulator(workersList);
        }
        /// <summary>
        /// Populate the data grid with information sorted by workers' salaries in descending order
        /// </summary>
        private void PopulateDataGridViewSortWorkersBySalaryDescending()
        {
            dataGridView.Rows.Clear();
            WorkerBusiness workerBusiness = new WorkerBusiness();
            var            workersList    = workerBusiness.SortWorkersBySalaryDescending();

            DataPopulator(workersList);
        }
        /// <summary>
        /// Populate the data grid with information sorted by workers' positions
        /// </summary>
        private void PopulateDataGridViewSortWorkersByPosition()
        {
            dataGridView.Rows.Clear();
            WorkerBusiness workerBusiness = new WorkerBusiness();
            var            workersList    = workerBusiness.SortWorkersByPosition();

            DataPopulator(workersList);
        }
        /// <summary>
        /// Populate the data grid with information about workers with given dealership Id
        /// </summary>
        private void PopulateDataGridViewGetWorkersByDealershipId()
        {
            dataGridView.Rows.Clear();
            WorkerBusiness workerBusiness = new WorkerBusiness();

            int.TryParse(txtGet.Text, out int dealershipId);
            var workersList = workerBusiness.GetWorkersByDealershipId(dealershipId);

            DataPopulator(workersList);
        }
        /// <summary>
        /// Populate the data grid with information about worker with given worker Id
        /// </summary>
        private void PopulateDataGridViewGetWorkerById()
        {
            dataGridView.Rows.Clear();
            WorkerBusiness workerBusiness = new WorkerBusiness();

            int.TryParse(txtGet.Text, out int workerId);
            var worker = workerBusiness.GetWorkerById(workerId);

            DataPopulatorSingle(worker);
        }
        /// <summary>
        /// Populate the data grid with information about workers with salary lower than given
        /// </summary>
        private void PopulateDataGridViewGetWorkersWithLowerSalary()
        {
            dataGridView.Rows.Clear();
            WorkerBusiness workerBusiness = new WorkerBusiness();

            decimal.TryParse(txtGet.Text, out decimal salary);
            var workersList = workerBusiness.GetWorkersWithLowerSalary(salary);

            DataPopulator(workersList);
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            Worker         worker         = GetEditedWorker();
            WorkerBusiness workerBusiness = new WorkerBusiness();

            workerBusiness.Update(worker);
            PopulateDataGridViewDefault();
            ResetSelect();
            ToggleSaveUpdate();
            ClearTextBoxes();
        }
        /// <summary>
        /// Update the input text boxes with information for a selected worker
        /// </summary>
        /// <param name="Id">The ID of a selected worker</param>
        private void UpdateTextBoxes(int Id)
        {
            WorkerBusiness workerBusiness = new WorkerBusiness();
            Worker         worker         = workerBusiness.GetWorkerById(Id);

            txtFirstName.Text  = worker.FirstName;
            txtLastName.Text   = worker.LastName;
            txtPosition.Text   = worker.Position;
            txtSalary.Text     = worker.Salary.ToString();
            txtDealership.Text = worker.CarDealershipId.ToString();
        }
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (dataGridView.SelectedRows.Count > 0)
     {
         var            worker         = dataGridView.SelectedRows[0].Cells;
         var            workerId       = int.Parse(worker[0].Value.ToString());
         WorkerBusiness workerBusiness = new WorkerBusiness();
         workerBusiness.Delete(workerId);
         PopulateDataGridViewDefault();
         ResetSelect();
     }
 }
Ejemplo n.º 11
0
        private void button1_Click(object sender, EventArgs e)
        {
            WorkerBusiness wb = new WorkerBusiness();

            foreach (CaffeWorker w in wb.GetCaffeWorkers())
            {
                if (textBox1.Text.Equals(w.User_Name) && textBox2.Text.Equals(w.Password))
                {
                    MainPage mp = new MainPage();
                    mp.Show();
                    this.Hide();
                }
            }
        }
        /// <summary>
        /// Populate the data grid with information for a single worker
        /// </summary>
        /// <param name="worker">A single worker used to populate the data grid</param>
        private void DataPopulatorSingle(Worker worker)
        {
            WorkerBusiness workerBusiness = new WorkerBusiness();

            string[] row =
            {
                worker.Id.ToString(),
                worker.FirstName,
                worker.LastName,
                worker.Position,
                worker.Salary.ToString(),
                workerBusiness.GetDealershipName(worker.CarDealershipId)
            };
            dataGridView.Rows.Add(row);
        }
Ejemplo n.º 13
0
        private void btnWorkers_Click(object sender, EventArgs e)
        {
            HideSpecificInfo();
            lblInfoWorker.Visible = true;
            btnNewWorker.Visible  = true;

            dataGridView.Rows.Clear();

            dataGridView.ColumnCount = 7;

            dataGridView.Columns[0].Name = "ID";
            dataGridView.Columns[1].Name = "Име";
            dataGridView.Columns[2].Name = "Фамилия";
            dataGridView.Columns[3].Name = "Длъжност";
            dataGridView.Columns[4].Name = "Заплата";
            dataGridView.Columns[5].Name = "ID на автокъща";
            dataGridView.Columns[6].Name = "Автокъща";

            dataGridView.AutoSizeRowsMode =
                DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
            dataGridView.ColumnHeadersBorderStyle =
                DataGridViewHeaderBorderStyle.Single;
            dataGridView.CellBorderStyle   = DataGridViewCellBorderStyle.Single;
            dataGridView.RowHeadersVisible = false;
            dataGridView.SelectionMode     =
                DataGridViewSelectionMode.FullRowSelect;
            dataGridView.MultiSelect = false;

            WorkerBusiness workerBusiness = new WorkerBusiness();
            var            workersList    = workerBusiness.GetAllWorkers();

            foreach (var worker in workersList)
            {
                string[] row =
                {
                    worker.Id.ToString(),
                    worker.FirstName,
                    worker.LastName,
                    worker.Position,
                    worker.Salary.ToString(),
                    worker.CarDealershipId.ToString(),
                    workerBusiness.GetDealershipName(worker.CarDealershipId)
                };
                dataGridView.Rows.Add(row);
            }
        }
Ejemplo n.º 14
0
        protected void login_ServerClick(object sender, EventArgs e)
        {
            WorkerBusiness wr = new WorkerBusiness();

            foreach (CaffeWorker caffeWorker in wr.GetCaffeWorkers())
            {
                if (txtuser.Value.Equals(caffeWorker.User_Name) && txtpass.Value.Equals(caffeWorker.Password))
                {
                    wr.getsetworker = caffeWorker;
                    Response.Redirect("Home.aspx");
                }
                else
                {
                    Label1.Visible = true;
                }
            }
        }
        //cbGet and cbSort//

        //Buttons + attached logic//
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Worker worker = new Worker
            {
                FirstName = txtFirstName.Text,
                LastName  = txtLastName.Text,
                Position  = txtPosition.Text
            };

            decimal.TryParse(txtSalary.Text, out decimal salary);
            worker.Salary = salary;
            int.TryParse(txtDealership.Text, out int dealershipId);
            worker.CarDealershipId = dealershipId;

            WorkerBusiness workerBusiness = new WorkerBusiness();

            workerBusiness.Add(worker);
            PopulateDataGridViewDefault();
            ClearTextBoxes();
        }