private void LoadProduct() { dgvProduct.DataSource = MobileBLL.FindAll(); this.dgvProduct.Columns["Id"].Visible = false; this.dgvProduct.Columns[1].Width = 200; munberOfProduct = MobileBLL.FindAll().Count(); }
/// <summary> /// Phuong thuc tra ve ket qua cua <b>suy dien tien</b> voi dau vao /// la danh sach gia thiet (assumptions)<br/> /// <i>Ngay cap nhat : 18/04/2021</i> /// </summary> /// <param name="assumptions"></param> /// <returns></returns> public static List <MobileDTO> Result(List <string> assumptions) { // Ket qua var result = new List <MobileDTO>(); // Lay tat ca cac luat trong database va tou uu hoa tap luat List <RuleDTO> rules = OptimizeRule(RulesBLL.FindAll()); List <RuleDTO> rulesCopy = new List <RuleDTO>(rules); // Lay tat ca cac doi tuong mobile trong database var mobiles = MobileBLL.FindAll(); //var mobileId = mobile.Id; //----------------------------------------------------------------------------------------- //Buoc 1: Gan trung gian bang gia thiet List <string> mediate = assumptions; //Buoc 2: THuc hien suy dien Queue <int> SAT = new Queue <int>(); mediate = ForwardChaining(SAT, rulesCopy, rules, mediate); //Buoc 3: Kiem tra neu bien trung gian co chua mobile thi them vao ket qua mobiles.ForEach(mobile => { if (mediate.Contains(mobile.Id)) { result.Add(mobile); } }); return(result); }
private void dgvResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { var row = e.RowIndex; string Id = dgvResult.Rows[row].Cells[0].Value.ToString(); MobileDTO mobileDTO = MobileBLL.FindById(Id); MessageBox.Show(mobileDTO.ToString(), "Thông tin điện thoại", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void dgvProduct_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { var row = e.RowIndex; string Id = dgvProduct.Rows[row].Cells[0].Value.ToString(); mobileDTOTemp = MobileBLL.FindById(Id); txtName.Text = mobileDTOTemp.Name; txtPrice.Text = mobileDTOTemp.Price.ToString(); txtBrand.Text = mobileDTOTemp.Brand; txtColor.Text = mobileDTOTemp.Color; txtScreen.Text = mobileDTOTemp.Screen; txtRam.Text = mobileDTOTemp.Ram; txtCamera.Text = mobileDTOTemp.Camera; txtStorage.Text = mobileDTOTemp.Storage; txtOS.Text = mobileDTOTemp.OperatingSystem; }
private void btnUpdateProduct_Click(object sender, EventArgs e) { if (mobileDTOTemp != null) { MobileDTO mobileDTO = getMobile(); mobileDTO.Id = mobileDTOTemp.Id; if (MobileBLL.Update(mobileDTO)) { MessageBox.Show("Cập nhật sản phẩm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadProduct(); } } else { MessageBox.Show("Bạn chưa chọn sản phẩm cần cập nhật!", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnRemoveProduct_Click(object sender, EventArgs e) { if (mobileDTOTemp != null) { if (MobileBLL.Delete(mobileDTOTemp)) { MessageBox.Show("Xóa sản phẩm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadProduct(); mobileDTOTemp = null; ClearTextBoxes(); } } else { MessageBox.Show("Bạn chưa chọn sản phẩm cần xóa!", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnInsertProduct_Click(object sender, EventArgs e) { try { MobileDTO mobileDTO = getMobile(); mobileDTO.Id = "MB" + (munberOfProduct + 1); if (MobileBLL.Insert(mobileDTO)) { MessageBox.Show("Thêm sản phẩm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadProduct(); } } catch (FormatException ex) { MessageBox.Show("Lỗi nhập không đúng định dạng!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }