Example #1
0
        public void RefreshGridViewUsers()
        {
            User entity = new User();

            SearchParam searchParam = new SearchParam();
            searchParam.Start = DEFAULT_START;
            searchParam.Limit = DEFAULT_LIMIT;
            searchParam.SortBy = DEFAULT_SORT_BY;
            searchParam.SortDir = DEFAULT_SORT_DIR;

            this.BindingDataToForm(entity, searchParam, 0);

            bindingNavigatorUser.BindingSource.PositionChanged += new EventHandler(BindingSource_PositionChanged);
        }
Example #2
0
        private void FrmUserStatus_Load(object sender, EventArgs e)
        {
            //
            ContructGridViewColumn();

            //Get all user
            searchParam = new SearchParam();
            searchParam.Start = DEFAULT_START;
            searchParam.Limit = DEFAULT_LIMIT;
            searchParam.SortBy = DEFAULT_SORT_BY;
            searchParam.SortDir = DEFAULT_SORT_DIR;

            //
            searchEntity = new UserStatus();

            //
            SearchResult<UserStatus> searchResult = userStatusManager.GetUserStatusListByParam(searchEntity, searchParam);

            //Binding list userrole to gridview
            IList2DataTable(searchResult.SearchList, dataSetUserStatus.Tables["UserStatus"]);

            //Binding list to navigator
            listPages = new List<Int32>();
            BindingDataToBindingNagivator(searchResult.SearchSize, 0);

            //
            isAdd = true;
        }
Example #3
0
        private void btnReloadAll_Click(object sender, EventArgs e)
        {
            //Get all user
            searchParam = new SearchParam();
            searchParam.Start = DEFAULT_START;
            searchParam.Limit = DEFAULT_LIMIT;
            searchParam.SortBy = DEFAULT_SORT_BY;
            searchParam.SortDir = DEFAULT_SORT_DIR;

            //
            searchEntity = new UserRole();

            //
            SearchResult<UserRole> searchResult = userRoleManager.GetUserRoleListByParam(searchEntity, searchParam);

            //Binding list userrole to gridview
            IList2DataTable(searchResult.SearchList, dataSetUserRole.Tables["UserRole"]);

            //Binding list to navigator
            listPages = new List<Int32>();
            BindingDataToBindingNagivator(searchResult.SearchSize, 0);
        }
Example #4
0
        public void AdvanceSearchProduct(Product searchEntity)
        {
            //Default param
            searchParam = new SearchParam();
            searchParam.Start = DEFAULT_START;
            searchParam.Limit = DEFAULT_LIMIT;
            searchParam.SortBy = DEFAULT_SORT_BY;
            searchParam.SortDir = DEFAULT_SORT_DIR;

            //
            this.searchEntity = searchEntity;

            //
            SearchResult<Product> searchResult = productManager.GetProductListByAdvanceParam(searchEntity, searchParam);
            currentListProduct = searchResult.SearchList;

            //Binding list userrole to gridview
            IList2DataTable(searchResult.SearchList, dataSetProduct.Tables["Product"]);

            //Binding list to navigator
            listPages = new List<Int32>();
            BindingDataToBindingNagivator(searchResult.SearchSize, 0);
        }
Example #5
0
        private void BindingDataToFormProductName(ProductName entity, SearchParam searchParam, int position)
        {
            SearchResult<ProductName> searchResult = productNameManager.GetProductNameListByParam(entity, searchParam);
            if (searchResult != null)
            {
                DataTable dataTableProductName = new DataTable("ProductName");
                dataTableProductName.Columns.Add("ProductNameId", typeof(Int32));
                dataTableProductName.Columns.Add("ProdName", typeof(string));
                dataTableProductName.Columns.Add("CategoryId", typeof(int));
                dataTableProductName.Columns.Add("CategoryName", typeof(string));
                dataTableProductName.Columns.Add("ManId", typeof(int));
                dataTableProductName.Columns.Add("ManName", typeof(string));
                foreach (ProductName objProduct in searchResult.SearchList)
                {
                    DataRow rowTemp = dataTableProductName.NewRow();
                    rowTemp["ProductNameId"] = objProduct.ID;
                    rowTemp["ProdName"] = objProduct.ProdName;
                    rowTemp["CategoryId"] = objProduct.CategoryId;
                    if (objProduct.CategoryIdLookup != null)
                    {
                        rowTemp["CategoryName"] = objProduct.CategoryIdLookup.CategoryName;
                    }
                    else
                    {
                        Category temp = categoryManager.GetById(objProduct.CategoryId, false);

                        if (temp != null)
                        {
                            rowTemp["CategoryName"] = temp.CategoryName;
                        }
                        else
                        {
                            rowTemp["CategoryName"] = string.Empty;
                        }
                    }
                    rowTemp["ManId"] = objProduct.ManId;
                    if (objProduct.ManIdLookup != null)
                    {
                        rowTemp["ManName"] = objProduct.ManIdLookup.ManName;
                    }
                    else
                    {
                        Manufacturer temp = manufacturerManager.GetById(objProduct.ManId, false);

                        if (temp != null)
                        {
                            rowTemp["ManName"] = temp.ManName;
                        }
                        else
                        {
                            rowTemp["ManName"] = string.Empty;
                        }
                    }
                    dataTableProductName.Rows.Add(rowTemp);
                }
                dataSetProductName = new DataSet();
                dataSetProductName.Tables.Add(dataTableProductName);
                gvTenSanPham.DataSource = dataSetProductName;
                gvTenSanPham.DataSource = dataSetProductName;
                gvTenSanPham.DataMember = "ProductName";
                gvTenSanPham.Columns["ProductNameId"].HeaderText = "Mã tên sản phẩm";
                gvTenSanPham.Columns["ProdName"].HeaderText = "Tên sản phẩm";
                gvTenSanPham.Columns["CategoryId"].Visible = false;
                gvTenSanPham.Columns["CategoryName"].HeaderText = "Loại sản phẩm";
                gvTenSanPham.Columns["ManId"].Visible = false;
                gvTenSanPham.Columns["ManName"].HeaderText = "Nhà sản xuất";
                currentListProductName = searchResult.SearchList;
                logger.Debug("searchList size = " + searchResult.SearchList.Count);
                List<Int32> listPages = new List<Int32>();
                int totalPage = 0;

                if (searchResult.SearchSize % DEFAULT_LIMIT > 0)
                {
                    totalPage = (int)searchResult.SearchSize / DEFAULT_LIMIT + 1;
                }
                else
                {
                    totalPage = (int)searchResult.SearchSize / DEFAULT_LIMIT;
                }

                logger.Debug("searchSize = " + searchResult.SearchSize);
                logger.Debug("totalPage = " + totalPage);

                for (int i = 0; i < totalPage; i++)
                {
                    listPages.Add(i);
                }
                bindingNavigatorProductName.BindingSource = new BindingSource(listPages, "");
                bindingNavigatorProductName.BindingSource.Position = position;
                bindingNavigatorProductName.BindingSource.PositionChanged += new EventHandler(BindingSource_PositionChangedProductName);
                toolStripLblTotal.Text = "Tổng số tên sản phẩm: " + searchResult.SearchSize;
            }
        }
Example #6
0
        private void BindingDataToForm(Product entity, SearchParam searchParam, int position)
        {
            SearchResult<Product> searchResult = productManager.GetProductListByParam(entity, searchParam);
            if (searchResult != null)
            {
                DataTable dataTableProduct = new DataTable("Product");
                dataTableProduct.Columns.Add("ProductId", typeof(Int64));
                dataTableProduct.Columns.Add("MfgDate", typeof(string));
                dataTableProduct.Columns.Add("ExpDate", typeof(string));
                dataTableProduct.Columns.Add("ProductNameId", typeof(int));
                dataTableProduct.Columns.Add("ProdName", typeof(string));
                dataTableProduct.Columns.Add("PurchasePrice", typeof(string));
                dataTableProduct.Columns.Add("SalePrice", typeof(string));
                dataTableProduct.Columns.Add("Discount", typeof(string));
                dataTableProduct.Columns.Add("StatusId", typeof(int));
                dataTableProduct.Columns.Add("Status", typeof(string));
                dataTableProduct.Columns.Add("BillPurchaseId", typeof(int));
                dataTableProduct.Columns.Add("BillSaleId", typeof(int));
                dataTableProduct.Columns.Add("UnitId", typeof(int));
                dataTableProduct.Columns.Add("Unit", typeof(string));
                dataTableProduct.Columns.Add("Description", typeof(string));

                foreach (Product objProduct in searchResult.SearchList)
                {
                    DataRow rowTemp = dataTableProduct.NewRow();
                    rowTemp["ProductId"] = objProduct.ID;
                    rowTemp["MfgDate"] = objProduct.MfgDate.Value.ToString("dd/MM/yyyy");
                    rowTemp["ExpDate"] = objProduct.ExpDate.Value.ToString("dd/MM/yyyy");
                    rowTemp["ProductNameId"] = objProduct.ProductNameIdLookup.ID;
                    rowTemp["ProdName"] = objProduct.ProductNameIdLookup.ProdName;
                    rowTemp["PurchasePrice"] = objProduct.PurchasePrice;
                    rowTemp["SalePrice"] = objProduct.SalePrice;
                    rowTemp["Discount"] = objProduct.Discount;
                    rowTemp["StatusId"] = objProduct.ProductStatusIdLookup.ID;
                    rowTemp["Status"] = objProduct.ProductStatusIdLookup.StatusName;
                    rowTemp["BillPurchaseId"] = objProduct.BillPurchaseId;
                    if (objProduct.BillSaleId != null) rowTemp["BillSaleId"] = objProduct.BillSaleId;
                    rowTemp["UnitId"] = objProduct.UnitIdLookup.ID;
                    rowTemp["Unit"] = objProduct.UnitIdLookup.UnitName;
                    rowTemp["Description"] = objProduct.Description;
                    dataTableProduct.Rows.Add(rowTemp);
                }
                dataSetProduct = new DataSet();
                dataSetProduct.Tables.Add(dataTableProduct);
                gvSanPhamDanhMuc.DataSource = dataSetProduct;

                gvSanPhamDanhMuc.DataSource = dataSetProduct;
                gvSanPhamDanhMuc.DataMember = "Product";
                gvSanPhamDanhMuc.Columns["ProductId"].HeaderText = "Mã sản phẩm";
                gvSanPhamDanhMuc.Columns["MfgDate"].HeaderText = "Ngày sản xuất";
                gvSanPhamDanhMuc.Columns["ExpDate"].HeaderText = "Ngày hết hạn";
                gvSanPhamDanhMuc.Columns["ProductNameId"].Visible = false;
                gvSanPhamDanhMuc.Columns["ProdName"].HeaderText = "Tên sản phẩm";
                gvSanPhamDanhMuc.Columns["PurchasePrice"].HeaderText = "Giá mua";
                gvSanPhamDanhMuc.Columns["SalePrice"].HeaderText = "Giá bán";
                gvSanPhamDanhMuc.Columns["Discount"].HeaderText = "Giảm giá";
                gvSanPhamDanhMuc.Columns["StatusId"].Visible = false;
                gvSanPhamDanhMuc.Columns["Status"].HeaderText = "Trạng thái";
                gvSanPhamDanhMuc.Columns["BillPurchaseId"].HeaderText = "Mã mua";
                gvSanPhamDanhMuc.Columns["BillSaleId"].HeaderText = "Mã bán";
                gvSanPhamDanhMuc.Columns["UnitId"].Visible = false;
                gvSanPhamDanhMuc.Columns["Unit"].HeaderText = "Đơn vị";
                gvSanPhamDanhMuc.Columns["Description"].HeaderText = "Mô tả";

                currentListProduct = searchResult.SearchList;
                logger.Debug("searchList size = " + searchResult.SearchList.Count);

                List<Int32> listPages = new List<Int32>();
                int totalPage = 0;

                if (searchResult.SearchSize % DEFAULT_LIMIT > 0)
                {
                    totalPage = (int)searchResult.SearchSize / DEFAULT_LIMIT + 1;
                }
                else
                {
                    totalPage = (int)searchResult.SearchSize / DEFAULT_LIMIT;
                }

                logger.Debug("searchSize = " + searchResult.SearchSize);
                logger.Debug("totalPage = " + totalPage);

                for (int i = 0; i < totalPage; i++)
                {
                    listPages.Add(i);
                }

                bindingNavigatorProduct.BindingSource = new BindingSource(listPages, "");
                bindingNavigatorProduct.BindingSource.Position = position;
                bindingNavigatorProduct.BindingSource.PositionChanged += new EventHandler(BindingSource_PositionChanged);
                toolStripLblTotal.Text = "Tổng số sản phẩm: " + searchResult.SearchSize;
            }
        }
Example #7
0
        private void RefreshGridViewProductName(ProductName searchEntity)
        {
            //Get all user
            searchParam = new SearchParam();
            searchParam.Start = DEFAULT_START;
            searchParam.Limit = DEFAULT_LIMIT;
            searchParam.SortBy = DEFAULT_SORT_BY;
            searchParam.SortDir = DEFAULT_SORT_DIR;

            //
            this.searchEntityProductName = searchEntity;

            //
            SearchResult<ProductName> searchResult = productNameManager.GetProductNameListByParam(searchEntity, searchParam);
            currentListProductName = searchResult.SearchList;

            //Binding list userrole to gridview
            IList2DataTableProductName(searchResult.SearchList, dataSetProductName.Tables["ProductName"]);

            //Binding list to navigator
            listPagesProductName = new List<Int32>();
            BindingDataToBindingNagivatorProductName(searchResult.SearchSize, 0);
        }
Example #8
0
        private void btnReloadAll_Click(object sender, EventArgs e)
        {
            //Get all user
            searchParam = new SearchParam();
            searchParam.Start = DEFAULT_START;
            searchParam.Limit = DEFAULT_LIMIT;
            searchParam.SortBy = DEFAULT_SORT_BY;
            searchParam.SortDir = DEFAULT_SORT_DIR;

            searchEntity = new User();

            SearchResult<User> searchResult = userManager.GetUserListByParam(searchEntity, searchParam);
            currentListUser = searchResult.SearchList;

            //Binding list user to gridview
            IList2DataTable(currentListUser, dataSetUser.Tables["User"]);

            //
            listPages = new List<Int32>();
            BindingDataToBindingNagivator(searchResult.SearchSize, 0);
        }
Example #9
0
        /*
        private string DieuKienTimKiem()
        {
            string dk = "";
            if (chkTatCaTimKiemQuanLy.Checked)
                dk = " where SanPham.MaSanPham like '%" + textBoxSearch.Text + "%' or SanPham.TenSanPham like N'%" + textBoxSearch.Text + "%' or LoaiSanPham.LoaiSanPham like N'%" + textBoxSearch.Text + "%' or DonVi.DonVi like N'%" + textBoxSearch.Text + "%' or QuocGia.QuocGia like N'%" + textBoxSearch.Text + "%' or NhaSanXuat.TenNhaSanXuat like N'%" + textBoxSearch.Text + "%' or NhaCungCap.NhaCungCap like N'%" + textBoxSearch.Text + "%' or SanPham.MoTa like N'%" + textBoxSearch.Text + "%'";
            else
            {
                if (chkMaSanPhamTimKiemQuanLy.Checked)
                    dk += " or SanPham.MaSanPham like '%" + textBoxSearch.Text+"%'";
                if (chkTenSanPhamTimKiemQuanLy.Checked)
                    dk += " or SanPham.TenSanPham like N'%" + textBoxSearch.Text+"%'";
                if (chkLoaiSanPhamTimKiemQuanLy.Checked)
                    dk += " or LoaiSanPham.LoaiSanPham like N'%" + textBoxSearch.Text+"%'";
                if (chkDonViTimKiemQuanLy.Checked)
                    dk += " or DonVi.DonVi like N'%" + textBoxSearch.Text + "%'";
                if (chkNguonGocTimKiemQuanLy.Checked)
                    dk += " or QuocGia.QuocGia like N'%"+ textBoxSearch.Text+"%'";
                if (chkNhaSanXuatTimKiemQuanLy.Checked)
                    dk += "or NhaSanXuat.TenNhaSanXuat like N'%" + textBoxSearch.Text + "%'";
                if (chkNhaCungCapTimKiemQuanLy.Checked)
                    dk += " or NhaCungCap.NhaCungCap like N'%" + textBoxSearch.Text + "%'";
                if (chkMoTaTimKiemQuanLy.Checked)
                    dk += " or SanPham.MoTa like N'%" + textBoxSearch.Text+"%'";

                if (dk.Trim().Length > 0)
                    dk = " where "+dk.Substring(4);
            }

            return dk;
        }
        */
        private void frmDanhMucSanPham_Load(object sender, EventArgs e)
        {
            this.Location = new Point((this.MdiParent.ClientSize.Width-this.Width)/2,(this.MdiParent.ClientSize.Height-this.Height)/2-50);

            try
            {
                //Create column of gridview
                ContructGridViewColumn();

                //Get all product
                searchParam = new SearchParam();
                searchParam.Start = DEFAULT_START;
                searchParam.Limit = DEFAULT_LIMIT;
                searchParam.SortBy = DEFAULT_SORT_BY;
                searchParam.SortDir = DEFAULT_SORT_DIR;

                searchParamProductName = new SearchParam();
                searchParamProductName.Start = DEFAULT_START;
                searchParamProductName.Limit = DEFAULT_LIMIT;
                searchParamProductName.SortBy = DEFAULT_SORT_BY;
                searchParamProductName.SortDir = DEFAULT_SORT_DIR;

                searchEntity = new Product();
                searchEntityProductName = new ProductName();
                SearchResult<Product> searchResult = productManager.GetProductListByParam(searchEntity, searchParam);

                SearchResult<ProductName> searchResultProductName = productNameManager.GetProductNameListByParam(searchEntityProductName, searchParamProductName);
                currentListProduct = searchResult.SearchList;
                currentListProductName = searchResultProductName.SearchList;

                //Binding list product to gridview
                IList2DataTable(currentListProduct, dataSetProduct.Tables["Product"]);
                IList2DataTableProductName(currentListProductName, dataSetProductName.Tables["ProductName"]);

                listPages = new List<Int32>();
                listPagesProductName = new List<Int32>();
                BindingDataToBindingNagivator(searchResult.SearchSize, 0);
                BindingDataToBindingNagivatorProductName(searchResultProductName.SearchSize, 0);

                //Binding value for combobox
                //comboBoxTenSanPham.DataSource = productNameManager.GetAll();
                //comboBoxTenSanPham.DisplayMember = "ProdName";
                //comboBoxTenSanPham.ValueMember = "ID";

                comboBoxLoaiSanPham.DataSource = categoryManager.GetAll();
                comboBoxLoaiSanPham.DisplayMember = "CategoryName";
                comboBoxLoaiSanPham.ValueMember = "ID";

                comboBoxNhasx.DataSource = manufacturerManager.GetAll();
                comboBoxNhasx.DisplayMember = "ManName";
                comboBoxNhasx.ValueMember = "ID";

                cboTenSanPham.DataSource = productNameManager.GetAll();
                cboTenSanPham.DisplayMember = "ProdName";
                cboTenSanPham.ValueMember = "ID";

                cboLoaiSanPham.DataSource = categoryManager.GetAll();
                cboLoaiSanPham.DisplayMember = "CategoryName";
                cboLoaiSanPham.ValueMember = "ID";

                cboNguonGoc.DataSource = countryManager.GetAll();
                cboNguonGoc.DisplayMember = "CountryName";
                cboNguonGoc.ValueMember = "ID";

                cboNhaSanXuat.DataSource = manufacturerManager.GetAll();
                cboNhaSanXuat.DisplayMember = "ManName";
                cboNhaSanXuat.ValueMember = "ID";

                cboDonVi.DataSource = unitManager.GetAll();
                cboDonVi.DisplayMember = "UnitName";
                cboDonVi.ValueMember = "ID";

                cboTrangThai.DataSource = productStatusManager.GetAll();
                cboTrangThai.DisplayMember = "StatusName";
                cboTrangThai.ValueMember = "ID";

                ResetFormProductName();
                SetFormProductNameReadOnly(true);
                SetFormProductReadOnly(true);

                //int khoa = Int32.Parse(cboTenSanPham.SelectedValue.ToString());
                //ProductName productName = productNameManager.GetById(khoa, true);
                //cboLoaiSanPham.SelectedValue = productName.CategoryIdLookup.ID;
                //cboNhaSanXuat.SelectedValue = productName.ManIdLookup.ID;
                //Manufacturer man = manufacturerManager.GetById(productName.ManIdLookup.ID, true);
                //cboNguonGoc.SelectedValue = man.CountryIdLookup.ID;

                //xoaTrang();

                //Display all column in gridview
                DisplayAll();

                //BindingProductToForm(0);
                //updateProductId = (Int64)gvSanPhamDanhMuc.Rows[0].Cells["ProductId"].Value;

                //BindingProductNameToForm(0);
                //updateProductNameId = (Int32)gvTenSanPham.Rows[0].Cells["ProductNameId"].Value;
            }
            catch (Exception ex)
            {
                logger.Debug(ex.Message);
                logger.Debug(ex.StackTrace);
                MessageBox.Show(ex.StackTrace);
            }
        }
Example #10
0
        private void RefreshGridView(Provider searchEntity)
        {
            //Get all user
            searchParam = new SearchParam();
            searchParam.Start = DEFAULT_START;
            searchParam.Limit = DEFAULT_LIMIT;
            searchParam.SortBy = DEFAULT_SORT_BY;
            searchParam.SortDir = DEFAULT_SORT_DIR;

            //
            this.searchEntity = searchEntity;

            //
            SearchResult<Provider> searchResult = manufacturerManager.GetProviderListByParam(searchEntity, searchParam);
            currentListProvider = searchResult.SearchList;

            //Binding list userrole to gridview
            IList2DataTable(searchResult.SearchList, dataSetProvider.Tables["Provider"]);

            //Binding list to navigator
            listPages = new List<Int32>();
            BindingDataToBindingNagivator(searchResult.SearchSize, 0);
        }
Example #11
0
        private void MoveItem(int position)
        {
            SearchParam searchParam = new SearchParam();
            searchParam.Start = bindingNavigatorProvider.BindingSource.Position * DEFAULT_LIMIT;
            searchParam.Limit = DEFAULT_LIMIT;
            searchParam.SortBy = DEFAULT_SORT_BY;
            searchParam.SortDir = DEFAULT_SORT_DIR;

            //this.BindingDataToForm(searchEntity, searchParam, position);

            SearchResult<Provider> searchResult = manufacturerManager.GetProviderListByParam(searchEntity, searchParam);
            currentListProvider = searchResult.SearchList;

            //Binding list userrole to gridview
            IList2DataTable(searchResult.SearchList, dataSetProvider.Tables["Provider"]);

            //
            BindingDataToBindingNagivator(searchResult.SearchSize, position);
        }
Example #12
0
        private void FrmProvider_Load(object sender, EventArgs e)
        {
            //
            ContructGridViewColumn();

            //Get all user
            searchParam = new SearchParam();
            searchParam.Start = DEFAULT_START;
            searchParam.Limit = DEFAULT_LIMIT;
            searchParam.SortBy = DEFAULT_SORT_BY;
            searchParam.SortDir = DEFAULT_SORT_DIR;

            //
            searchEntity = new Provider();

            //
            SearchResult<Provider> searchResult = manufacturerManager.GetProviderListByParam(searchEntity, searchParam);
            currentListProvider = searchResult.SearchList;

            //Binding list userrole to gridview
            IList2DataTable(searchResult.SearchList, dataSetProvider.Tables["Provider"]);

            //Binding list to navigator
            listPages = new List<Int32>();
            BindingDataToBindingNagivator(searchResult.SearchSize, 0);

            //Binding data to cbbCountry
            cbbCountry.DataSource = countryManager.GetAll();
            cbbCountry.ValueMember = "ID";
            cbbCountry.DisplayMember = "CountryName";

            //
            isAdd = true;
        }
Example #13
0
        private void FrmUser_Load(object sender, EventArgs e)
        {
            try
            {
                //Create column of gridview
                ContructGridViewColumn();

                //Get all user
                searchParam = new SearchParam();
                searchParam.Start = DEFAULT_START;
                searchParam.Limit = DEFAULT_LIMIT;
                searchParam.SortBy = DEFAULT_SORT_BY;
                searchParam.SortDir = DEFAULT_SORT_DIR;

                searchEntity = new User();

                SearchResult<User> searchResult = userManager.GetUserListByParam(searchEntity, searchParam);
                currentListUser = searchResult.SearchList;

                //Binding list user to gridview
                IList2DataTable(currentListUser, dataSetUser.Tables["User"]);

                //
                listPages = new List<Int32>();
                BindingDataToBindingNagivator(searchResult.SearchSize, 0);

                //Binding value for combobox
                cbbUserTitle.DataSource = userTitleManager.GetAll();
                cbbUserTitle.DisplayMember = "UserTitleName";
                cbbUserTitle.ValueMember = "ID";

                cbbUserRole.DataSource = userRoleManager.GetAll();
                cbbUserRole.DisplayMember = "UserRoleName";
                cbbUserRole.ValueMember = "ID";

                cbbUserStatus.DataSource = userStatusManager.GetAll();
                cbbUserStatus.DisplayMember = "UserStatusName";
                cbbUserStatus.ValueMember = "ID";

                //Display all column in gridview
                DisplayAll();
            }
            catch (Exception ex)
            {
                logger.Debug(ex.Message);
                logger.Debug(ex.StackTrace);
                MessageBox.Show(ex.Message);
            }
        }
Example #14
0
        private void MoveItem(int position)
        {
            SearchParam searchParam = new SearchParam();
            searchParam.Start = bindingNavigatorUserStatus.BindingSource.Position * DEFAULT_LIMIT;
            searchParam.Limit = DEFAULT_LIMIT;
            searchParam.SortBy = DEFAULT_SORT_BY;
            searchParam.SortDir = DEFAULT_SORT_DIR;

            //this.BindingDataToForm(searchEntity, searchParam, position);

            SearchResult<UserStatus> searchResult = userStatusManager.GetUserStatusListByParam(searchEntity, searchParam);

            //Binding list userrole to gridview
            IList2DataTable(searchResult.SearchList, dataSetUserStatus.Tables["UserStatus"]);

            //
            BindingDataToBindingNagivator(searchResult.SearchSize, position);
        }
Example #15
0
 private void MoveItemProductName(int position)
 {
     SearchParam searchParam = new SearchParam();
     searchParam.Start = bindingNavigatorProductName.BindingSource.Position * DEFAULT_LIMIT;
     searchParam.Limit = DEFAULT_LIMIT;
     searchParam.SortBy = DEFAULT_SORT_BY;
     searchParam.SortDir = DEFAULT_SORT_DIR;
     this.BindingDataToFormProductName(searchEntityProductName, searchParam, position);
 }
Example #16
0
        private void RefreshGridView(UserStatus searchEntity)
        {
            //Get all user
            searchParam = new SearchParam();
            searchParam.Start = DEFAULT_START;
            searchParam.Limit = DEFAULT_LIMIT;
            searchParam.SortBy = DEFAULT_SORT_BY;
            searchParam.SortDir = DEFAULT_SORT_DIR;

            //
            this.searchEntity = searchEntity;

            //
            SearchResult<UserStatus> searchResult = userStatusManager.GetUserStatusListByParam(searchEntity, searchParam);

            //Binding list userrole to gridview
            IList2DataTable(searchResult.SearchList, dataSetUserStatus.Tables["UserStatus"]);

            //Binding list to navigator
            listPages = new List<Int32>();
            BindingDataToBindingNagivator(searchResult.SearchSize, 0);
        }
Example #17
0
        private void BindingDataToForm(User entity, SearchParam searchParam, int position)
        {
            SearchResult<User> searchResult = userManager.GetUserListByParam(entity, searchParam);

            if (searchResult != null)
            {
                DataTable dataTableUser = new DataTable("User");
                dataTableUser.Columns.Add("UserId", typeof(int));
                dataTableUser.Columns.Add("Username", typeof(string));
                dataTableUser.Columns.Add("FullName", typeof(string));
                dataTableUser.Columns.Add("Email", typeof(string));
                dataTableUser.Columns.Add("Birthday", typeof(string));
                dataTableUser.Columns.Add("IdCardNo", typeof(string));
                dataTableUser.Columns.Add("SexId", typeof(byte));
                dataTableUser.Columns.Add("Sex", typeof(string));

                dataTableUser.Columns.Add("TelNo", typeof(string));
                dataTableUser.Columns.Add("Address", typeof(string));
                dataTableUser.Columns.Add("UserTitleId", typeof(int));
                dataTableUser.Columns.Add("UserTitle", typeof(string));
                dataTableUser.Columns.Add("UserRoleId", typeof(int));
                dataTableUser.Columns.Add("UserRole", typeof(string));
                dataTableUser.Columns.Add("UserStatusId", typeof(int));
                dataTableUser.Columns.Add("UserStatus", typeof(string));

                foreach(User objUser in searchResult.SearchList)
                {
                    DataRow rowTemp = dataTableUser.NewRow();
                    rowTemp["UserId"] = objUser.ID;
                    rowTemp["Username"] = objUser.Username;
                    rowTemp["FullName"] = objUser.FullName;
                    rowTemp["Email"] = objUser.Email;
                    rowTemp["Birthday"] = objUser.Birthday.Value.ToString("dd/MM/yyyy");

                    rowTemp["IdCardNo"] = objUser.IdCardNo;
                    try
                    {
                        if (Int32.Parse(objUser.Sex.ToString()) == 0)
                        {
                            rowTemp["Sex"] = "Nữ";
                            rowTemp["SexId"] = 0;
                        }
                        else {
                            rowTemp["Sex"] = "Nam";
                            rowTemp["SexId"] = 1;
                        }
                    }
                    catch (Exception ex) {
                        rowTemp["Sex"] = "Nam";
                    }

                    rowTemp["TelNo"] = objUser.TelNo;
                    rowTemp["Address"] = objUser.Address;
                    rowTemp["UserTitleId"] = objUser.UserTitleId;
                    if (objUser.UserTitleIdLookup != null)
                    {
                        rowTemp["UserTitle"] = objUser.UserTitleIdLookup.UserTitleName;
                    }
                    else
                    {
                        if (objUser.UserTitleId.HasValue)
                        {
                            UserTitle temp = userTitleManager.GetById(objUser.UserTitleId.Value, false);
                            rowTemp["UserTitle"] = temp.UserTitleName;
                        }
                        else
                        {
                            rowTemp["UserTitle"] = string.Empty;
                        }
                    }
                    rowTemp["UserRoleId"] = objUser.UserRoleId;
                    if (objUser.UserRoleIdLookup != null)
                    {
                        rowTemp["UserRole"] = objUser.UserRoleIdLookup.UserRoleName;
                    }
                    else
                    {
                        if (objUser.UserRoleId != 0)
                        {
                            UserRole temp = userRoleManager.GetById(objUser.UserRoleId, false);
                            rowTemp["UserRole"] = temp.UserRoleName;
                        }
                        else
                        {
                            rowTemp["UserRole"] = string.Empty;
                        }
                    }
                    rowTemp["UserStatusId"] = objUser.UserStatusId;
                    if (objUser.UserStatusIdLookup != null)
                    {
                        rowTemp["UserStatus"] = objUser.UserStatusIdLookup.UserStatusName;
                    }
                    else
                    {
                        UserStatus temp = userStatusManager.GetById(objUser.UserStatusId, false);

                        if (temp != null)
                        {
                            rowTemp["UserStatus"] = temp.UserStatusName;
                        }
                        else
                        {
                            rowTemp["UserStatus"] = string.Empty;
                        }
                    }

                    dataTableUser.Rows.Add(rowTemp);
                }

                dataSetUser = new DataSet();
                dataSetUser.Tables.Add(dataTableUser);
                gvUser.DataSource = dataSetUser;
                gvUser.DataMember = "User";
                gvUser.Columns["UserId"].HeaderText = "Mã người dùng";
                gvUser.Columns["Username"].HeaderText = "Tên đăng nhập";
                gvUser.Columns["FullName"].HeaderText = "Họ và tên";
                gvUser.Columns["Email"].HeaderText = "Email";
                gvUser.Columns["Birthday"].HeaderText = "Ngày sinh";
                gvUser.Columns["IdCardNo"].HeaderText = "Số CMT/Passport";
                gvUser.Columns["Sex"].HeaderText = "Giới tính";
                gvUser.Columns["TelNo"].HeaderText = "Điện thoại";
                gvUser.Columns["Address"].HeaderText = "Địa chỉ";
                gvUser.Columns["UserTitleId"].Visible = false;
                gvUser.Columns["UserTitle"].HeaderText = "Chức vụ";
                gvUser.Columns["UserRoleId"].Visible = false;
                gvUser.Columns["UserRole"].HeaderText = "Nhóm người dùng";
                gvUser.Columns["UserStatusId"].Visible = false;
                gvUser.Columns["UserStatus"].HeaderText = "Trạng thái";

                //
                currentListUser = searchResult.SearchList;

                //
                logger.Debug("searchList size = " + searchResult.SearchList.Count);

                List<Int32> listPages = new List<Int32>();
                int totalPage = 0;

                if (searchResult.SearchSize % DEFAULT_LIMIT > 0)
                {
                    totalPage = (int)searchResult.SearchSize / DEFAULT_LIMIT + 1;
                }
                else
                {
                    totalPage = (int)searchResult.SearchSize / DEFAULT_LIMIT;
                }

                logger.Debug("searchSize = " + searchResult.SearchSize);
                logger.Debug("totalPage = " + totalPage);

                for (int i = 0; i < totalPage; i++)
                {
                    listPages.Add(i);
                }

                bindingNavigatorUser.BindingSource = new BindingSource(listPages, "");
                bindingNavigatorUser.BindingSource.Position = position;
                bindingNavigatorUser.BindingSource.PositionChanged += new EventHandler(BindingSource_PositionChanged);

                //Set total of number user in bindingNavigator
                toolStripLblTotal.Text = "Tổng số người dùng: " + searchResult.SearchSize;
            }
        }