Esempio n. 1
0
        public System.Data.DataTable ListAsDataTable(Int32 BranchID = 0, ProductDetails clsSearchKeys = new ProductDetails(), ProductAddOnFilters ProductAddOnFilters = new ProductAddOnFilters(), ProductListFilterType clsProductListFilterType = ProductListFilterType.ShowActiveAndInactive,
                    long SequenceNoStart = 0, System.Data.SqlClient.SortOrder SequenceSortOrder = System.Data.SqlClient.SortOrder.Ascending, Int32 limit = 0, bool isQuantityGreaterThanZERO = false, string SortField = "ProductCode", SortOption SortOrder = SortOption.Ascending)
		{
			try
			{
                System.Data.DataTable dt = ListAsDataTable(BranchID, clsSearchKeys.BarCode, clsSearchKeys.ProductCode, clsSearchKeys.SupplierID, clsProductListFilterType, 
                                                            isQuantityGreaterThanZERO, ProductAddOnFilters, limit, SortField, SortOrder);
                return dt;
			}
			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}
		}
Esempio n. 2
0
		private void LoadList()
		{	
			string SortField = "ProductDesc";
			if (Request.QueryString["sortfield"]!=null)
			{	SortField = Common.Decrypt(Request.QueryString["sortfield"].ToString(), Session.SessionID);	}
			
			SortOption sortoption = SortOption.Ascending;
			if (Request.QueryString["sortoption"]!=null)
			{	sortoption = (SortOption) Enum.Parse(typeof(SortOption), Common.Decrypt(Request.QueryString["sortoption"], Session.SessionID), true);	}

            ProductListFilterType clsProductListFilterType = ProductListFilterType.ShowActiveOnly;
            if (rdoShowInactiveOnly.Checked == true) clsProductListFilterType = ProductListFilterType.ShowInactiveOnly;
            if (rdoShowActiveOnly.Checked == true) clsProductListFilterType = ProductListFilterType.ShowActiveOnly;
            if (rdoShowAll.Checked == true) clsProductListFilterType = ProductListFilterType.ShowActiveAndInactive;

            int intLimit = 0;
            try { intLimit = int.Parse(txtLimit.Text); }
            catch { }

            string SearchKey = string.Empty;
            if (Request.QueryString["Search"] != null)
            { SearchKey = Server.UrlDecode(Common.Decrypt((string)Request.QueryString["search"], Session.SessionID)); }
            else if (Session["Search"] != null)
            { SearchKey = Server.UrlDecode(Common.Decrypt(Session["Search"].ToString(), Session.SessionID)); }

            try { Session.Remove("Search"); } catch { }
            if (SearchKey == null) { SearchKey = string.Empty; }
            else if (SearchKey != string.Empty) { Session.Add("Search", Common.Encrypt(SearchKey, Session.SessionID)); }

            Data.ProductDetails clsSearchKeys = new Data.ProductDetails();
            clsSearchKeys.BarCode = SearchKey;
            clsSearchKeys.BarCode2 = SearchKey;
            clsSearchKeys.BarCode3 = SearchKey;
            clsSearchKeys.ProductCode = SearchKey;

            ProductAddOnFilters clsProductAddOnFilters = new ProductAddOnFilters();
            clsProductAddOnFilters.BarcodeFrom = txtBarcodeFrom.Text;
            clsProductAddOnFilters.BarcodeTo = txtBarcodeTo.Text;
            clsProductAddOnFilters.ProductCodeFrom = txtProductCodeFrom.Text;
            clsProductAddOnFilters.ProductCodeTo = txtProductCodeTo.Text;
            clsProductAddOnFilters.ProductSubGroupNameFrom = txtProductSubGroupNameFrom.Text;
            clsProductAddOnFilters.ProductSubGroupNameTo = txtProductSubGroupNameTo.Text;
            clsProductAddOnFilters.ProductGroupNameFrom = txtProductGroupnameFrom.Text;
            clsProductAddOnFilters.ProductGroupNameTo = txtProductGroupNameTo.Text;
            clsProductAddOnFilters.SupplierNameFrom = txtSupplierNameFrom.Text;
            clsProductAddOnFilters.SupplierNameTo = txtSupplierNameTo.Text;

            Products clsProduct = new Products();
            System.Data.DataTable dt = clsProduct.ListAsDataTable(clsSearchKeys: clsSearchKeys, ProductAddOnFilters: clsProductAddOnFilters, clsProductListFilterType: clsProductListFilterType, limit: 100, SortField: SortField, SortOrder: SortOption.Ascending);
            clsProduct.CommitAndDispose();

            PageData.DataSource = dt.DefaultView;

			int iPageSize = Convert.ToInt16(Session["PageSize"]) ;
			
			PageData.AllowPaging = true;
			PageData.PageSize = iPageSize;
			try
			{
				PageData.CurrentPageIndex = Convert.ToInt16(cboCurrentPage.SelectedItem.Value) - 1;				
				lstItem.DataSource = PageData;
				lstItem.DataBind();
			}
			catch
			{
				PageData.CurrentPageIndex = 1;
				lstItem.DataSource = PageData;
				lstItem.DataBind();
			}			
			
			cboCurrentPage.Items.Clear();
			for (int i=0; i < PageData.PageCount;i++)
			{
				int iValue = i + 1;
				cboCurrentPage.Items.Add(new ListItem(iValue.ToString(),iValue.ToString()));
				if (PageData.CurrentPageIndex == i)
				{	cboCurrentPage.Items[i].Selected = true;}
				else
				{	cboCurrentPage.Items[i].Selected = false;}
			}
			lblDataCount.Text = " of " + " " + PageData.PageCount;
		}
Esempio n. 3
0
        private System.Data.DataTable ListAsDataTable(Int32 BranchID = 0, string BarCode = "", string ProductCode = "", Int64 SupplierID = 0, ProductListFilterType clsProductListFilterType = ProductListFilterType.ShowActiveAndInactive,
                bool isQuantityGreaterThanZERO = false, ProductAddOnFilters ProductAddOnFilters = new ProductAddOnFilters(), Int32 limit = 0, string SortField = "", SortOption SortOrder = SortOption.Ascending)
        {
            // 26Oct2014 - additional filters ProductCodeFrom, ProductSubGroupNameFrom, ProductGroupNameFrom, SupplierNameFrom
            string SQL = "CALL procProductSelect(@BranchID, @BarCode, @ProductCode, @SupplierID, @ShowActiveAndInactive, @isQuantityGreaterThanZERO, " +
                                                "@BarcodeFrom, @BarcodeTo, " +    
                                                "@ProductCodeFrom, @ProductCodeTo, @ProductSubGroupNameFrom, @ProductSubGroupNameTo, " +
                                                "@ProductGroupNameFrom, @ProductGroupNameTo, @SupplierNameFrom, @SupplierNameTo, " +
                                                "@limit, @SortField, @SortOrder)";


            MySqlCommand cmd = new MySqlCommand();
            cmd.CommandType = System.Data.CommandType.Text;
            cmd.CommandText = SQL;

            cmd.Parameters.AddWithValue("BranchID", BranchID);
            cmd.Parameters.AddWithValue("BarCode", BarCode);
            cmd.Parameters.AddWithValue("ProductCode", ProductCode);
            cmd.Parameters.AddWithValue("SupplierID", SupplierID);
            cmd.Parameters.AddWithValue("ShowActiveAndInactive", clsProductListFilterType.ToString("d"));
            cmd.Parameters.AddWithValue("isQuantityGreaterThanZERO", isQuantityGreaterThanZERO);

            cmd.Parameters.AddWithValue("BarcodeFrom", ProductAddOnFilters.BarcodeFrom);
            cmd.Parameters.AddWithValue("BarcodeTo", ProductAddOnFilters.BarcodeTo);
            cmd.Parameters.AddWithValue("ProductCodeFrom", ProductAddOnFilters.ProductCodeFrom);
            cmd.Parameters.AddWithValue("ProductCodeTo", ProductAddOnFilters.ProductCodeTo);
            cmd.Parameters.AddWithValue("ProductSubGroupNameFrom", ProductAddOnFilters.ProductSubGroupNameFrom);
            cmd.Parameters.AddWithValue("ProductSubGroupNameTo", ProductAddOnFilters.ProductSubGroupNameTo);
            cmd.Parameters.AddWithValue("ProductGroupNameFrom", ProductAddOnFilters.ProductGroupNameFrom);
            cmd.Parameters.AddWithValue("ProductGroupNameTo", ProductAddOnFilters.ProductGroupNameTo);
            cmd.Parameters.AddWithValue("SupplierNameFrom", ProductAddOnFilters.SupplierNameFrom);
            cmd.Parameters.AddWithValue("SupplierNameTo", ProductAddOnFilters.SupplierNameTo);

            cmd.Parameters.AddWithValue("limit", limit);
            cmd.Parameters.AddWithValue("SortField", SortField);
            cmd.Parameters.AddWithValue("SortOrder", SortOrder == SortOption.Ascending ? "ASC" : "DESC");

            string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
            base.MySqlDataAdapterFill(cmd, dt);

            return dt;
        }