protected void BtnUpdate_Click(object sender, EventArgs e) { int pid = Convert.ToInt32(Request.QueryString["id"]); if (FuImg01.HasFile) { string a = Class1.GetRandom(10).ToString(); FuImg01.SaveAs(Request.PhysicalApplicationPath + "./Images/" + a + FuImg01.FileName.ToString()); TxtImage.Text = "./Images/" + a + FuImg01.FileName.ToString(); } SqlConnection con = new SqlConnection(ConnectString); con.Open(); SqlCommand cmd = new SqlCommand("update Table_Product set ProductName=@ProductName, ProductDescription = @Description,ProductPrice = @Price,ProductImages = @Image ,Category = @Cat,Brand = @Brand where id=@id ", con); cmd.Parameters.AddWithValue("@id", pid); cmd.Parameters.AddWithValue("@ProductName", TxtProduceName.Text); cmd.Parameters.AddWithValue("@Description", TxtDescription.Text); cmd.Parameters.AddWithValue("@Price", TxtPrice.Text); cmd.Parameters.AddWithValue("@Image", TxtImage.Text); cmd.Parameters.AddWithValue("@Cat", DdlCategory.SelectedValue.ToString()); cmd.Parameters.AddWithValue("@Brand", DdlBrand.SelectedValue.ToString()); cmd.ExecuteNonQuery(); con.Close(); Response.Redirect("~/AdminProducts.aspx"); }
protected void BtnAdd_Click(object sender, EventArgs e) { con.Open(); a = Class1.GetRandom(10).ToString(); FuImg01.SaveAs(Request.PhysicalApplicationPath + "./Images/" + a + FuImg01.FileName.ToString()); b = "./Images/" + a + FuImg01.FileName.ToString(); SqlCommand cmd = new SqlCommand("insert into Table_Product values('" + TxtProduceName.Text + "','" + TxtDescription.Text + "','" + TxtPrice.Text + "','" + b.ToString() + "','" + DdlCategory.SelectedValue.ToString() + "','" + DdlBrand.SelectedValue.ToString() + "')", con); cmd.ExecuteNonQuery(); con.Close(); Response.Redirect("~/AdminProducts.aspx"); }
protected void BtnAddd_Click(object sender, EventArgs e) { using (SqlConnection con = new SqlConnection(CS)) { SqlCommand cmd = new SqlCommand("procInsertHouses", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@HName", txtHName.Text); cmd.Parameters.AddWithValue("@HPrice", txtPrice.Text); cmd.Parameters.AddWithValue("@HSelPrice", txtSelPrice.Text); cmd.Parameters.AddWithValue("@HBrandID", ddlBrands.SelectedItem.Value); cmd.Parameters.AddWithValue("@HCategoryID", ddlCategory.SelectedItem.Value); cmd.Parameters.AddWithValue("@HSubCatID", ddlSubCategory.SelectedItem.Value); cmd.Parameters.AddWithValue("@HGenre", ddlGenre.SelectedItem.Value); cmd.Parameters.AddWithValue("@HDescription", txtDesc.Text); cmd.Parameters.AddWithValue("@HProductDetails", txtHDetails.Text); cmd.Parameters.AddWithValue("@HMaterialCare", txtMatCare.Text); if (cbFD.Checked == true) { cmd.Parameters.AddWithValue("@FreeDelivery", 1.ToString()); } else { cmd.Parameters.AddWithValue("@FreeDelivery", 0.ToString()); } if (cb30DRet.Checked == true) { cmd.Parameters.AddWithValue("@30daysReturn", 1.ToString()); } else { cmd.Parameters.AddWithValue("@30daysReturn", 0.ToString()); } if (cbCOD.Checked == true) { cmd.Parameters.AddWithValue("@COD", 1.ToString()); } else { cmd.Parameters.AddWithValue("@COD", 0.ToString()); } con.Open(); Int64 HID = Convert.ToInt64(cmd.ExecuteScalar()); //Insert House Floor SizeQuantity for (int i = 0; i < CblSize.Items.Count; i++) { if (CblSize.Items[i].Selected == true) { Int64 SizeID = Convert.ToInt64(CblSize.Items[i].Value); int Quantity = Convert.ToInt32(txtHouseFloor.Text); SqlCommand cmd2 = new SqlCommand("insert into tblHouseSizeQuantity values('" + HID + "','" + SizeID + "','" + Quantity + "')", con); cmd2.ExecuteNonQuery(); } } //Insert and Upload Images if (FuImg01.HasFile) { string SavePath = Server.MapPath("~/House Images/ProductImages/") + HID; if (!Directory.Exists(SavePath)) { Directory.CreateDirectory(SavePath); } string Extention = Path.GetExtension(FuImg01.PostedFile.FileName); FuImg01.SaveAs(SavePath + "\\" + txtHName.Text.ToString().Trim() + "01" + Extention); SqlCommand cmd3 = new SqlCommand("insert into tblHouseImages values ('" + HID + "','" + txtHName.Text.ToString().Trim() + "01" + "','" + Extention + "')", con); cmd3.ExecuteNonQuery(); } if (FuImg02.HasFile) { string SavePath = Server.MapPath("~/House Images/ProductImages/") + HID; if (!Directory.Exists(SavePath)) { Directory.CreateDirectory(SavePath); } string Extention = Path.GetExtension(FuImg02.PostedFile.FileName); FuImg02.SaveAs(SavePath + "\\" + txtHName.Text.ToString().Trim() + "02" + Extention); SqlCommand cmd4 = new SqlCommand("insert into tblHouseImages values ('" + HID + "','" + txtHName.Text.ToString().Trim() + "02" + "','" + Extention + "')", con); cmd4.ExecuteNonQuery(); } if (FuImg03.HasFile) { string SavePath = Server.MapPath("~/House Images/ProductImages/") + HID; if (!Directory.Exists(SavePath)) { Directory.CreateDirectory(SavePath); } string Extention = Path.GetExtension(FuImg03.PostedFile.FileName); FuImg03.SaveAs(SavePath + "\\" + txtHName.Text.ToString().Trim() + "03" + Extention); SqlCommand cmd5 = new SqlCommand("insert into tblHouseImages values ('" + HID + "','" + txtHName.Text.ToString().Trim() + "03" + "','" + Extention + "')", con); cmd5.ExecuteNonQuery(); } if (FuImg04.HasFile) { string SavePath = Server.MapPath("~/House Images/ProductImages/") + HID; if (!Directory.Exists(SavePath)) { Directory.CreateDirectory(SavePath); } string Extention = Path.GetExtension(FuImg04.PostedFile.FileName); FuImg04.SaveAs(SavePath + "\\" + txtHName.Text.ToString().Trim() + "04" + Extention); SqlCommand cmd6 = new SqlCommand("insert into tblHouseImages values ('" + HID + "','" + txtHName.Text.ToString().Trim() + "04" + "','" + Extention + "')", con); cmd6.ExecuteNonQuery(); } if (FuImg05.HasFile) { string SavePath = Server.MapPath("~/House Images/ProductImages/") + HID; if (!Directory.Exists(SavePath)) { Directory.CreateDirectory(SavePath); } string Extention = Path.GetExtension(FuImg05.PostedFile.FileName); FuImg05.SaveAs(SavePath + "\\" + txtHName.Text.ToString().Trim() + "05" + Extention); SqlCommand cmd7 = new SqlCommand("insert into tblHouseImages values ('" + HID + "','" + txtHName.Text.ToString().Trim() + "05" + "','" + Extention + "')", con); cmd7.ExecuteNonQuery(); } } }