private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { try { if (comboBox2.SelectedIndex != -1) { con3.dataGet3("select * from [dbo].[EmpAttendence] where EmpId = '" + textBox1.Text + "'and Year='" + comboBox1.Text + "'and Month='" + comboBox2.Text + "'"); DataTable dt = new DataTable(); con3.sda3.Fill(dt); if (dt.Rows.Count > 0) { textBox1.Text = dt.Rows[0]["TotalDays"].ToString(); textBox2.Text = dt.Rows[0]["WorkingDays"].ToString(); textBox3.Text = dt.Rows[0]["PresentDays"].ToString(); textBox4.Text = dt.Rows[0]["AbsentDays"].ToString(); } else { textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void disp_data() { try { con3.dataGet3("select * from [dbo].[Employee_Register]"); DataTable dt = new DataTable(); con3.sda3.Fill(dt); dataGridView1.Rows.Clear(); foreach (DataRow row in dt.Rows) { int n = dataGridView1.Rows.Add(); dataGridView1.Rows[n].Cells["EmpId"].Value = row["EmpId"].ToString(); dataGridView1.Rows[n].Cells["EmpName"].Value = row["Name"].ToString(); dataGridView1.Rows[n].Cells["Mobile"].Value = row["Mobile"].ToString(); dataGridView1.Rows[n].Cells["Email"].Value = row["Email"].ToString(); dataGridView1.Rows[n].Cells["Dob"].Value = Convert.ToDateTime(row["Dob"].ToString()).ToString("dd-MM-yyyy"); dataGridView1.Rows[n].Cells["BankDetails"].Value = row["BankDetails"].ToString(); dataGridView1.Rows[n].Cells["Address"].Value = row["Address"].ToString(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
void LoadData() { try { con3.dataGet3("Select * from [dbo].[Budget] "); DataTable dt = new DataTable(); con3.sda3.Fill(dt); dataGridView1.Rows.Clear(); foreach (DataRow row in dt.Rows) { int n = dataGridView1.Rows.Add(); dataGridView1.Rows[n].Cells["Year"].Value = row["Year"].ToString(); dataGridView1.Rows[n].Cells["Month"].Value = row["Month"].ToString(); dataGridView1.Rows[n].Cells["CostForInventory"].Value = row["CostForInventory"].ToString(); dataGridView1.Rows[n].Cells["WaterBill"].Value = row["WaterBill"].ToString(); dataGridView1.Rows[n].Cells["LightBill"].Value = row["LightBill"].ToString(); dataGridView1.Rows[n].Cells["EmployeeTotalSalary"].Value = row["EmployeeTotalSalary"].ToString(); dataGridView1.Rows[n].Cells["Other"].Value = row["Other"].ToString(); dataGridView1.Rows[n].Cells["TotalIncome"].Value = row["TotalIncome"].ToString(); dataGridView1.Rows[n].Cells["NetIncomeForMonth"].Value = row["NetIncomeForMonth"].ToString(); dataGridView1.Rows[n].Cells["NetIncomeForYear"].Value = row["NetIncomeForYear"].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void textBox5_TextChanged(object sender, EventArgs e) { try { if (textBox5.Text.Length > 0) { this.dgview.Visible = true; dgview.BringToFront(); Search(90, 70, 400, 200, "Emp Id,Emp Name", "100,0"); this.dgview.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.employee_MouseDoubleClick); Connection3 con3 = new Connection3(); con3.dataGet3("Select Top(10) EmpId,Name From [dbo].[Employee_Register] where EmpId like '" + textBox5.Text + "%'"); DataTable dt = new DataTable(); con3.sda3.Fill(dt); dgview.Rows.Clear(); foreach (DataRow row in dt.Rows) { int n = dgview.Rows.Add(); dgview.Rows[n].Cells[0].Value = row["EmpId"].ToString(); dgview.Rows[n].Cells[1].Value = row["Name"].ToString(); } } else { dgview.Visible = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }