private void frmThemDaiLy_Load(object sender, EventArgs e) { // https://www.devexpress.com/Support/Center/Question/Details/Q20064/comboboxedit-how-do-you-set-the-datasource // Lookup-edit Loại Đại lý BUS_LoaiDaiLy dl = new BUS_LoaiDaiLy(); cbLoaiDL.Properties.DataSource = dl.DanhSachLoaiDL(); cbLoaiDL.Properties.DisplayMember = "TenLoai"; cbLoaiDL.Properties.ValueMember = "MaLoai"; cbLoaiDL.Properties.Columns.Add(new LookUpColumnInfo("TenLoai", "Loại Đại Lý")); // Lookup-edit Quận BUS_Quan q = new BUS_Quan(); cbQuan.Properties.DataSource = q.DanhSachQuan(); cbQuan.Properties.DisplayMember = "TenQuan"; cbQuan.Properties.ValueMember = "TenQuan"; cbQuan.Properties.Columns.Add(new LookUpColumnInfo("TenQuan", "Quận")); // Date edit dtpNgayTiepNhan.EditValue = DateTime.Now; }
private void btnThem_Click(object sender, EventArgs e) { string quan = txtQuan.Text; if (quan.Equals("") == false) { int kq = BUS_Quan.ThemQuan(quan); if (kq == 1) { MessageBox.Show("Thêm thành công"); dsQuan = BUS_Quan.DSquan(); updateGV(); } else if (kq == 2) { MessageBox.Show("số lượng quận vượt quy định"); } else if (kq == 3) { MessageBox.Show("tên quận đã tồn tại"); } else { MessageBox.Show("Thêm thất bại"); } // 1:thành công //*2:số lượng quận vượt quy định //*3:tên quận đã tồn tại } }
private void btnLuu_Click(object sender, EventArgs e) { if (KiemTraDuLieu()) { BUS_Quan q = new BUS_Quan(); int oldmax = q.LaySoDaiLyToiDa(); int newmax = int.Parse(txtSoDLToiDa.Text); if (oldmax != newmax) { var tb = MessageBox.Show(string.Format("Hiện tại, số đại lý tối đa trong một quận là {0}.\nBạn có chắc chắn muốn chỉnh sửa thành {1} ?", oldmax.ToString(), newmax.ToString()), "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (tb == DialogResult.Yes) { q.LuuSoDaiLyToiDa(newmax); MessageBox.Show("Bạn đã lưu thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { return; } } else { this.Close(); } } }
private void Load() { tb = new DataTable(); tb.Columns.Add("id", typeof(int)); tb.Columns.Add("ten", typeof(string)); dsQuan = BUS_Quan.DSquan(); gvQuan.DataSource = tb; foreach (DTO_Quan q in dsQuan) { tb.Rows.Add(q.IdQuan, q.TenQuan); } }
private void btnXoa_Click(object sender, EventArgs e) { if (txtQuan.Text.Equals("") == false) { int kq = BUS_Quan.XoaQuan(id); if (kq == 1) { MessageBox.Show("Xoá thành công"); dsQuan = BUS_Quan.DSquan(); updateGV(); } else { MessageBox.Show("Xoá thất bại"); } } }
private void UpdateGvDaiLy() { ResetTable(); int t = 0; foreach (DTO_DaiLy dl in dsDaiLy) { arrIdDL[t] = dl.IdDL; t++; string tenDL = BUS_DaiLy.GetTenById(dl.IdDL); string tenQuan = BUS_Quan.GetTen(dl.IdQuan); string tenLoaiDL = BUS_LoaiDL.GetTenById(dl.IdLoaiDL); string tenNV = BUS_NhanVien.GetTenNV(dl.Cmnd); string ngay = dl.NgayNhan.ToString("dd/MM/yyyy"); tb.Rows.Add(dl.IdDL, dl.IdLoaiDL, dl.IdQuan, tenDL, tenLoaiDL, dl.Sdt, tenQuan, ngay, tenNV, dl.TienNo, dl.DiaChi); } }
private void Load() { idDL = -1; idLoaiDL = -1; idQuan = -1; txtTenDaiLy.Text = ""; cbLoaiDL.SelectedItem = ""; txtSdt.Text = ""; cbQuan.SelectedItem = ""; dtNgayNhan.Value = DateTime.Now; txtNguoiNhan.Text = ""; txtTienNo.Text = ""; txtDiaChi.Text = ""; //txtNguoiNhan.Enabled = false; dsDaiLy = BUS_DaiLy.DsDaiLy(); dsQuan = BUS_Quan.DSquan(); dsLoaiDL = BUS_LoaiDL.DsLoaiDL(); arrIdDL = new int[dsDaiLy.Count]; arrIdLDL = new int[dsLoaiDL.Count]; arrIdQuan = new int[dsQuan.Count]; int i = 0; foreach (DTO_LoaiDL ldl in dsLoaiDL) { cbLoaiDL.Items.Add(ldl.TenLoaiDL); arrIdLDL[i] = ldl.IdLoaiDL; i++; } int j = 0; foreach (DTO_Quan ldl in dsQuan) { cbQuan.Items.Add(ldl.TenQuan); arrIdQuan[j] = ldl.IdQuan; j++; } gvDaiLy.DataSource = tb; gvDaiLy.Columns["IdDL"].Visible = false; gvDaiLy.Columns["IdLoaiDL"].Visible = false; gvDaiLy.Columns["IdQuan"].Visible = false; UpdateGvDaiLy(); }
private void frmSoDaiLyToiDa_Load(object sender, EventArgs e) { BUS_Quan q = new BUS_Quan(); txtSoDLToiDa.Text = q.LaySoDaiLyToiDa().ToString(); }