private void LoadCBNhaCC() { nhacungcapBL ctr = new nhacungcapBL(); DataTable dt = new DataTable(); dt = ctr.GetAll(); cbNhaCC.DataSource = dt; cbNhaCC.DisplayMember = "ten"; cbNhaCC.ValueMember = "id"; }
private void HienThiDS() { nhacungcapBL _ctr = new nhacungcapBL(); DataTable dt = new DataTable(); dt = _ctr.Filter(txtKeyword.Text.Trim()); if (dt != null) { c1FlexGrid1.DataSource = dt; FormatGrid(); } }
private void btnExport_Click(object sender, EventArgs e) { Application.DoEvents(); progressBar1.PerformStep(); Application.DoEvents(); DateTime dtdenngay = dpkDenNgay.Value; nhacungcapBL ctrnhacc = new nhacungcapBL(); DataTable dtnhacc = new DataTable(); try { Application.DoEvents(); progressBar1.PerformStep(); Application.DoEvents(); dtnhacc = ctrnhacc.GetByPhieuNhap(); Application.DoEvents(); progressBar1.PerformStep(); Application.DoEvents(); if (dtnhacc != null) { TKCongNoNhap ctr = new TKCongNoNhap(); string kq = ""; kq = ctr.Generate(txtpath.Text, dtdenngay, dtnhacc, progressBar1); Application.DoEvents(); progressBar1.Value = progressBar1.Maximum; Application.DoEvents(); if (kq.Trim().Equals("") == true) { MessageBox.Show("Tổng hợp dữ liệu thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Tổng hợp dữ liệu không thành công.\nChi tiết lỗi: " + kq, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } progressBar1.Value = 0; Application.DoEvents(); } else { MessageBox.Show("Lỗi không tổng hợp được dữ liệu.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); progressBar1.Value = 0; Application.DoEvents(); } } catch (Exception ex) { MessageBox.Show("Lỗi không tổng hợp được dữ liệu.\nChi tiết lỗi: " + ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); progressBar1.Value = 0; Application.DoEvents(); } }
private void cbNhaCC_SelectedIndexChanged(object sender, EventArgs e) { tblphieunhapkhoBL ctrpn = new tblphieunhapkhoBL(); string sidnhacc = ""; try { sidnhacc = cbNhaCC.SelectedValue.ToString().Trim(); } catch { } nhacungcap obj = new nhacungcap(); nhacungcapBL ctr = new nhacungcapBL(); obj = ctr.GetByID(sidnhacc); try { try { txtNoToaTruoc.Text = ctrpn.GetTienConNo(sidnhacc, dpkNgayNhap.Value).ToString("N0", CultureInfo.InvariantCulture); } catch { txtNoToaTruoc.Text = "0"; } txtDiaChi.Text = obj.diachi; txtDienThoai.Text = obj.dienthoai.Trim(); double tongtien = 0; try { tongtien = Convert.ToDouble(txtTongTien.Text); } catch { } double tienconno = 0; try { tienconno = Convert.ToDouble(txtNoToaTruoc.Text); } catch { } double tientt = 0; try { tientt = Convert.ToDouble(txtTienThanhToan.Text); } catch { } double chietkhau = 0; try { chietkhau = Convert.ToDouble(txtChietKhau.Text); } catch { } txtConNo.Text = ((tienconno + tongtien) - (tientt + chietkhau)).ToString("N0", CultureInfo.InvariantCulture); } catch { txtDiaChi.Text = ""; txtDienThoai.Text = ""; txtTongTien.Text = "0"; } }
private void HienThiTTPhieuNhap() { tblphieunhapkho objpn = new tblphieunhapkho(); tblphieunhapkhoBL ctrpn = new tblphieunhapkhoBL(); objpn = ctrpn.GetByID(sidpn); try{ nhacungcap objnhacc = new nhacungcap(); nhacungcapBL ctrnhacc = new nhacungcapBL(); objnhacc = ctrnhacc.GetByID(objpn.id_nguoicap.Trim()); lbDiaChi.Text = objnhacc.diachi; lbDienThoai.Text = objnhacc.dienthoai; lbNgayXuat.Text = objpn.ngaytao.ToString("dd/MM/yyyy HH:mm:ss"); lbTenKH.Text = objnhacc.ten; } catch { lbDiaChi.Text = "-/-"; lbDienThoai.Text = "-/-"; lbNgayXuat.Text = "-/-"; lbTenKH.Text = "-/-"; } }
private void Delete() { nhacungcapBL _ctr = new nhacungcapBL(); string loi = ""; string sten = ""; string iid = ""; int n = c1FlexGrid1.RowSel; if (n >= 1) { try { sten = c1FlexGrid1[c1FlexGrid1.RowSel, "ten"].ToString().Trim(); } catch { } try { iid = c1FlexGrid1[c1FlexGrid1.RowSel, "id"].ToString().Trim(); } catch { } DialogResult bien; bien = MessageBox.Show("Xác nhận xóa dữ liệu", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (bien == DialogResult.Yes) { loi = _ctr.Delete(iid); if (loi.Equals("") == true) { try { _ctrlog.Append(Data.use, "Xóa nhà cung cấp: " + sten.Trim()); } catch { } HienThiDS(); } else { MessageBox.Show(loi, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show("Dữ liệu hiện tại đang trắng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } c1FlexGrid1.Focus(); }
private void Save() { string temploi = ""; string loi = ""; nhacungcapBL _ctr = new nhacungcapBL(); List <nhacungcap> lst = new List <nhacungcap>(); lst = GetData(); if (lst != null) { for (int i = 0; i < lst.Count; i++) { loi = ""; nhacungcap _obj = new nhacungcap(); try { _obj = _ctr.GetByID(lst[i].id); } catch { } if (_obj == null) { try { loi = c1FlexGrid1.GetUserData(c1FlexGrid1.FindRow(lst[i].id.ToString().Trim(), 1, c1FlexGrid1.Cols["id"].Index, true, true, true), "ten").ToString().Trim(); } catch { } if (loi.Equals("") == true) { loi = _ctr.Insert(lst[i]); if (loi.Equals("") == false) { c1FlexGrid1.Rows[c1FlexGrid1.FindRow(lst[i].id.ToString().Trim(), 1, c1FlexGrid1.Cols["id"].Index, true, true, true)].Style = cserror; } else { _ctrlog.Append(Data.use, "Thêm mới nhà cung cấp: " + lst[i].ten.Trim()); } } else { c1FlexGrid1.Rows[c1FlexGrid1.FindRow(lst[i].id.ToString().Trim(), 1, c1FlexGrid1.Cols["id"].Index, true, true, true)].Style = cserror; } if (loi.Trim().Equals("") == false) { temploi = loi; } } else { try { loi = c1FlexGrid1.GetUserData(c1FlexGrid1.FindRow(lst[i].id.ToString().Trim(), 1, c1FlexGrid1.Cols["id"].Index, true, true, true), "ten").ToString().Trim(); } catch { } if (loi.Equals("") == true) { loi = _ctr.Update(lst[i]); if (loi.Equals("") == false) { c1FlexGrid1.SetUserData(c1FlexGrid1.FindRow(lst[i].id.ToString().Trim(), 1, c1FlexGrid1.Cols["id"].Index, true, true, true), "ten", loi); c1FlexGrid1.Rows[c1FlexGrid1.FindRow(lst[i].id.ToString().Trim(), 1, c1FlexGrid1.Cols["id"].Index, true, true, true)].Style = cserror; } else { _ctrlog.Append(Data.use, "Cập nhật thông tin nhà cung cấp: " + lst[i].ten.Trim()); } } else { c1FlexGrid1.SetUserData(c1FlexGrid1.FindRow(lst[i].id.ToString().Trim(), 1, c1FlexGrid1.Cols["id"].Index, true, true, true), "ten", loi); c1FlexGrid1.Rows[c1FlexGrid1.FindRow(lst[i].id.ToString().Trim(), 1, c1FlexGrid1.Cols["id"].Index, true, true, true)].Style = cserror; } if (loi.Trim().Equals("") == false) { temploi = loi; } } } } if (temploi.Trim().Equals("") == true) { HienThiDS(); MessageBox.Show("Cập nhật dữ liệu thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Cập nhật dữ liệu không thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }