private void btnInsertRecord_Click(object sender, EventArgs e) { try { if (tablename == "PHONG_BAN") { dgvData.DataSource = QuanLy.InsertTableDepartment(conn, tablename, pbID, pbTen); pbID = null; pbTen = null; MessageBox.Show("Nhap phong ban moi thanh cong"); } if (tablename == "NHANVIEN") { dgvData.DataSource = QuanLy.InsertTableStaff(conn, tablename, nvID, nvMapb, nvTen, nvLabacsi, nvUserName, nvLuong, nvPhucap); nvID = null; nvMapb = null; nvTen = null; nvLabacsi = null; nvUserName = null; nvLuong = null; nvPhucap = null; MessageBox.Show("Nhap nhan vien moi thanh cong!"); } if (tablename == "TRUC_PHONG_KHAM") { dgvData.DataSource = QuanLy.InsertTableShift(conn, tablename, tpkMaNV, tpkThoigian); tpkMaNV = null; tpkThoigian = null; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void cbbTableView_SelectedValueChanged(object sender, EventArgs e) { try { String Utable = this.cbbTableView.SelectedItem.ToString(); tablename = Utable; dgvTableView.DataSource = QuanLy.getUpdateTable(conn, Utable); dgvTableView.ReadOnly = true; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void cbbUpdate_SelectedValueChanged(object sender, EventArgs e) { try { String Utable = this.cbbUpdate.SelectedItem.ToString(); tablename = Utable; deleteTable = Utable; dgvData.DataSource = QuanLy.getUpdateTable(conn, Utable); if (Utable != "PHONG_BAN" && Utable != "NHANVIEN" && Utable != "TRUC_PHONG_KHAM") { dgvData.ReadOnly = true; } else { dgvData.ReadOnly = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnDeleteRecord_Click(object sender, EventArgs e) { try { if (deleteTable == "PHONG_BAN") { dgvData.DataSource = QuanLy.DeleteTableDepartment(conn, tablename, deleteID); } if (deleteTable == "NHANVIEN") { dgvData.DataSource = QuanLy.DeleteTableStaff(conn, tablename, deleteID); } if (deleteTable == "TRUC_PHONG_KHAM") { dgvData.DataSource = QuanLy.DeleteTableShift(conn, tablename, deleteID); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { try { string username = f_DangNhap_Username_textbox.Text; username = username.ToLower(); string password = f_DangNhap_Password_textbox.Text; //Oracle db = new Oracle(); //MainForm = new ChucNang_form(); LogedIn_Username = username; //MainForm.username = f_DangNhap_Username_textbox.Text; //MessageBox.Show("Da dang nhap voi username:"******"sy") == true || username.StartsWith("dba") == true) { conn = Oracle.CreateDBConnection(username, password); ChucNang_form MainFrom = new ChucNang_form(this); MainFrom.Show(); } if (username.StartsWith("tt") == true) { conn = TiepTan.CreateDBConnection(username, password); try { // conn.Open(); FormTiepTan tieptan = new FormTiepTan(this); tieptan.Show(); } catch { MessageBox.Show("Đăng nhập thất bại!"); } } if (username.StartsWith("kt") == true) { conn = Oracle.CreateDBConnection(username, password); conn.Open(); FormKeToan ketoan = new FormKeToan(this); ketoan.Show(); } if (username.StartsWith("bs") == true) { conn = BacSi.CreateDBConnection(username, password); try { conn.Open(); FormBacSi bacsi = new FormBacSi(this); bacsi.Show(); } catch { MessageBox.Show("Đăng nhập thất bại!"); } } if (username.StartsWith("bt") == true) { conn = BacSi.CreateDBConnection(username, password); try { FormBanThuoc bt = new FormBanThuoc(this); bt.Show(); } catch { MessageBox.Show("Đăng nhập thất bại!"); } } if (username.StartsWith("tv") == true) { conn = TaiVu.CreateDBConnection(username, password); try { conn.Open(); FormTaiVu f_tv = new FormTaiVu(this); f_tv.Show(); //this.Hide(); } catch (Exception ex) { MessageBox.Show("Đăng nhập thất bại!"); } } if (username.StartsWith("ql002") == true) { conn = TaiVu.CreateDBConnection(username, password); try { conn.Open(); FormQuanLiTaiVu f_qltv = new FormQuanLiTaiVu(this); f_qltv.Show(); //this.Hide(); } catch (Exception ex) { MessageBox.Show("Đăng nhập thất bại!"); } } if (username.StartsWith("ql001") == true) { conn = QuanLy.CreateDBConnection(username, password); try { conn.Open(); QLTNNS f_qltnns = new QLTNNS(this); f_qltnns.Show(); //this.Hide(); } catch (Exception ex) { MessageBox.Show("Đăng nhập thất bại!"); } } if (username.StartsWith("ql003") == true) { conn = QuanLy.CreateDBConnection(username, password); try { conn.Open(); QLCM f_qlcm = new QLCM(this); f_qlcm.Show(); //this.Hide(); } catch (Exception ex) { MessageBox.Show("Đăng nhập thất bại!"); } } } catch (Exception er) { MessageBox.Show("Error: " + er); } }
private void dgvData_CellValueChanged(object sender, DataGridViewCellEventArgs e) { try { String ColName = this.dgvData.Columns[0].Name; String id = dgvData.Rows[e.RowIndex].Cells[ColName].Value.ToString(); //MessageBox.Show(ColName); int temp; if (id == "") { temp = 0; } else { temp = Convert.ToInt32(dgvData.Rows[e.RowIndex].Cells[ColName].Value.ToString()); } if (temp == 0) { if (tablename == "PHONG_BAN") { int c = QuanLy.getCount(conn, tablename) + 1; pbID = c.ToString(); String tenpb = dgvData.Rows[e.RowIndex].Cells["TENPB"].Value.ToString(); pbTen = tenpb; //dgvData.DataSource = QuanLy.InsertTableDepartment(conn, tablename, c.ToString(), tenpb); } if (tablename == "NHANVIEN") { int c = QuanLy.getCount(conn, tablename) + 1; nvID = c.ToString(); String mapb = dgvData.Rows[e.RowIndex].Cells["MAPB"].Value.ToString(); nvMapb = mapb; String tennv = dgvData.Rows[e.RowIndex].Cells["TENNV"].Value.ToString(); nvTen = tennv; String labacsi = dgvData.Rows[e.RowIndex].Cells["LABACSI"].Value.ToString(); nvLabacsi = labacsi; String username = dgvData.Rows[e.RowIndex].Cells["username"].Value.ToString(); nvUserName = username; String luong = dgvData.Rows[e.RowIndex].Cells["LUONGCOBAN"].Value.ToString(); nvLuong = luong; String phucap = dgvData.Rows[e.RowIndex].Cells["PHUCAP"].Value.ToString(); nvPhucap = phucap; //dgvData.DataSource = QuanLy.InsertTableStaff(conn, tablename, c.ToString(), mapb, tennv, labacsi, username, luong, phucap); } if (tablename == "TRUC_PHONG_KHAM") { //int c = QuanLy.getCount(conn, tablename) + 1; String manv = dgvData.Rows[e.RowIndex].Cells["MANV"].Value.ToString(); tpkMaNV = manv; DateTime today = DateTime.Today; String thoigian = today.ToString("dd-MMMM-yy"); tpkThoigian = thoigian; //MessageBox.Show(thoigian); //dgvData.DataSource = QuanLy.InsertTableShift(conn, tablename, manv, thoigian); } } else { if (tablename == "PHONG_BAN") { String tenpb = dgvData.Rows[e.RowIndex].Cells["TENPB"].Value.ToString(); dgvData.DataSource = QuanLy.UpdateTableDepartment(conn, tablename, temp.ToString(), tenpb); } if (tablename == "NHANVIEN") { String mapb = dgvData.Rows[e.RowIndex].Cells["MAPB"].Value.ToString(); String tennv = dgvData.Rows[e.RowIndex].Cells["TENNV"].Value.ToString(); String labacsi = dgvData.Rows[e.RowIndex].Cells["LABACSI"].Value.ToString(); String username = dgvData.Rows[e.RowIndex].Cells["username"].Value.ToString(); String luong = dgvData.Rows[e.RowIndex].Cells["LUONGCOBAN"].Value.ToString(); String phucap = dgvData.Rows[e.RowIndex].Cells["PHUCAP"].Value.ToString(); dgvData.DataSource = QuanLy.UpdateTableStaff(conn, tablename, temp.ToString(), mapb, tennv, labacsi, username, luong, phucap); } if (tablename == "TRUC_PHONG_KHAM") { DateTime today = DateTime.Today; String thoigian = today.ToString("dd-MMMM-yy"); String manv = dgvData.Rows[e.RowIndex].Cells["MANV"].Value.ToString(); //String thoigian = dgvData.Rows[e.RowIndex].Cells["THOIGIANBATDAUTRUC"].Value.ToString(); dgvData.DataSource = QuanLy.UpdateTableShift(conn, tablename, temp.ToString(), manv, thoigian); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }