private void OnShowLov(string searchKey, bool isTimTheoTen) { if (ReadOnly) { return; } var lov = new MFullLov(_allDto); if (isTimTheoTen) { lov.SetTen(searchKey); } else { lov.SetMa(searchKey); } if (lov.ShowDialog(this) == DialogResult.OK && lov.SelectedDto != null) { _selectedDto = lov.SelectedDto; txtSearchKey.Text = _selectedDto.Ten; if (_validateEvent != null) { _validateEvent(null, null); } } else { _selectedDto = null; } }
private void btnCapNhat_Click(object sender, EventArgs e) { if (!IsValidInputData()) { return; } var dr = MMessageBox.Show(this, "Lưu nhóm thực đơn?", "Thông báo" , MMessageBoxButtons.YesNo, MMessageBoxIcon.Warning); if (DialogResult.No == dr) { Dispose(); return; } var maNhom = txtMaNhom.Text.Trim(); var tenNhom = txtTenNhom.Text.Trim(); var dto = new DanhMucDto() { Id = Convert.ToString(_categoryId), Ma = maNhom, Ten = tenNhom }; _billingDao.SaveCategory(dto); _isChange = true; Dispose(); }
private void OnAddOneRow(DataGridViewRowCollection rows, DanhMucDto dto) { int index = rows.Add(); rows[index].Cells[MA_KEY].Value = dto.Ma; rows[index].Cells[TEN_KEY].Value = dto.Ten; rows[index].Cells[ID_KEY].Value = dto.Id; }
private void AddOneCategoryRow(DanhMucDto dto) { int index = dgvCategory.Rows.Add(); var r = dgvCategory.Rows[index]; r.Cells["code"].Value = dto.Ma; r.Cells["name"].Value = dto.Ten; r.Cells["edit"].Value = "Sửa"; r.Cells["categoryId"].Value = dto.Id; }
private void OnSelectRow() { if (dgvLov.CurrentRow != null) { _selectedDto = new DanhMucDto(); _selectedDto.Id = (string)dgvLov.CurrentRow.Cells[ID_KEY].Value; _selectedDto.Ma = (string)dgvLov.CurrentRow.Cells[MA_KEY].Value; _selectedDto.Ten = (string)dgvLov.CurrentRow.Cells[TEN_KEY].Value; DialogResult = DialogResult.OK; } Close(); }
private void OnSearch(string searchKey) { if (_allDto.Count == 0) { return; } List <DanhMucDto> itemsForListBox = new List <DanhMucDto>(); bool isTimTheoTen = false; _allDto.FindAll( delegate(DanhMucDto dto) { bool found = false; if (dto.Ma.ToUpper().Equals(searchKey.ToUpper())) { found = true; itemsForListBox.Add(dto); } return(found); }); if (itemsForListBox.Count == 0) { _allDto.FindAll( delegate(DanhMucDto dto) { bool found = false; if (VnStringHelper.toEnglish(dto.Ten.ToUpper()).Equals(VnStringHelper.toEnglish(searchKey).ToUpper())) { found = true; itemsForListBox.Add(dto); } return(found); }); isTimTheoTen = true; } if (itemsForListBox.Count == 1) { _selectedDto = itemsForListBox[0]; txtSearchKey.Text = _selectedDto.Ten; } else if (itemsForListBox.Count > 1) { OnShowLov(txtSearchKey.Text.Trim(), isTimTheoTen); } else { _selectedDto = null; } }
public DanhMucDto getCategoryDto(long categoryId) { var categorys = m_PersistenceManager.RetrieveEquals <Category>("Id", categoryId); var dto = new DanhMucDto(); if (categorys.Count == 0) { return(dto); } var category = categorys[0]; dto.Id = Convert.ToString(category.Id); dto.Ma = category.Code; dto.Ten = category.Name; return(dto); }
public bool SaveCategory(DanhMucDto dto) { try { var categories = m_PersistenceManager.RetrieveEquals <Category>("Id", long.Parse(dto.Id)); var category = categories.Count == 0 ? new Category() : categories[0]; category.Code = dto.Ma; category.Name = dto.Ten; m_PersistenceManager.Save <Category>(category); return(true); } catch (Exception e) { Console.WriteLine(e.Message); return(false); } }
public List <DanhMucDto> GetAllUnit() { using (ISession session = m_SessionFactory.OpenSession()) { var query = session.CreateQuery("from Unit c order by c.Code asc"); // Get the matching objects var allUnits = query.List(); var listUnitDtos = new List <DanhMucDto>(); foreach (Unit unit in allUnits) { var dto = new DanhMucDto() { Id = Convert.ToString(unit.Id), Ma = unit.Code, Ten = unit.Name }; listUnitDtos.Add(dto); } return(listUnitDtos); } }
public List <DanhMucDto> GetAllCategory() { using (ISession session = m_SessionFactory.OpenSession()) { var query = session.CreateQuery("from Category c order by c.Code asc"); // Get the matching objects var allCategories = query.List(); var listCategoryDtos = new List <DanhMucDto>(); foreach (Category category in allCategories) { var dto = new DanhMucDto() { Id = Convert.ToString(category.Id), Ma = category.Code, Ten = category.Name }; listCategoryDtos.Add(dto); } return(listCategoryDtos); } }
public bool SaveCategory(DanhMucDto dto) { return(_controller.SaveCategory(dto)); }