Beispiel #1
0
        public DataSet SearchItems(ItemsSearch itemsSearch)
        {
            try
            {
                Database  db        = DatabaseFactory.CreateDatabase(Constant.Database_Connection_Name);
                DbCommand dbCommand = db.GetStoredProcCommand(Constant.SP_Items_Search);

                db.AddInParameter(dbCommand, "@sItemCode", DbType.String, itemsSearch.ItemCode);
                db.AddInParameter(dbCommand, "@sItemDescription", DbType.String, itemsSearch.ItemDescription);
                db.AddInParameter(dbCommand, "@mSellingPrice", DbType.Currency, itemsSearch.SellingPrice);
                db.AddInParameter(dbCommand, "@iOption", DbType.Int32, itemsSearch.Option);
                db.AddInParameter(dbCommand, "@iSupId", DbType.Int32, itemsSearch.SupId);
                db.AddInParameter(dbCommand, "@iCategoryId", DbType.Int32, itemsSearch.CategoryId);
                db.AddInParameter(dbCommand, "@biQuantityInHand", DbType.Int64, itemsSearch.QuantityInHand);
                db.AddInParameter(dbCommand, "@iROL", DbType.Int32, itemsSearch.ROL);
                db.AddInParameter(dbCommand, "@iBranchId", DbType.Int32, itemsSearch.BranchID);
                db.AddInParameter(dbCommand, "@iBrandId", DbType.Int32, itemsSearch.BrandID);

                return(db.ExecuteDataSet(dbCommand));
            }
            catch (System.Exception ex)
            {
                ex.Data.Add("BusinessLayerException", GetType().ToString() + Constant.Error_Seperator + "public DataSet SearchItems(Item item)");
                return(null);

                throw ex;
            }
        }
Beispiel #2
0
        public DataSet SearchItems(ItemsSearch itemsSearch)
        {
            try
            {
                Database db = DatabaseFactory.CreateDatabase(Constant.Database_Connection_Name);
                DbCommand dbCommand = db.GetStoredProcCommand(Constant.SP_Items_Search);

                db.AddInParameter(dbCommand, "@sItemCode", DbType.String, itemsSearch.ItemCode);
                db.AddInParameter(dbCommand, "@sItemDescription", DbType.String, itemsSearch.ItemDescription);
                db.AddInParameter(dbCommand, "@mSellingPrice", DbType.Currency, itemsSearch.SellingPrice);
                db.AddInParameter(dbCommand, "@iOption", DbType.Int32, itemsSearch.Option);
                db.AddInParameter(dbCommand, "@iSupId", DbType.Int32, itemsSearch.SupId);
                db.AddInParameter(dbCommand, "@iCategoryId", DbType.Int32, itemsSearch.CategoryId);
                db.AddInParameter(dbCommand, "@biQuantityInHand", DbType.Int64, itemsSearch.QuantityInHand);
                db.AddInParameter(dbCommand, "@iROL", DbType.Int32, itemsSearch.ROL);
                db.AddInParameter(dbCommand, "@iBranchId", DbType.Int32, itemsSearch.BranchID);
                db.AddInParameter(dbCommand, "@iBrandId", DbType.Int32, itemsSearch.BrandID);

                return db.ExecuteDataSet(dbCommand);

            }
            catch (System.Exception ex)
            {
                ex.Data.Add("BusinessLayerException", GetType().ToString() + Constant.Error_Seperator + "public DataSet SearchItems(Item item)");
                return null;
                throw ex;
            }
        }
    /// <summary>
    /// Search the products using the values provided in the search controls
    /// </summary>
    public void Search()
    {
        try
        {
            this.ShowHideGrids();

            ItemsSearch searchItem = new ItemsSearch();
            searchItem.ItemCode = txtItemCode.Text.Trim();
            searchItem.ItemDescription = txtItemDescription.Text.Trim();
            decimal selPrice = 0;
            Decimal.TryParse(txtPrice.Text.Trim(), out selPrice);
            searchItem.SellingPrice = selPrice;
            searchItem.Option = ddlStatus.SelectedValue != "-1" ? Int32.Parse(ddlStatus.SelectedValue.Trim()):-1;
            searchItem.SupId = ddlSupplier.SelectedValue != "-1" ? Int32.Parse(ddlSupplier.SelectedValue.Trim()): 0;
            searchItem.CategoryId = ddlCategory.SelectedValue != "-1" ? Int32.Parse(ddlCategory.SelectedValue.Trim()):0;
            Int64 qih = 0;
            Int64.TryParse(txtQuantityInHand.Text.Trim(), out qih);
            searchItem.QuantityInHand = qih;
            int rol = 0;
            int.TryParse(txtROL.Text.Trim(), out rol);
            searchItem.ROL = rol;
            searchItem.BranchID = ddlBranch.SelectedIndex != -1 ? Int32.Parse(ddlBranch.SelectedItem.Value.ToString().Trim()) : 0;
            searchItem.BrandID = ddlBrands.SelectedValue != "-1" ? Int32.Parse(ddlBrands.SelectedValue.Trim()): 0;

            DataSet dsProd = searchItem.Search();
            Session["SearchItems"] = dsProd;

            if (dsProd != null && dsProd.Tables.Count > 0 && dsProd.Tables[0] != null && dsProd.Tables[0].Rows.Count > 0)
            {
                dxgvItemList.DataSource = dsProd;
                dxgvItemList.DataBind();
                trItemList.Visible = true;
            }
            else
            {

                dxgvItemList.DataSource = null;
                dxgvItemList.DataBind();
            }

        }
        catch (Exception ex)
        {

            throw ex;
        }
    }