예제 #1
0
    private DataTable CreateDataSource()
    {
        ProductsTransaction p          = new ProductsTransaction();
        DataTable           dtProducts = p.SearchProduct(txtSKU.Text.Trim(), ddlBrand.SelectedItem.Value.Trim(), ddlServices.SelectedItem.Value.Trim(), ddlSubCategory.SelectedItem.Value.Trim(), connstring);

        return(dtProducts);
    }
예제 #2
0
    protected void btnShowAll_Click(object sender, EventArgs e)
    {
        ViewState["SearchString"] = "";
        ProductsTransaction p = new ProductsTransaction();

        lstProducts.DataSource     = p.QueryProducts(connstring, "", hdnSubCategoryId.Value.Trim(), hdnCategoryId.Value.Trim(), ViewState["Mode"].ToString().Trim());
        lstProducts.DataTextField  = ((ViewState["Mode"].ToString().Trim() == Constant.HIDESKU.ToString().Trim()) ? "ItemName_NoSKU" : "ItemName");
        lstProducts.DataValueField = "VALUE";
        lstProducts.DataBind();
    }
예제 #3
0
    private void UpdateProduct()
    {
        ProductsTransaction P = new ProductsTransaction();
        int result            = P.UpdateProduct(txtSKU.Text.Trim(), txtItemName.Text.Trim(), txtProductDescription.Text.Trim(), ddlUnitOfMeasure.SelectedItem.Value.Trim(), ddlCategory.SelectedItem.Value.Trim(), ddlSubCategory.SelectedItem.Value.Trim(), ddlBrand.SelectedItem.Value.Trim(), ddlServiceType.SelectedItem.Value.Trim(), connstring);

        if (result == 0)
        {
            lblMessage.Text = "Update Successful.";
        }
        else
        {
            lblMessage.Text = "Update Failed.";
        }
    }
예제 #4
0
    private void DeleteProduct()
    {
        ProductsTransaction P = new ProductsTransaction();
        int result            = P.UpdateProductStatus(ViewState["SKU"].ToString(), 1, connstring);

        if (result == 0)
        {
            lblMessage.Text = "Product successfully deleted.";
            Response.Redirect("product.aspx");
        }
        else
        {
            lblMessage.Text = "Delete failed.";
        }
    }
예제 #5
0
    private void InsertProduct()
    {
        ProductsTransaction P = new ProductsTransaction();
        int count             = P.InsertProduct(txtSKU.Text.Trim(), txtItemName.Text.Trim(), txtProductDescription.Text.Trim(), ddlUnitOfMeasure.SelectedItem.Value.Trim(), ddlCategory.SelectedItem.Value.Trim(), ddlSubCategory.SelectedItem.Value.Trim(), ddlBrand.SelectedItem.Value.Trim(), ddlServiceType.SelectedItem.Value.Trim(), connstring);

        if (count > 0)
        {
            lblSKUAlreadyExists.Text = "Product SKU already exists. Please enter another SKU.";
            lblMessage.Text          = "";
        }
        else
        {
            lblSKUAlreadyExists.Text = "";
            lblMessage.Text          = "Insert Successful.";
        }
    }
예제 #6
0
 protected void gvProducts_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName.Equals("recoverProduct"))
     {
         ProductsTransaction P = new ProductsTransaction();
         int result            = P.UpdateProductStatus(e.CommandArgument.ToString(), 0, connstring);
         if (result == 0)
         {
             Session["message"] = "Product successfully recovered.";
             Response.Redirect("recoverproduct.aspx");
         }
         else
         {
             Session["message"] = "Recover failed.";
         }
     }
 }
예제 #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //FormsAuthenticationHelper.AuthenticateUserWithReturnUrl();
        connstring = Client.ConnectionString(HttpContext.Current.Session["clientid"].ToString());
        //if (Int32.Parse(Session[Constant.SESSION_USERTYPE].ToString().Trim()) != (int)Constant.USERTYPE.BUYER)
        //    Response.Redirect("../unauthorizedaccess.aspx");

        if (!(IsPostBack))
        {
            if (Request.QueryString[Constant.QS_CATEGORYID] != null)
            {
                hdnCategoryId.Value = Request.QueryString[Constant.QS_CATEGORYID].Trim();
            }
            if (Request.QueryString[Constant.QS_SUBCATEGORYID] != null)
            {
                hdnSubCategoryId.Value = Request.QueryString[Constant.QS_SUBCATEGORYID].Trim();
            }
            if (Request.QueryString[Constant.QS_SEARCHTEXT] != null)
            {
                txtSearch.Text = Request.QueryString[Constant.QS_SEARCHTEXT].Trim();
            }
            if (Request.QueryString[Constant.QS_CONTROLID] != null)
            {
                hdnControlId.Value = Request.QueryString[Constant.QS_CONTROLID].Trim();
            }

            ViewState["SearchString"] = txtSearch.Text.Trim();
            ViewState["Mode"]         = Constant.SHOWSKU.ToString().Trim();

            CategoryTransaction c = new CategoryTransaction();
            lblCategory.Text = c.GetCategoryNameById(connstring, hdnCategoryId.Value.Trim());

            SubCategory s = new SubCategory();
            lblSubCategory.Text = s.GetSubCategoryNameById(connstring, hdnSubCategoryId.Value.Trim());

            btnClose.Attributes.Add("onclick", "Close();");
            btnOK.Attributes.Add("onclick", "SelectProduct('" + hdnControlId.Value + "');");

            ProductsTransaction p = new ProductsTransaction();
            lstProducts.DataSource     = p.QueryProducts(connstring, ViewState["SearchString"].ToString().Trim(), hdnSubCategoryId.Value.Trim(), hdnCategoryId.Value.Trim(), ViewState["Mode"].ToString().Trim());
            lstProducts.DataTextField  = ((ViewState["Mode"].ToString().Trim() == Constant.HIDESKU.ToString().Trim()) ? "ItemName_NoSKU" : "ItemName");
            lstProducts.DataValueField = "VALUE";
            lstProducts.DataBind();
        }
    }
예제 #8
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        lblMessage.Text         = "";
        lblSubCategoryName.Text = "";
        ProductsTransaction P = new ProductsTransaction();
        int count             = P.InsertSubCategory(connstring, ddlCategory.SelectedItem.Value.Trim(), txtSubCategoryName.Text.Trim(), txtSubCategoryDesc.Text.Trim());

        if (count > 0)
        {
            lblSubCategoryName.Text = "Sub-Category Name already exists. Please enter another Sub-Category Name.";
            lblMessage.Text         = "";
        }
        else
        {
            lblSubCategoryName.Text = "";
            lblMessage.Text         = "Insert Successful.";
        }
    }
예제 #9
0
    protected void btnSKU_Click(object sender, EventArgs e)
    {
        if (btnSKU.Text.ToUpper().Trim() == "HIDE SKU")
        {
            btnSKU.Text       = "Show SKU";
            ViewState["Mode"] = Constant.HIDESKU.ToString().Trim();
        }
        else
        {
            btnSKU.Text       = "Hide SKU";
            ViewState["Mode"] = Constant.SHOWSKU.ToString().Trim();
        }
        ProductsTransaction p = new ProductsTransaction();

        lstProducts.DataSource     = p.QueryProducts(connstring, ViewState["SearchString"].ToString().Trim(), hdnSubCategoryId.Value.Trim(), hdnCategoryId.Value.Trim(), ViewState["Mode"].ToString().Trim());
        lstProducts.DataTextField  = ((ViewState["Mode"].ToString().Trim() == Constant.HIDESKU.ToString().Trim())? "ItemName_NoSKU" : "ItemName");
        lstProducts.DataValueField = "VALUE";
        lstProducts.DataBind();
    }
예제 #10
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        lblMessage.Text      = "";
        lblCategoryId.Text   = "";
        lblCategoryName.Text = "";
        ProductsTransaction P   = new ProductsTransaction();
        Category            cat = P.InsertCategory(connstring, txtCategoryId.Text.Trim(), txtCategoryName.Text.Trim(), txtCategoryDesc.Text.Trim());

        if ((cat.IdCount == "0") && (cat.NameCount == "0"))
        {
            lblMessage.Text = "Insert successful.";
        }
        else
        {
            if (cat.IdCount.ToString().Trim() != "0")
            {
                lblCategoryId.Text = "Category Id already exists!";
            }
            if (cat.NameCount.ToString().Trim() != "0")
            {
                lblCategoryName.Text = "Category Name already exists!";
            }
        }
    }
예제 #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        FormsAuthenticationHelper.AuthenticateUserWithReturnUrl();
        connstring          = Client.ConnectionString(HttpContext.Current.Session["clientid"].ToString());
        PageTitle.InnerText = String.Format(Constant.TITLEFORMAT, "Search Result");
        if (!(IsPostBack))
        {
            if ((Session[Constant.SESSION_USERID] != null) && (Session[Constant.SESSION_USERTYPE] != null))
            {
                ViewState[Constant.SESSION_USERID] = Int32.Parse(Session[Constant.SESSION_USERID].ToString().Trim());
                int userID = Int32.Parse(ViewState[Constant.SESSION_USERID].ToString().Trim());

                int    usertype     = Int32.Parse(Session[Constant.SESSION_USERTYPE].ToString().Trim());
                string searchstring = "";
                int    searchType   = 1;
                if (Request.QueryString["searchstring"] != null)
                {
                    searchstring = Request.QueryString["searchstring"].ToString().Trim();
                }
                if (Request.QueryString["searchType"] != null)
                {
                    searchType = Int32.Parse(Request.QueryString["searchType"].ToString().Trim());
                }

                if ((searchType >= 1) && (searchType <= 6))
                {
                    if ((searchType >= 1) && (searchType <= 3))
                    {
                        gvSearchResultForItems.Columns[0].HeaderText = "Bid Reference No.";
                        gvSearchResultForItems.Columns[1].HeaderText = "Bid Items";
                    }
                    else
                    {
                        gvSearchResultForItems.Columns[0].HeaderText = "Auction Reference No.";
                        gvSearchResultForItems.Columns[1].HeaderText = "Auction Items";
                    }

                    gvSearchResultForItems.Visible = true;

//                    BidItemTransaction items = new BidItemTransaction();

                    DataTable dtItems = BidItemTransaction.QuerySearchedItemByItemDesc(connstring, searchType, searchstring, usertype, userID);

                    if (dtItems.Rows.Count > 0)
                    {
                        DataView dvItems = new DataView(dtItems);

                        gvSearchResultForItems.DataSource = dvItems;
                        gvSearchResultForItems.DataBind();
                    }
                    else
                    {
                        lblIsEmpty.Visible = true;
                        lblIsEmpty.Text    = "No matches for '" + searchstring + "' found.";
                    }
                }
                else if (searchType == 7)
                {
                    ProductsTransaction products = new ProductsTransaction();

                    DataTable dtProducts = products.QueryProductsViaName(connstring, searchstring);
                    // DataView dvProducts = new DataView(dtProducts);

                    if (dtProducts.Rows.Count > 0)
                    {
                        gvProducts.Visible = true;

                        gvProducts.DataSource = dtProducts;
                        gvProducts.DataBind();
                    }
                    else
                    {
                        lblIsEmpty.Visible = true;
                        lblIsEmpty.Text    = "No matches for '" + searchstring + "' found.";
                    }
                }
                else if (searchType == 8)
                {
                    CompanyTransaction vendor = new CompanyTransaction();

                    DataTable dtVendor = vendor.QueryVendorSearch(connstring, searchstring);

                    if (dtVendor.Rows.Count > 0)
                    {
                        DataView dvVendor = new DataView(dtVendor);

                        gvSuppliers.Visible    = true;
                        gvSuppliers.DataSource = dvVendor;
                        gvSuppliers.DataBind();
                    }
                    else
                    {
                        lblIsEmpty.Visible = true;
                        lblIsEmpty.Text    = "No matches for '" + searchstring + "' found.";
                    }
                }
            }
        }
    }
예제 #12
0
    protected void gridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        ViewState[Constant.SESSION_USERID] = Int32.Parse(Session[Constant.SESSION_USERID].ToString().Trim());
        int    userID   = Int32.Parse(ViewState[Constant.SESSION_USERID].ToString().Trim());
        string usertype = Session[Constant.SESSION_USERTYPE].ToString().Trim();

        if (Request.QueryString["usertype"] != null)
        {
            usertype = Request.QueryString["usertype"].ToString().Trim();
        }
        string searchstring = "";

        if (Request.QueryString["searchstring"] != null)
        {
            searchstring = Request.QueryString["searchstring"].ToString().Trim();
        }
        string searchType = "1";

        if (Request.QueryString["searchType"] != null)
        {
            searchType = Request.QueryString["searchType"].ToString().Trim();
        }

        if ((Int32.Parse(searchType) >= 1) && (Int32.Parse(searchType) <= 6))
        {
            if ((Int32.Parse(searchType) >= 1) && (Int32.Parse(searchType) <= 3))
            {
                gvSearchResultForItems.Columns[0].HeaderText = "Bid Reference No.";
                gvSearchResultForItems.Columns[1].HeaderText = "Bid Items";
            }
            else
            {
                gvSearchResultForItems.Columns[0].HeaderText = "Auction Reference No.";
                gvSearchResultForItems.Columns[1].HeaderText = "Auction Items";
            }

            gvSearchResultForItems.Visible = true;

            DataTable dtItems = BidItemTransaction.QuerySearchedItemByItemDesc(connstring, Int32.Parse(searchType), searchstring, Int32.Parse(usertype), userID);
            DataView  dvItems = new DataView(dtItems);

            gvSearchResultForItems.DataSource = dvItems;
            gvSearchResultForItems.PageIndex  = e.NewPageIndex;
            gvSearchResultForItems.DataBind();
        }
        else if (Int32.Parse(searchType) == 7)
        {
            ProductsTransaction products = new ProductsTransaction();

            DataTable dtProducts = products.QueryProductsViaName(connstring, searchstring);

            gvProducts.Visible = true;

            gvProducts.DataSource = dtProducts;
            gvProducts.PageIndex  = e.NewPageIndex;
            gvProducts.DataBind();
        }
        else if (Int32.Parse(searchType) == 8)
        {
            CompanyTransaction vendor = new CompanyTransaction();

            DataTable dtVendor = vendor.QueryVendorSearch(connstring, searchstring);
            DataView  dvVendor = new DataView(dtVendor);

            gvSuppliers.Visible = true;

            gvSuppliers.DataSource = dvVendor;
            gvSuppliers.PageIndex  = e.NewPageIndex;
            gvSuppliers.DataBind();
        }
    }
예제 #13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        FormsAuthenticationHelper.AuthenticateUserWithReturnUrl();
        connstring = HttpContext.Current.Session["ConnectionString"].ToString();
        if (Int32.Parse(Session[Constant.SESSION_USERTYPE].ToString().Trim()) != (int)Constant.USERTYPE.ADMINISTRATOR)
        {
            Response.Redirect("../unauthorizedaccess.aspx");
        }

        if (!(Page.IsPostBack))
        {
            if (Session["SKU"] != null)
            {
                ViewState["SKU"] = Session["SKU"].ToString().Trim();
            }

            BrandsTransaction            brand = new BrandsTransaction();
            ServicesTransaction          serv  = new ServicesTransaction();
            SubCategory                  sub   = new SubCategory();
            CategoryTransaction          c     = new CategoryTransaction();
            ServicesTransaction          s     = new ServicesTransaction();
            UnitOfMeasurementTransaction u     = new UnitOfMeasurementTransaction();

            ddlUnitOfMeasure.DataSource     = u.GetAllUnitsOfMeasurement(connstring);
            ddlUnitOfMeasure.DataTextField  = "UnitOfMeasureName";
            ddlUnitOfMeasure.DataValueField = "UnitOfMeasureID";
            ddlUnitOfMeasure.DataBind();
            ddlUnitOfMeasure.Items.Insert(0, "");


            ddlCategory.DataSource     = c.GetAllCategories(connstring);
            ddlCategory.DataTextField  = "CategoryName";
            ddlCategory.DataValueField = "CategoryId";
            ddlCategory.DataBind();
            ddlCategory.Items.Insert(0, "");

            ddlSubCategory.DataSource     = sub.GetAllSubCategories(connstring);
            ddlSubCategory.DataTextField  = "SubCategoryName";
            ddlSubCategory.DataValueField = "SubCategoryId";
            ddlSubCategory.DataBind();
            ddlSubCategory.Items.Insert(0, "");

            ddlBrand.DataSource     = brand.GetAllBrands(connstring);
            ddlBrand.DataTextField  = "BrandName";
            ddlBrand.DataValueField = "BrandId";
            ddlBrand.DataBind();
            ddlBrand.Items.Insert(0, "");

            ddlServiceType.DataSource     = s.GetAllServices(connstring);
            ddlServiceType.DataTextField  = "ServiceName";
            ddlServiceType.DataValueField = "ServiceId";
            ddlServiceType.DataBind();
            ddlServiceType.Items.Insert(0, "");

            if (ViewState["SKU"] != null)
            {
                ProductsTransaction p  = new ProductsTransaction();
                Product             po = new Product();
                po                             = p.QueryProductBySKU(ViewState["SKU"].ToString().Trim(), connstring);
                txtSKU.Enabled                 = false;
                txtSKU.Text                    = po.SKU.Trim();
                txtItemName.Text               = po.ItemName.Trim();
                txtProductDescription.Text     = po.ProductDescription.Trim();
                ddlUnitOfMeasure.SelectedIndex = ddlUnitOfMeasure.Items.IndexOf(ddlUnitOfMeasure.Items.FindByValue(po.UnitOfMeasure.Trim()));
                ddlCategory.SelectedIndex      = ddlCategory.Items.IndexOf(ddlCategory.Items.FindByValue(po.Category.Trim()));
                ddlSubCategory.SelectedIndex   = ddlSubCategory.Items.IndexOf(ddlSubCategory.Items.FindByValue(po.SubCategory.Trim()));
                ddlBrand.SelectedIndex         = ddlBrand.Items.IndexOf(ddlBrand.Items.FindByValue(po.Brand.Trim()));
                ddlServiceType.SelectedIndex   = ddlServiceType.Items.IndexOf(ddlServiceType.Items.FindByValue(po.ServiceType.Trim()));
                btnDelete.Visible              = true;
            }
        }
    }