void LoadTenThucAn() { try { string query = "Select * from ThucAn"; DataTable data = KetNoi.Istance.ExcuteQuerry(query); cbTenThucAn.DataSource = data; cbTenThucAn.DisplayMember = "tenThucAn"; cbTenThucAn.ValueMember = "maThucAn"; } catch { Alert a = new Alert("Dữ liệu không hợp lệ hoặc lỗi kết nối.", AlertType.error); a.ShowDialog(); } }
void loadBo() { try { string query = "Select * from danBo where ngayXuatChuong is null"; DataTable data = KetNoi.Istance.ExcuteQuerry(query); cbMaBo.DataSource = data; cbMaBo.DisplayMember = "maBo"; cbMaBo.ValueMember = "maBo"; } catch { Alert a = new Alert("Dữ liệu không hợp lệ hoặc lỗi kết nối.", AlertType.error); a.ShowDialog(); } }
void loadNhaCungCap() { try { string query = "select * from nhaCungCap"; DataTable Data = KetNoi.Istance.ExcuteQuerry(query); cbNcc.DataSource = Data; cbNcc.DisplayMember = "tenNCC"; cbNcc.ValueMember = "maNCC"; cbNcc.Text = ""; } catch { Alert a = new Alert("Dữ liệu không hợp lệ hoặc lỗi kết nối.", AlertType.error); a.ShowDialog(); } }
void loadLuongSua() { try { string query = "Select soLuongSua from khosua"; DataTable data = KetNoi.Istance.ExcuteQuerry(query); foreach (DataRow item in data.Rows) { lbLuongSua.Text = item["soluongsua"].ToString(); } } catch { Alert a = new Alert("Dữ liệu không hợp lệ hoặc lỗi kết nối.", AlertType.error); a.ShowDialog(); } }
private void btnSua_Click_1(object sender, EventArgs e) { if (tbMaNv.text == "") { Alert a = new Alert("Vui lòng chọn dòng cần sửa!", AlertType.info); a.ShowDialog(); } else { dem = 2; groupBox1.Enabled = true; btnThem.Enabled = false; btnSua.Enabled = false; btnXoa.Enabled = false; dgvChuongTrai.Enabled = false; } }
void getTenCHuong() { try { string query = "Select * from ChuongTrai"; DataTable data = KetNoi.Istance.ExcuteQuerry(query); cbTenChuong.DataSource = data; cbTenChuong.DisplayMember = "tenChuong"; cbTenChuong.ValueMember = "maChuong"; cbTenChuong.Text = ""; } catch { Alert a = new Alert("Dữ liệu không hợp lệ hoặc lỗi kết nối.", AlertType.error); a.ShowDialog(); } }
private void bunifuThinButton23_Click(object sender, EventArgs e) { if (bien == 0) { Alert a = new Alert("Hiện tại chưa có dữ liệu để xuất", AlertType.error); a.ShowDialog(); } else { string query = "select convert(nvarchar(30), ngayMua, 23)as ngayLap,sum(thanhTien)as tongTien from HDBanBo " + "where ngayMua between N'" + dtpkTuNgay.Text + " 00:00:00' and N'" + dtpkDenNgay.Text + " 23:59:59' group by convert(nvarchar(30), ngayMua, 23)"; this.Hide(); FBieuDo fbd = new FBieuDo(query); fbd.ShowDialog(); this.Show(); } }
private void bunifuFlatButton4_Click(object sender, EventArgs e) { if (txMaNv.Text == "") { Alert a = new Alert("Hãy Chọn Nhân Viên Cần Sửa.", AlertType.error); a.ShowDialog(); } else { dem = 2; panelNV.Enabled = true; txMaNv.ReadOnly = true; linkLb.Visible = false; btnAnh.Visible = true; btnThem.Enabled = false; btnSua.Enabled = false; btnXoa.Enabled = false; } }
void LoadCTHD(string maHd) { string query = ""; try { query = "select d.maBo,d.gioiTinh,d.trongLuong, d.idCategory,cth.giaBoNhap,cth.LoaiNhap,d.MaChuong" + " from HdNhapBo H,DanBo d, CTHDNhapBo cth,categoryBo C" + " where H.maHD = cth.maHD and d.maBo = cth.maBo and C.idCategory = d.idCategory and cth.maHd = '" + maHd + "'"; DataTable data = KetNoi.Istance.ExcuteQuerry(query); data = KetNoi.Istance.ExcuteQuerry(query); dtgvCTHD.DataSource = data; } catch { Alert a = new Alert("Dữ liệu không hợp lệ hoặc lỗi kết nối.", AlertType.error); a.ShowDialog(); } }
private void bunifuFlatButton2_Click(object sender, EventArgs e) { if (lbTongSoCHo.Text == "0") { Alert a = new Alert("Vui Lòng Chọn Chuồng.", AlertType.error); a.ShowDialog(); } else if (txMaBo.Text == "") { Alert a = new Alert("Vui Lòng Chọn Bò.", AlertType.error); a.ShowDialog(); } else { try { string mabo = txMaBo.Text; string machuong = cbTenChuong.SelectedValue.ToString(); string query = "Delete DanBo where maBo='" + mabo + "'"; DataTable data = KetNoi.Istance.ExcuteQuerry(query); Alert a = new Alert("Xóa Thành Công.", AlertType.success); a.ShowDialog(); loadChuong(); showBo(machuong); lbtrong.Text = (getTongSoCHo(cbTenChuong.Text) - dtgvChuongTrai.RowCount).ToString(); txMaBo.ResetText(); txTrongLuong.ResetText(); panelInfor.Enabled = false; txMaBo.ReadOnly = false; dem = 0; } catch { Alert a = new Alert("Lỗi Kết nối hoặc \n do mã bò có liên quan đến các bảng khác", AlertType.error); a.ShowDialog(); } } }
void loadNhanVien() { try { string query = "select * from NhanVien"; DataTable Data = KetNoi.Istance.ExcuteQuerry(query); cbMaNv.DataSource = Data; cbMaNv.DisplayMember = "maNv"; cbMaNv.ValueMember = "maNv"; if (MaNv != "") { cbMaNv.Text = MaNv; cbMaNv.Enabled = false; } } catch { Alert a = new Alert("Dữ liệu không hợp lệ hoặc lỗi kết nối.", AlertType.error); a.ShowDialog(); } }
private void bunifuThinButton21_Click(object sender, EventArgs e) { if (chbNhomk.Checked == true) { Properties.Settings.Default.UserName = txtTenDn.Text; Properties.Settings.Default.PassWord = txPass.Text; Properties.Settings.Default.Save(); } else if (chbNhomk.Checked == false) { Properties.Settings.Default.UserName = ""; Properties.Settings.Default.PassWord = ""; Properties.Settings.Default.Save(); } string querry = "Select * from account where tenDn='" + txtTenDn.Text + "' and matKhau='" + Encrypt(txPass.Text) + "'"; DataTable data = KetNoi.Istance.ExcuteQuerry(querry); if (data.Rows.Count > 0) { Alert a = new Alert("Đăng nhập thành công.", AlertType.success); string maNv = ""; foreach (DataRow item in data.Rows) { maNv = item["maNv"].ToString(); } a.ShowDialog(); Fmain fm = new Fmain(maNv, txtTenDn.Text); this.Hide(); fm.ShowDialog(); this.Show(); } else { Alert a = new Alert("Tên đăng nhập hoặc mật khẩu không đúng", AlertType.error); a.ShowDialog(); } }
void loadTyLe() { try { double tong = 0; string query = "select count(*)as soLuong,CategoryName from DanBo,categoryBo where DanBo.idCategory=categoryBo.idCategory and ngayXuatChuong is null and maChuong is not null group by CategoryName "; DataTable data = KetNoi.Istance.ExcuteQuerry(query); foreach (DataRow item in data.Rows) { tong = tong + int.Parse(item["soLuong"].ToString()); } lbTong.Text = tong.ToString(); foreach (DataRow item in data.Rows) { chart1.Series["Series1"].Points.AddXY(item["CategoryName"], (double.Parse(item["soLuong"].ToString())) / tong); } } catch { Alert a = new Alert("Dữ liệu không hợp lệ hoặc lỗi kết nối.", AlertType.error); a.ShowDialog(); } }
private void bunifuFlatButton3_Click(object sender, EventArgs e) { try { if (tam == 1) { string query = "Insert into PhanViec values('" + cbmaNvPQ.Text + "',N'" + cbTenCv.Text + "')"; DataTable data = KetNoi.Istance.ExcuteQuerry(query); Alert a = new Alert("Thêm thành công.", AlertType.success); a.ShowDialog(); loadCongViec(); panelPQ.Enabled = false; dem = 0; btnThemPQ.Enabled = true; btnXoaPQ.Enabled = true; } } catch { Alert a = new Alert("Dữ liệu không hợp lệ hoặc lỗi kết nối.", AlertType.error); a.ShowDialog(); } }
private void bunifuFlatButton5_Click(object sender, EventArgs e) { if (tbTenNv.Text == "") { Alert a = new Alert("Chọn tài khoản muốn xóa!", AlertType.info); a.ShowDialog(); } else { try { string querry = "delete account where tenDn = '" + tbTenTk.Text + "'"; DataTable data = KetNoi.Istance.ExcuteQuerry(querry); Alert a = new Alert("Xóa thành công!", AlertType.success); a.ShowDialog(); LoadTkNv(); } catch { Alert a = new Alert("Xóa thất bại!", AlertType.success); a.ShowDialog(); } } }
private void bunifuFlatButton1_Click(object sender, EventArgs e) { if (lbTongSoCHo.Text == "0") { Alert a = new Alert("Vui Lòng Chọn Chuồng.", AlertType.error); a.ShowDialog(); } else if (txMaBo.Text == "") { Alert a = new Alert("Vui Lòng Chọn Bò.", AlertType.error); a.ShowDialog(); } else { dem = 2; btnThem.Enabled = false; btnSua.Enabled = false; btnXoa.Enabled = false; cbTenChuong.Enabled = true; panelInfor.Enabled = true; dtpkNgayNhap.Enabled = true; txMaBo.ReadOnly = true; } }
private void bt_Click(object sender, EventArgs e) { try { string idChuong = (sender as System.Windows.Forms.Button).Name; showBo(idChuong); cbTenChuong.Text = (sender as System.Windows.Forms.Button).Tag.ToString(); lbTenChuong.Text = idChuong; string querry = "Select * from ChuongTrai where maChuong='" + idChuong + "'"; DataTable data = KetNoi.Istance.ExcuteQuerry(querry); foreach (DataRow row in data.Rows) { lbTongSoCHo.Text = row["tongSoCho"].ToString(); lbtrong.Text = row["soChoConTrong"].ToString(); } } catch { Alert a = new Alert("Dữ liệu không hợp lệ hoặc lỗi kết nối.", AlertType.error); a.ShowDialog(); } }
private void bunifuFlatButton3_Click(object sender, EventArgs e) { if (dem == 1) { try { if (txMaBo.Text == "" || (rdbCai.Checked == false && rdbDuc.Checked == false) || txTrongLuong.Text == "") { Alert a = new Alert("Bạn hãy nhập đủ thông tin", AlertType.error); a.ShowDialog(); } else { string mabo = txMaBo.Text; string gioitinh = ""; if (rdbCai.Checked == true) { gioitinh = "Cái"; } else { gioitinh = "Đực"; } string tl = txTrongLuong.Text; string idcategory = cbTrangThai.SelectedValue.ToString(); string machuong = cbTenChuong.SelectedValue.ToString(); if (KiemTraMabo(mabo) == false) { Alert b = new Alert("Mã bò đã tồn tại", AlertType.error); b.ShowDialog(); } else { string query = "Insert into DanBo values('" + mabo + "',N'" + gioitinh + "','" + tl + "','" + idcategory + "','" + cbTenChuong.SelectedValue + "',getDate(),null)"; DataTable data = KetNoi.Istance.ExcuteQuerry(query); Alert a = new Alert("Thêm thành Công", AlertType.success); a.ShowDialog(); txMaBo.ResetText(); txTrongLuong.ResetText(); panelInfor.Enabled = false; dem = 0; loadChuong(); showBo(machuong); panelInfor.Enabled = false; lbtrong.Text = (getTongSoCHo(cbTenChuong.Text) - dtgvChuongTrai.RowCount).ToString(); btnSua.Enabled = true; btnXoa.Enabled = true; btnThem.Enabled = true; } } } catch { Alert a = new Alert("Lỗi Kết Nối", AlertType.error); a.ShowDialog(); } } if (dem == 2) { if ((rdbCai.Checked == false && rdbDuc.Checked == false) || txTrongLuong.Text == "") { Alert a = new Alert("Bạn hãy nhập đủ thông tin", AlertType.error); a.ShowDialog(); } else { try { string mabo = txMaBo.Text; string gioitinh = ""; if (rdbCai.Checked == true) { gioitinh = "Cái"; } else { gioitinh = "Đực"; } string tl = txTrongLuong.Text; string idcategory = cbTrangThai.SelectedValue.ToString(); string machuong = cbTenChuong.Text; if (machuong != lbTenChuong.Text && demBo(cbTenChuong.SelectedValue.ToString()) == getTongSoCHo(machuong)) { Alert a = new Alert("Chuồng bạn chọn đã đủ chỗ", AlertType.error); a.ShowDialog(); } else { //MessageBox.Show(demBo(cbTenChuong.SelectedValue.ToString()) + " "+ getTongSoCHo(machuong)); string query = "Update DanBo set gioiTinh=N'" + gioitinh + "',trongLuong='" + tl + "',idcategory='" + idcategory + "',maChuong='" + cbTenChuong.SelectedValue + "',ngayNhapCHuong=N'" + dtpkNgayNhap.Value + "' where maBo='" + mabo + "'"; DataTable data = KetNoi.Istance.ExcuteQuerry(query); Alert a = new Alert("Sửa Thành Công", AlertType.success); dem = 0; a.ShowDialog(); panelInfor.Enabled = false; txMaBo.ReadOnly = false; dtpkNgayNhap.Enabled = true; loadChuong(); showBo(cbTenChuong.SelectedValue.ToString()); txMaBo.ResetText(); lbTongSoCHo.Text = getTongSoCHo(cbTenChuong.Text.ToString()).ToString(); lbtrong.Text = (getTongSoCHo(cbTenChuong.Text) - dtgvChuongTrai.RowCount).ToString(); txTrongLuong.ResetText(); btnSua.Enabled = true; btnXoa.Enabled = true; btnThem.Enabled = true; } } catch { Alert a = new Alert("Dữ liệu không hợp lệ hoặc lỗi kết nối.", AlertType.error); a.ShowDialog(); } } } }
private void btnLuu_Click(object sender, EventArgs e) { try { if (dem == 1) { string maKh = tbMaKH.text; string tenkh = tbTenKH.text; string email = tbEmail.text; decimal sodienthoai = 0; if (tbTenKH.text == "" || tbEmail.text == "" || tbSdt.text == "") { Alert a = new Alert("Vui lòng nhập đủ thông tin!", AlertType.info); a.ShowDialog(); } else if (kiemTra(maKh) == true) { Alert a = new Alert("Mã khách hàng đã tồn tại!", AlertType.error); a.ShowDialog(); } else { try { sodienthoai = decimal.Parse(tbSdt.text); } catch { Alert a = new Alert("Số điện thoại nhập không hợp lệ!", AlertType.error); a.ShowDialog(); } try { string querry = "insert into KhachHang(tenKh,email,sodt) values (N'" + tenkh + "',N'" + email + "','" + sodienthoai + "')"; DataTable data = KetNoi.Istance.ExcuteQuerry(querry); Alert a = new Alert("Thêm thành công", AlertType.success); a.ShowDialog(); setNull(); LoadData(); } catch { Alert a = new Alert("Thêm thất bại!", AlertType.info); a.ShowDialog(); } } } else if (dem == 2) { string maKH = tbMaKH.text; string tenKH = tbTenKH.text; string email = tbEmail.text; decimal sdt = 0; if (tbTenKH.text == "") { Alert a = new Alert("Vui lòng chọn đối tượng muốn sửa!", AlertType.error); a.ShowDialog(); } else if (tbMaKH.text == "" || tbTenKH.text == "" || tbEmail.text == "" || tbSdt.text == "") { Alert a = new Alert("Vui lòng nhập đủ thông tin!", AlertType.error); a.ShowDialog(); } else { try { sdt = decimal.Parse(tbSdt.text); } catch { Alert a = new Alert("Số điện thoại nhập không hợp lệ!", AlertType.error); a.ShowDialog(); } try { string querry = "update KhachHang set tenKh = N'" + tenKH + "',email = N'" + email + "',sodt = '" + sdt + "' where maKh = '" + maKH + "'"; DataTable data = KetNoi.Istance.ExcuteQuerry(querry); Alert a = new Alert("Sửa Thành Công!", AlertType.info); a.ShowDialog(); setNull(); LoadData(); } catch { Alert a = new Alert("Sửa Thất Bại!", AlertType.info); a.ShowDialog(); } } } } catch { Alert a = new Alert("Dữ liệu không hợp lệ hoặc lỗi kết nối.", AlertType.error); a.ShowDialog(); } }
private void bunifuThinButton22_Click(object sender, EventArgs e) { if (bien == 0) { Alert a = new Alert("Hiện tại chưa có dữ liệu để xuất", AlertType.error); a.ShowDialog(); } else { bool fileError = true; try { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "PDF(*.pdf)|*.pdf"; saveFileDialog.FileName = "DoanhThuBanBo.pdf"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { fileError = false; if (File.Exists(saveFileDialog.FileName)) { try { fileError = false; File.Delete(saveFileDialog.FileName); } catch { fileError = true; } } } if (!fileError) { string deviceInfo = "<DeviceInfo>" + " <OutputFormat>EMF</OutputFormat>" + " <PageWidth>9in</PageWidth>" + " <PageHeight>6in</PageHeight>" + " <MarginTop>0.25in</MarginTop>" + " <MarginLeft>0.25in</MarginLeft>" + " <MarginRight>0.25in</MarginRight>" + " <MarginBottom>0.25in</MarginBottom>" + "</DeviceInfo>"; byte[] bytes = reportViewer1.LocalReport.Render( "PDF", deviceInfo); FileStream fs = new FileStream(saveFileDialog.FileName, FileMode.Create); fs.Write(bytes, 0, bytes.Length); fs.Close(); path = Convert.ToString(Path.GetFullPath(saveFileDialog.FileName)); Alert a = new Alert("Xuất thành công", AlertType.success); a.ShowDialog(); } } catch { Alert a = new Alert("Dữ liệu không hợp lệ hoặc lỗi kết nối.", AlertType.error); a.ShowDialog(); } } }
void exFile(DataGridView data) { bool fileError = true; try { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "XLS(*.xls)|*.xls"; saveFileDialog.FileName = "HoaDonNhapBo.xls"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { fileError = false; if (File.Exists(saveFileDialog.FileName)) { try { fileError = false; File.Delete(saveFileDialog.FileName); } catch { fileError = true; } } } if (!fileError) { Application xlApp; Workbook xlWorkBook; Worksheet xlWorkSheet; object misValue = System.Reflection.Missing.Value; xlApp = new Application(); xlWorkBook = xlApp.Workbooks.Add(misValue); xlWorkSheet = (Worksheet)xlWorkBook.Worksheets.get_Item(1); xlWorkSheet.Columns.ColumnWidth = 25; string qrcode = ""; if (getQR() == "") { createQR(); qrcode = getQR(); } else { qrcode = getQR(); } xlWorkSheet.Shapes.AddPicture(qrcode, MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoCTrue, 50, 5, 100, 100); //add some text xlWorkSheet.Cells[7, 1] = " Hóa Đơn Nhập Bò "; xlWorkSheet.Cells[8, 1] = "Mã Hóa Đơn: " + cbmaHD.Text; xlWorkSheet.Cells[8, 2] = "Ngày Lập: " + NgayLap; xlWorkSheet.Cells[9, 1] = "Mã Nhân Viên: " + MaNv; xlWorkSheet.Cells.Font.Bold = true; int dem = 10; xlWorkSheet.Rows[dem].HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter; if (dtgvCTHD.RowCount > 0) { for (int i = 1; i < data.Columns.Count + 1; i++) { xlWorkSheet.Cells[10, i] = data.Columns[i - 1].HeaderText; } for (int i = 0; i < data.Rows.Count; i++) { dem += 1; xlWorkSheet.Rows[dem].HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter; for (int j = 0; j < data.Columns.Count; j++) { if (data.Rows[i].Cells[j].Value != null) { xlWorkSheet.Cells[i + 11, j + 1] = data.Rows[i].Cells[j].Value.ToString(); } else { xlWorkSheet.Cells[i + 11, j + 1] = ""; } } } } xlWorkSheet.Cells[dem + 1, 1] = "Tổng Tiền " + txTongTien.Text; xlWorkSheet.Rows[dem + 1].Font.Color = Color.Red; xlWorkSheet.Rows[dem + 1].Font.Bold = true; xlWorkSheet.Rows[dem + 1].HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter; xlWorkBook.SaveAs(saveFileDialog.FileName, XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue); xlWorkBook.Close(true, misValue, misValue); xlApp.Quit(); string sql = "Update HDNhapBo set trangThai='1' where maHd='" + cbmaHD.Text + "'"; KetNoi.Istance.ExcuteQuerry(sql); Alert a = new Alert("In thành công", AlertType.success); a.ShowDialog(); kiemTra(cbmaHD.Text); } } catch { Alert a = new Alert("Dữ liệu không hợp lệ hoặc lỗi kết nối.", AlertType.error); a.ShowDialog(); } }
private void bunifuFlatButton2_Click(object sender, EventArgs e) { try { if (dem == 1) { string tenCh = tbTenChuong.text; decimal tongCho = 0; string manv = tbMaNv.text; try { tongCho = decimal.Parse(tbTongCho.text); } catch { Alert a = new Alert("Tổng số chỗ hoặc số chỗ trống nhập không hợp lệ!", AlertType.error); a.ShowDialog(); return; } if (tbTenChuong.text == "" || tbTongCho.text == "" || tbMaNv.text == "") { Alert a = new Alert("Vui lòng nhập đủ thông tin!", AlertType.info); a.ShowDialog(); } else if (kiemTra(tenCh) == true) { Alert a = new Alert("Tên chuồng đã tồn tại!", AlertType.error); a.ShowDialog(); } else { try { tongCho = decimal.Parse(tbTongCho.text); } catch { Alert a = new Alert("Tổng số chỗ hoặc số chỗ trống nhập không hợp lệ!", AlertType.error); a.ShowDialog(); } try { string querry = "insert into ChuongTrai(tenChuong,tongsocho,sochocontrong,manv) values (N'" + tenCh + "',N'" + tongCho + "','" + tongCho + "','" + manv + "')"; DataTable data = KetNoi.Istance.ExcuteQuerry(querry); Alert a = new Alert("Thêm thành công", AlertType.success); a.ShowDialog(); setNull(); LoadData(); dem = 0; btnThem.Enabled = true; btnSua.Enabled = true; btnXoa.Enabled = true; dgvChuongTrai.Enabled = true; } catch { Alert a = new Alert("Thêm thất bại!", AlertType.info); a.ShowDialog(); } } } else if (dem == 2) { string tenCh = tbTenChuong.text; string tongCho = tbTongCho.text; string manv = tbMaNv.text; if (tbTenChuong.text == "") { Alert a = new Alert("Vui lòng chọn đối tượng muốn sửa!", AlertType.error); a.ShowDialog(); } else if (tbTenChuong.text == "" || tbTongCho.text == "" || tbMaNv.text == "") { Alert a = new Alert("Vui lòng nhập đủ thông tin!", AlertType.error); a.ShowDialog(); } else if (tbTenChuong.text != tenChuongTrai && kiemTra(tbTenChuong.text) == true) { Alert a = new Alert("Tên chuồng đã tồn tại!", AlertType.error); a.ShowDialog(); } else if (int.Parse(tongCho) < DemBo(txmachuong.Text)) { Alert a = new Alert("Số bò trong chuồng phải ít hơn hoặc bằng \n tổng số chỗ!", AlertType.error); a.ShowDialog(); } else { try { string querry = "update ChuongTrai set tenChuong = N'" + tenCh + "',tongsocho=N'" + tongCho + "',manv = '" + manv + "' where maChuong = N'" + txmachuong.Text + "'"; DataTable data = KetNoi.Istance.ExcuteQuerry(querry); Alert a = new Alert("Sửa Thành Công!", AlertType.success); a.ShowDialog(); setNull(); LoadData(); dem = 0; btnThem.Enabled = true; btnSua.Enabled = true; btnXoa.Enabled = true; dgvChuongTrai.Enabled = true; } catch { Alert a = new Alert("Sửa Thất Bại!", AlertType.info); a.ShowDialog(); } } } } catch { Alert a = new Alert("Dữ liệu không hợp lệ hoặc lỗi kết nối.", AlertType.error); a.ShowDialog(); } }
private void bunifuFlatButton2_Click(object sender, EventArgs e) { try { if (dem == 1) { groupBox1.Enabled = true; string maNcc = tbMaNcc.text; string tenNcc = tbTenNcc.text; string diachi = tbDiaChi.text; decimal sodienthoai = 123; if (tbTenNcc.text == "" || tbDiaChi.text == "" || tbSdt.text == "") { Alert a = new Alert("Vui lòng nhập đủ thông tin!", AlertType.info); a.ShowDialog(); } else { try { sodienthoai = decimal.Parse(tbSdt.text); } catch { Alert a = new Alert("Số điện thoại nhập không hợp lệ!", AlertType.error); a.ShowDialog(); } try { string querry = "insert into NhaCungCap(tenNCC,diachi,sodt) values (N'" + tenNcc + "',N'" + diachi + "','" + sodienthoai + "')"; DataTable data = KetNoi.Istance.ExcuteQuerry(querry); Alert a = new Alert("Thêm thành công", AlertType.success); a.ShowDialog(); setNull(); LoadData(); dem = 0; btnXoa.Enabled = true; btnSua.Enabled = true; btnThem.Enabled = true; groupBox1.Enabled = false; } catch { Alert a = new Alert("Thêm thất bại!", AlertType.info); a.ShowDialog(); } } } else if (dem == 2) { groupBox1.Enabled = true; string maNcc = tbMaNcc.text; string tenNcc = tbTenNcc.text; string diachi = tbDiaChi.text; decimal sdt = 0; if (tbTenNcc.text == "") { Alert a = new Alert("Vui lòng chọn đối tượng muốn sửa!", AlertType.error); a.ShowDialog(); } else if (tbTenNcc.text == "" || tbDiaChi.text == "" || tbSdt.text == "") { Alert a = new Alert("Vui lòng nhập đủ thông tin!", AlertType.error); a.ShowDialog(); } else { try { sdt = decimal.Parse(tbSdt.text); } catch { Alert a = new Alert("Số điện thoại nhập không hợp lệ!", AlertType.error); a.ShowDialog(); } try { string querry = "update NhaCungCap set tenNcc = N'" + tenNcc + "',diachi=N'" + diachi + "',sodt = '" + sdt + "' where maNcc = '" + maNcc + "'"; DataTable data = KetNoi.Istance.ExcuteQuerry(querry); Alert a = new Alert("Sửa Thành Công!", AlertType.info); a.ShowDialog(); btnXoa.Enabled = true; btnSua.Enabled = true; btnThem.Enabled = true; setNull(); dem = 0; LoadData(); groupBox1.Enabled = false; } catch { Alert a = new Alert("Sửa Thất Bại!", AlertType.info); a.ShowDialog(); } } } } catch { Alert a = new Alert("Dữ liệu không hợp lệ hoặc lỗi kết nối.", AlertType.error); a.ShowDialog(); } }
private void btnLuu_Click(object sender, EventArgs e) { try { if (dem == 1) { string mathuoc = tbMaThuoc.text; string tenthuoc = tbTenThuoc.text; string dvt = cbDVT.Text; decimal soluongcon = 0; if (tbMaThuoc.text == "" || tbTenThuoc.text == "" || cbDVT.Text == "" || tbSoLuongCon.text == "") { Alert a = new Alert("Vui lòng nhập đủ thông tin!", AlertType.info); a.ShowDialog(); } else if (kiemTra(mathuoc) == true) { Alert a = new Alert("Mã thuốc đã tồn tại!", AlertType.error); a.ShowDialog(); } else { try { soluongcon = decimal.Parse(tbSoLuongCon.text); } catch { Alert a = new Alert("Số lượng nhập không hợp lệ!", AlertType.error); a.ShowDialog(); } try { string querry = "insert into ThuocVacXin(tenthuoc,donvitinh,slcon) values (N'" + tenthuoc + "',N'" + dvt + "','" + soluongcon + "')"; DataTable data = KetNoi.Istance.ExcuteQuerry(querry); Alert a = new Alert("Thêm thành công", AlertType.success); a.ShowDialog(); setNull(); LoadData(); LoadCBBox(); } catch { Alert a = new Alert("Thêm thất bại!", AlertType.info); a.ShowDialog(); } } } else if (dem == 2) { string mathuoc = tbMaThuoc.text; string tenthuoc = tbTenThuoc.text; string dvt = cbDVT.Text; decimal soluongcon = 0; if (tbTenThuoc.text == "") { Alert a = new Alert("Vui lòng chọn đối tượng muốn sửa!", AlertType.error); a.ShowDialog(); } else if (tbMaThuoc.text == "" || tbTenThuoc.text == "" || cbDVT.Text == "" || tbSoLuongCon.text == "") { Alert a = new Alert("Vui lòng nhập đủ thông tin!", AlertType.error); a.ShowDialog(); } else { try { soluongcon = decimal.Parse(tbSoLuongCon.text); } catch { Alert a = new Alert("Số lượng nhập không hợp lệ!", AlertType.error); a.ShowDialog(); } try { string querry = "update ThuocVacxin set tenthuoc = N'" + tenthuoc + "',donvitinh = N'" + dvt + "',slcon = '" + soluongcon + "' where mathuoc = '" + mathuoc + "'"; DataTable data = KetNoi.Istance.ExcuteQuerry(querry); Alert a = new Alert("Sửa Thành Công!", AlertType.info); a.ShowDialog(); setNull(); LoadData(); LoadCBBox(); tbMaThuoc.Enabled = true; } catch { Alert a = new Alert("Sửa Thất Bại!", AlertType.info); a.ShowDialog(); } } } } catch { Alert a = new Alert("Dữ liệu không hợp lệ hoặc lỗi kết nối.", AlertType.error); a.ShowDialog(); } }
private void btnLuu_Click(object sender, EventArgs e) { try { if (dem == 1) { string mathucan = tbMaThucAn.text; string tenthucan = tbTenThucAn.text; if (tbMaThucAn.text == "" || tbTenThucAn.text == "") { Alert a = new Alert("Vui lòng nhập đủ thông tin!", AlertType.info); a.ShowDialog(); } else if (kiemTra(mathucan) == true) { Alert a = new Alert("Mã thức ăn đã tồn tại!", AlertType.error); a.ShowDialog(); } else { try { string querry = "insert into ThucAn values ('" + mathucan + "',N'" + tenthucan + "')"; DataTable data = KetNoi.Istance.ExcuteQuerry(querry); Alert a = new Alert("Thêm thành công", AlertType.success); a.ShowDialog(); setNull(); LoadData(); } catch { Alert a = new Alert("Thêm thất bại!", AlertType.info); a.ShowDialog(); } } } else if (dem == 2) { string mathucan = tbMaThucAn.text; string tenthucan = tbTenThucAn.text; if (tbTenThucAn.text == "") { Alert a = new Alert("Vui lòng chọn đối tượng muốn sửa!", AlertType.error); a.ShowDialog(); } else if (tbMaThucAn.text == "" || tbTenThucAn.text == "") { Alert a = new Alert("Vui lòng nhập đủ thông tin!", AlertType.error); a.ShowDialog(); } else { try { string querry = "update ThucAn set tenthucan = N'" + tenthucan + "' where mathucan = '" + mathucan + "' "; DataTable data = KetNoi.Istance.ExcuteQuerry(querry); Alert a = new Alert("Sửa Thành Công!", AlertType.info); a.ShowDialog(); setNull(); LoadData(); } catch { Alert a = new Alert("Sửa Thất Bại!", AlertType.info); a.ShowDialog(); } } } } catch { Alert a = new Alert("Dữ liệu không hợp lệ hoặc lỗi kết nối.", AlertType.error); a.ShowDialog(); } }
private void bunifuFlatButton2_Click(object sender, EventArgs e) { try { if (dem == 1) { if (txMaNv.Text == "" || txTenNv.Text == "" || txEmail.Text == "" || (rdbNam.Checked == false && rdbNu.Checked == false)) { Alert a = new Alert("Hãy nhập đủ thông tin.", AlertType.error); a.ShowDialog(); } else if (kiemtraMaNv(txMaNv.Text)) { Alert a = new Alert("Mã nv đã tồn tại.", AlertType.error); a.ShowDialog(); } else { string gt = ""; if (rdbNam.Checked == true) { gt = "Nam"; } else { gt = "Nữ"; } string query = "Insert into Nhanvien values('" + txMaNv.Text + "',N'" + txTenNv.Text + "',N'" + txEmail.Text + "',N'" + gt + "',N'" + dtpkNgaySinh.Value + "',N'" + dtpkNgayVaoLam.Value + "','" + fileimage + "')"; DataTable data = KetNoi.Istance.ExcuteQuerry(query); Alert a = new Alert("Thêm thành công.", AlertType.success); a.ShowDialog(); loadNv(); panelNV.Enabled = false; txEmail.ResetText(); txMaNv.ResetText(); txTenNv.ResetText(); txTimKiem.ResetText(); ptAnh.BackgroundImage = null; fileimage = ""; btnAnh.Visible = false; dem = 0; btnThem.Enabled = true; btnSua.Enabled = true; btnXoa.Enabled = true; } } if (dem == 2) { if (txTenNv.Text == "" || txEmail.Text == "" || (rdbNam.Checked == false && rdbNu.Checked == false)) { Alert a = new Alert("Hãy nhập đủ thông tin.", AlertType.error); a.ShowDialog(); } else { string gt = ""; if (rdbNam.Checked == true) { gt = "Nam"; } else { gt = "Nữ"; } string query = "Update NhanVien Set tenNv=N'" + txTenNv.Text + "',eMail=N'" + txEmail.Text + "',gioiTinh=N'" + gt + "',ngaySinh=N'" + dtpkNgaySinh.Value + "',ngayVaoLam=N'" + dtpkNgayVaoLam.Value + "',anh='" + fileimage + "' where maNv='" + txMaNv.Text + "'"; DataTable data = KetNoi.Istance.ExcuteQuerry(query); Alert a = new Alert("Sửa thành công.", AlertType.success); a.ShowDialog(); loadNv(); panelNV.Enabled = false; txEmail.ResetText(); txMaNv.ResetText(); txTenNv.ResetText(); txTimKiem.ResetText(); ptAnh.BackgroundImage = null; fileimage = ""; dem = 0; txMaNv.ReadOnly = false; btnAnh.Visible = false; linkLb.Visible = false; btnThem.Enabled = true; btnSua.Enabled = true; btnXoa.Enabled = true; } } } catch { Alert a = new Alert("Dữ liệu không hợp lệ hoặc lỗi kết nối", AlertType.error); a.ShowDialog(); } LoadTkNv(); }