private void updateBtn_Click(object sender, EventArgs e)
        {
            int selectedRowIndex = 0;

            if (table.SelectedCells.Count > 0)
            {
                Software.Model.Job job = new Software.Model.Job();

                selectedRowIndex = table.SelectedCells[0].RowIndex;
                DataGridViewRow selectedRow = table.Rows[selectedRowIndex];

                job.Id          = Convert.ToInt32(Convert.ToString(selectedRow.Cells["Id"].Value));
                job.Job_Title   = jobTitileBox.Text;
                job.Salary      = Convert.ToInt32(salaryBox.Text);
                job.Description = descriptionBox.Text;
                Software.Database.SQL.JobDB.UpdateJob(job);
            }
            else
            {
                MessageBox.Show("You must select a row to update its value!", "Invalid Selection");
            }

            DoRefresh();
            table.CurrentCell = table.Rows[selectedRowIndex].Cells[0];
            table.Rows[selectedRowIndex].Selected = true;
        }
Пример #2
0
 private void createBtn_Click(object sender, EventArgs e)
 {
     Software.Model.Job job = new Software.Model.Job
     {
         Job_Title   = jobTitileBox.Text,
         Salary      = Int32.Parse(salaryBox.Text),
         Description = descriptionBox.Text
     };
     Software.Database.SQL.JobDB.InsertJob(job);
     MetroFramework.MetroMessageBox.Show(this, "Sucess", "Data Inserted Successfully", MessageBoxButtons.OK, MessageBoxIcon.Information);
     Close();
 }
Пример #3
0
        private void table_SelectionChanged(object sender, System.EventArgs e)
        {
            if (table.SelectedCells.Count > 0)
            {
                int             selectedrowindex = table.SelectedCells[0].RowIndex;
                DataGridViewRow selectedRow      = table.Rows[selectedrowindex];
                pictureBox.ImageLocation = Convert.ToString(selectedRow.Cells["Picture"].Value);
                nameBox.Text             = Convert.ToString(selectedRow.Cells["Name"].Value);
                contactBox.Text          = Convert.ToString(selectedRow.Cells["Contact_No"].Value);
                emailBox.Text            = Convert.ToString(selectedRow.Cells["Email"].Value);
                addressBox.Text          = Convert.ToString(selectedRow.Cells["Address"].Value);
                commissionBox.Text       = Convert.ToString(selectedRow.Cells["Commission"].Value);
                passBox.Text             = Convert.ToString(selectedRow.Cells["Password"].Value);
                authorityBox.Text        = Convert.ToString(selectedRow.Cells["Authority"].Value);
                hireDateTime.Value       = Convert.ToDateTime(selectedRow.Cells["Hire_Date"].Value);

                Software.Model.Job job = jobs.Single(j => j.Id == Convert.ToInt32(Convert.ToString(selectedRow.Cells["Job_id"].Value)));
                jobComboBox.SelectedIndex = jobComboBox.FindStringExact(job.Job_Title);
            }
        }