private void btnNhanVien_Click(object sender, EventArgs e) { Form nhanVienManagerForm = searchOpenedForm("NhanVienManagerForm"); if (nhanVienManagerForm == null) { nhanVienManagerForm = new NhanVienManagerForm(); } nhanVienManagerForm.Show(); nhanVienManagerForm.Activate(); }
private void nhânViênToolStripMenuItem_Click(object sender, EventArgs e) { Form nhanVienManagerForm = searchOpenedForm("NhanVienManagerForm"); if (nhanVienManagerForm == null) { nhanVienManagerForm = new NhanVienManagerForm(); } nhanVienManagerForm.MdiParent = this; nhanVienManagerForm.Show(); nhanVienManagerForm.Activate(); }
private void btnOK_Click(object sender, EventArgs e) { int gt = 0; DateTime ngaySinh; switch (btnOK.Text) { case "Tìm kiếm": string filter = "1=1"; if (txtMaNV.Text != string.Empty) { filter += string.Format(" AND sMaNhanVien LIKE '%{0}%'", txtMaNV.Text); } if (txtHoTenNV.Text != string.Empty) { filter += string.Format(" AND sTenNhanVien LIKE '%{0}%'", txtHoTenNV.Text); } if (txtDiaChi.Text != string.Empty) { filter += string.Format(" AND sDiaChi LIKE '%{0}%'", txtDiaChi.Text); } if (txtSDT.Text != string.Empty) { filter += string.Format(" AND sSoDienThoai LIKE '%{0}%'", txtSDT.Text); } hienNV(filter); break; case "Sửa": DataTable dtNhanVien = (DataTable)grQuanLyNhanVien.DataSource; DataRow row = dtNhanVien.Rows[grQuanLyNhanVien.CurrentRow.Index]; string manv = row["sMaNhanVien"].ToString(); if (rbNam.Checked == true) { gt = 1; } else { gt = 0; } ngaySinh = dateNgaySinh.Value.Date; NhanVienManagerForm f = new NhanVienManagerForm(); using (SqlConnection conn = new SqlConnection(connectionString)) { using (SqlCommand cmd = new SqlCommand(sqlEditNhanVien, conn)) { cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@sMaNV", manv); cmd.Parameters.AddWithValue("@sTenNV", txtHoTenNV.Text); cmd.Parameters.AddWithValue("@bGioiTinh", gt); cmd.Parameters.AddWithValue("@dNgaySinh", ngaySinh); cmd.Parameters.AddWithValue("@sDiaChi", txtDiaChi.Text); cmd.Parameters.AddWithValue("@sSoDienThoai", txtSDT.Text); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); } ////sdasđđay rồi } showAllNhanVien(); break; case "Thêm": //cau1 //if (txtMaNV.Text != "" && txtDiaChi.Text != "" && txtHoTenNV.Text != "" && txtSDT.Text != "") //{ if (rbNam.Checked == true) { gt = 1; } else { gt = 0; } ngaySinh = dateNgaySinh.Value.Date; using (SqlConnection conn = new SqlConnection(connectionString)) { using (SqlCommand cmd = new SqlCommand(sqlAddNhanVien, conn)) { cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@sMaNV", txtMaNV.Text); cmd.Parameters.AddWithValue("@sTenNV", txtHoTenNV.Text); cmd.Parameters.AddWithValue("@bGioiTinh", gt); cmd.Parameters.AddWithValue("@dNgaySinh", ngaySinh); cmd.Parameters.AddWithValue("@sDiaChi", txtDiaChi.Text); cmd.Parameters.AddWithValue("@sSoDienThoai", txtSDT.Text); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); } // } //} //else //{ // MessageBox.Show("Thông Báo ?","Phải nhập đủ", MessageBoxButtons.OK); //} showAllNhanVien(); break; } } }