예제 #1
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     if (checkSub(SubCatName.Text))
     {
         ErrorMessage.ForeColor = Color.Red;
         ErrorMessage.Text      = "This subcategory already exists";
     }
     else
     {
         String SQL_Insert = "INSERT INTO SubCategory(SubCategoryName,CategoryID) Values('" + SubCatName.Text + "','" + ddlCategory.SelectedItem.Value + "')";
         if (access.AddAndDelInDatabase(SQL_Insert))
         {
             SubCatName.Text = string.Empty;
             ddlCategory.ClearSelection();
             ddlCategory.Items.FindByValue("0").Selected = true;
             ErrorMessage.ForeColor = Color.Green;
             ErrorMessage.Text      = "Successfully Added";
         }
         else
         {
             ErrorMessage.ForeColor = Color.Red;
             ErrorMessage.Text      = "Adding SubCategory not Successful";
         }
         BindSubCatRptr();
     }
 }
예제 #2
0
    protected void DeleteProduct(object sender, EventArgs e)
    {
        Int64 ProductID = Convert.ToInt64(Request.QueryString["ProductID"]);

        access.AddAndDelInDatabase("delete from Products where ProductID='" + ProductID.ToString() + "'");
        Response.Redirect("~/AdminHome.aspx");
    }
예제 #3
0
    protected void DeleteProduct(object sender, CommandEventArgs e)
    {
        int ProductID = Convert.ToInt32(e.CommandArgument);

        access.AddAndDelInDatabase("delete from Products where ProductID='" + ProductID.ToString() + "'");
        Response.Redirect("~/AdminHome.aspx");
    }
예제 #4
0
    }//end of BindCartProducts

    protected void add_ShippingAddress(object sender, EventArgs e)
    {
        if (ShippingAddress.Text == String.Empty)
        {
            EmptyAddress.Text = "Please Enter Valid Email Address";
        }
        else
        {
            String CS = ConfigurationManager.ConnectionStrings["CraftStoreDatabaseConnectionString1"].ConnectionString;
            access.AddAndDelInDatabase("update Customer SET ShippingAddress='" + ShippingAddress.Text + "'where CustomerID='" + Session["userID"] + "'");
            EmptyAddress.Text       = "Provided address added";
            CheckOutButton.Enabled  = true;
            CheckOutButton.CssClass = "btn btn-primary enabled";
        }
    }
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     if (checkCat(CategoryName.Text))
     {
         ErrorMessage.ForeColor = Color.Red;
         ErrorMessage.Text      = "This Category already exist.";
     }
     else
     {
         String SQL_Insert = "INSERT INTO Category(CategoryName) Values('" + CategoryName.Text + "')";
         if (access.AddAndDelInDatabase(SQL_Insert))
         {
             CategoryName.Text      = String.Empty;
             ErrorMessage.ForeColor = Color.Green;
             ErrorMessage.Text      = "Successfully Added";
         }
         else
         {
             ErrorMessage.ForeColor = Color.Red;
             ErrorMessage.Text      = "Adding Category not Successful";
         }
         BindCategoriesRptr();
     }
 }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        int    PID           = Convert.ToInt32(Request.QueryString["PID"]);
        string ProductName   = txtPName.Text;
        string Price         = txtSelPrice.Text;
        int    CategoryID    = Convert.ToInt32(ddlCategory.SelectedItem.Value);
        int    SubCategoryID = Convert.ToInt32(ddlSubCategory.SelectedItem.Value);
        int    InStock       = Convert.ToInt32(txtQuantity.Text);
        string Colour        = colour.Text;
        string Size          = txtSize.Text;
        int    ArtistID      = Convert.ToInt32(ddlArtist.SelectedItem.Value);
        string Description   = txtDesc.Text;
        int    FreeDelivery;
        int    Ret;
        int    COD;
        string ImageType;

        Byte[] Img;

        if (cbFD.Checked == true)
        {
            FreeDelivery = 1;
        }
        else
        {
            FreeDelivery = 0;
        }
        if (cb30Ret.Checked == true)
        {
            Ret = 1;
        }
        else
        {
            Ret = 0;
        }
        if (cbCOD.Checked == true)
        {
            COD = 1;
        }
        else
        {
            COD = 0;
        }
        string filePath    = fuImg01.PostedFile.FileName;
        string filename    = Path.GetFileName(filePath);
        string ext         = Path.GetExtension(filename);
        string contenttype = String.Empty;

        switch (ext)
        {
        case ".jpg":
            contenttype = "image/jpg";
            break;

        case ".png":
            contenttype = "image/png";
            break;

        case ".gif":
            contenttype = "image/gif";
            break;
        }



        Stream       fs = fuImg01.PostedFile.InputStream;
        BinaryReader br = new BinaryReader(fs);

        Byte[] bytes = br.ReadBytes((Int32)fs.Length);

        //insert the file into database

        ImageType = contenttype;
        Img       = bytes;



        access.AddAndDelInDatabase("update Products SET ProductName='" + ProductName + "',Price='" + Price + "',CategoryID='" + CategoryID + "',SubCategoryID='" + SubCategoryID + "',InStock='" + InStock + "',Colour='" + Colour.ToString() + "',Size='" + Size.ToString() + "',ArtistID='" + ArtistID + "',Description='" + Description + "',FreeDelivery='" + FreeDelivery + "',[30DayRet]='" + Ret + "',COD='" + COD + "'where ProductID='" + PID.ToString() + "'");

        Response.Redirect("~/AdminDescription.aspx?ProductID=" + PID + "");
    }