private void Load() { tb = new DataTable(); dsDaiLy = BUS_DaiLy.DsDaiLy(); txtDiaChi.Modified = false; txtNguoiThu.Modified = false; txtSdt.Modified = false; txtTienNo.Modified = false; dsIdDL = new int[dsDaiLy.Count]; int i = 0; tb = new DataTable(); tb.Columns.Add("idDL", typeof(int)); tb.Columns.Add("diachi", typeof(string)); tb.Columns.Add("sdt", typeof(string)); tb.Columns.Add("tienno", typeof(float)); foreach (DTO_DaiLy dl in dsDaiLy) { dsIdDL[i] = dl.IdDL; string tendaily = BUS_DaiLy.GetTenById(dl.IdDL); cbDaiLy.Items.Add(tendaily); tb.Rows.Add(dl.IdDL, dl.DiaChi, dl.Sdt, dl.TienNo); i++; } cbDaiLy.SelectedIndex = 0; }
private void btnAdd_Click(object sender, EventArgs e) { if (idDL != -1 && arrIdLDL[cbLoaiDL.SelectedIndex] >= 0 && arrIdQuan[cbQuan.SelectedIndex] >= 0 && txtTienNo.Text.Equals("") == false && txtTenDaiLy.Text.Equals("") == false && txtSdt.Text.Equals("") == false && txtDiaChi.Text.Equals("") == false) { DTO_DaiLy dl = new DTO_DaiLy(); dl.IdDL = 1; dl.IdLoaiDL = arrIdLDL[cbLoaiDL.SelectedIndex]; dl.IdQuan = arrIdQuan[cbQuan.SelectedIndex]; dl.TenDaiLy = txtTenDaiLy.Text; dl.Sdt = txtSdt.Text; dl.Cmnd = nhanVien.Cmnd; dl.DiaChi = txtDiaChi.Text; dl.NgayNhan = DateTime.Now; dl.TienNo = 0; if (BUS_DaiLy.Themdaily(dl) == 0) { } else { dsDaiLy = BUS_DaiLy.DsDaiLy(); UpdateGvDaiLy(); } } }
private void btnModify_Click(object sender, EventArgs e) { if (idDL != -1 && arrIdLDL[cbLoaiDL.SelectedIndex] >= 0 && arrIdQuan[cbQuan.SelectedIndex] >= 0 && txtTienNo.Text.Equals("") == false && txtTenDaiLy.Text.Equals("") == false && txtSdt.Text.Equals("") == false && txtDiaChi.Text.Equals("") == false) { DTO_DaiLy dl = new DTO_DaiLy(); dl.IdDL = idDL; dl.IdLoaiDL = arrIdLDL[cbLoaiDL.SelectedIndex]; dl.IdQuan = arrIdQuan[cbQuan.SelectedIndex]; dl.TienNo = (float)Convert.ToDouble(txtTienNo.Text); dl.TenDaiLy = txtTenDaiLy.Text; dl.Sdt = txtSdt.Text; dl.DiaChi = txtDiaChi.Text; dl.Cmnd = nhanVien.Cmnd; dl.NgayNhan = DateTime.Now; int kq = BUS_DaiLy.SuaDaiLy(dl); if (kq == 1) { dsDaiLy = BUS_DaiLy.DsDaiLy(); UpdateGvDaiLy(); MessageBox.Show("Cập nhật thành công"); } else if (kq == 3) { MessageBox.Show("Loại đại lý đã đủ số lượng"); } else { MessageBox.Show("Cập nhật thất bại"); } } }
private void btnDelete_Click(object sender, EventArgs e) { if (BUS_DaiLy.XoaDaiLy(idDL) == 0) { } else { dsDaiLy = BUS_DaiLy.DsDaiLy(); UpdateGvDaiLy(); } }
private void txtsearch_EditValueChanged_1(object sender, EventArgs e) { if (txtsearch.Text.Equals("") == false) { dsDaiLy = BUS_DaiLy.Search(txtsearch.Text); UpdateGvDaiLy(); } else { dsDaiLy = BUS_DaiLy.DsDaiLy(); UpdateGvDaiLy(); } }
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 Load() { tongTien = 0; //tb = new DataTable(); dsDaiLy = BUS_DaiLy.DsDaiLy(); dsIdDL = new int[dsDaiLy.Count]; foreach (DataRow r in tb.Rows) { tongTien = tongTien + (float)Convert.ToDouble(r[5].ToString()); } int i = 0; foreach (DTO_DaiLy dl in dsDaiLy) { cbDaiLy.Items.Add(dl.TenDaiLy); dsIdDL[i] = dl.IdDL; i++; } cbDaiLy.SelectedIndex = 0; gvhang.DataSource = tb; txtTongTien.Text = tongTien.ToString(); }