public FormUpdateEmployee(DeligateForEmployee.DelegatePopulateDataGridView delgrid, string id, List <string> employee) { InitializeComponent(); this.Data = new DataAccess(); this.Id = id; this.update = true; this.delGridView = delgrid; // this.txtId.Visible= false; this.cmbDepertment.Enabled = false; this.cmbJob.Enabled = false; this.Job = DataAccess.SingleVarification("select job from employee where id='" + this.Id + "'"); // this.txtName.Text = dataTeble.Rows[0][1].ToString(); this.txtId.Text = employee[0]; this.txtName.Text = employee[1]; this.cmbJob.Text = employee[2]; this.txtSalary.Text = employee[3]; if (employee[4] == "male") { this.rbtnMale.Checked = true; } else { this.rbtnFemale.Checked = true; } this.cmbDepertment.Text = employee[5]; this.txtEmail.Text = employee[6]; }
public FormUpdateEmployee(DeligateForEmployee.DelegatePopulateDataGridView delGridView, string id) { InitializeComponent(); this.Data = new DataAccess(); this.Id = id; this.delGridView = delGridView; this.Job = DataAccess.SingleVarification("select job from employee where id='" + this.Id + "'"); // this.job = this.cmbJob.SelectedItem.ToString(); string sqlCount = "select count(*) from employee"; int total = DataAccess.CountMethod(sqlCount) + 1; count = total.ToString("D4"); this.id = "un-" + count + ""; // MessageBox.Show(this.id); this.txtId.Text = this.id; this.cmbDepertment.DropDownStyle = ComboBoxStyle.DropDownList; this.cmbJob.DropDownStyle = ComboBoxStyle.DropDownList; this.rbtnMale.Checked = true; if (Job == "manager") { this.cmbDepertment.DataSource = new List <string> { "hr-01" }; } else if (Job == "depertment head") { // this.PopulateDataGridView("select * from employee where status='active' and depertmentid='it-01'"); this.cmbDepertment.DataSource = new List <string> { "it-01" }; } else { // this.PopulateDataGridView("select * from employee where status='active' and depertmentid='it-01'"); this.cmbDepertment.DataSource = new List <string> { "it-01", "hr-01" }; } }
private void updateEmployeeInformationToolStripMenuItem_Click(object sender, EventArgs e) { try { DeligateForEmployee.DelegatePopulateDataGridView delGridView = this.PopulateDataGridView; if (this.dgvEmployeeInformation.SelectedRows.Count != 1) { MessageBox.Show("Please Select a Employee .!"); } else if (this.dgvEmployeeInformation.CurrentRow.Cells["job"].Value.ToString() == this.Job && this.Job != "hr") { MessageBox.Show("Sorry you can't update your own information "); } else if (this.dgvEmployeeInformation.CurrentRow.Cells["job"].Value.ToString() == "hr" && this.Job != "hr") { MessageBox.Show("Sorry you can't update HR's information "); } else { DeligateForEmployee.DelegatePopulateDataGridView delGridViewUpdate = this.PopulateDataGridView; string id = this.dgvEmployeeInformation.CurrentRow.Cells["id"].Value.ToString(); List <string> employee = new List <string> { this.dgvEmployeeInformation.CurrentRow.Cells["id"].Value.ToString(), this.dgvEmployeeInformation.CurrentRow.Cells["name"].Value.ToString(), this.dgvEmployeeInformation.CurrentRow.Cells["job"].Value.ToString(), this.dgvEmployeeInformation.CurrentRow.Cells["salary"].Value.ToString(), this.dgvEmployeeInformation.CurrentRow.Cells["gender"].Value.ToString(), this.dgvEmployeeInformation.CurrentRow.Cells["deptid"].Value.ToString(), this.dgvEmployeeInformation.CurrentRow.Cells["email"].Value.ToString() }; if ((MessageBox.Show("Are you sure to update id :" + id + "'s Information ?", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)) { new FormUpdateEmployee(delGridViewUpdate, this.Id, employee).Visible = true; } } } catch (Exception ea) { MessageBox.Show(ea.Message); } }
private void addNewEmployeeToolStripMenuItem_Click(object sender, EventArgs e) { DeligateForEmployee.DelegatePopulateDataGridView delGridView = this.PopulateDataGridView; new FormUpdateEmployee(delGridView, this.Id).Visible = true; }