private void Holiday_Load(object sender, EventArgs e) { this.LoadActiveHoliday(); this.LoadArchiveHoliday(); payroll_holiday_category.SelectedIndex = 0; if (dbcon.OpenCon() == true) { Button box; string query = "SELECT * from tbl_payroll_company where payroll_company_archived=0"; cmd = new MySqlCommand(query, dbcon.con); read = cmd.ExecuteReader(); int y = 6; while (read.Read()) { //initialize box box = new Button(); //set box properties box.Location = new Point(6, y); box.AutoSize = true; box.Tag = read["payroll_company_id"].ToString(); box.Text = read["payroll_company_name"].ToString(); //add box to groupbox panelHoliday.Controls.Add(box); //add event to checkbox int id = Convert.ToInt32(read["payroll_company_id"]); box.Click += (se, ev) => payroll.TagEmployee(se, ev, id, "Holiday"); y += 29; } dbcon.CloseCon(); } }
public bool CheckIfLeavenameExist(string leavename) { bool exist = false; if (dbcon.OpenCon() == true) { string query = "SELECT count(*) from tbl_payroll_leave_temp where payroll_leave_temp_name='" + leavename + "' AND payroll_leave_temp_archived=0"; cmd = new MySqlCommand(query, dbcon.con); Int32 count = Convert.ToInt32(cmd.ExecuteScalar()); dbcon.CloseCon(); if (count > 0) { exist = true; return(exist); } } return(exist); }
private void TagEmployee_Load(object sender, EventArgs e) { employeecontroller.LoadDepartment(payroll_filter_dept_tag); employeecontroller.LoadJobTitle(payroll_filter_job_tag, payroll_filter_dept_tag.SelectedValue.ToString()); if (dbcon.OpenCon() == true) { CheckBox box; MySqlDataReader read; if (company_id != 0) { string query = "SELECT * from tbl_payroll_employee_basic where payroll_employee_company_id=" + company_id + " ORDER by payroll_employee_last_name"; MySqlCommand cmd = new MySqlCommand(query, dbcon.con); read = cmd.ExecuteReader(); } else { string query = "SELECT * from tbl_payroll_employee_basic ORDER by payroll_employee_last_name"; MySqlCommand cmd = new MySqlCommand(query, dbcon.con); read = cmd.ExecuteReader(); } int y = 3; while (read.Read()) { //initialize box box = new CheckBox(); //set box properties box.Location = new Point(6, y); box.AutoSize = true; box.Tag = read["payroll_employee_id"].ToString(); box.Text = read["payroll_employee_last_name"].ToString() + ", " + read["payroll_employee_first_name"] + " " + read["payroll_employee_middle_name"]; //add box to panel panelEmployee.Controls.Add(box); y += 23; } dbcon.CloseCon(); } //mark check the checkbox if found in dictionary(array) if (empid.Count != 0) { //loop the checkbox foreach (Control c in panelEmployee.Controls) { if (c is CheckBox) { //if company exist in dictionary if (empid.ContainsKey(company_id)) { //if employee found in the dictionary if (empid[company_id].Contains(Convert.ToInt32(c.Tag))) { ((CheckBox)c).CheckState = CheckState.Checked; } } } } } }