예제 #1
0
        protected void edit_Click(object sender, EventArgs e)
        {
            string conn = ConfigurationManager.ConnectionStrings["sqlconnection"].ToString();
            SqlConnection obj = new SqlConnection(conn);
            obj.Open();

            string sno = Request.QueryString["sno"];
            string filename1 = Image1.ImageUrl;
            string filename2 = Image2.ImageUrl;
            string filename3 = Image3.ImageUrl;
            if (PhotoUploadControl1.HasFile)
            {
                Random random = new Random();
                filename1 = Convert.ToString(random.Next(10, 200)) + Path.GetFileName(PhotoUploadControl1.PostedFile.FileName);
                PhotoUploadControl1.SaveAs(Server.MapPath("prod_pic/" + filename1));
                filename1 = "prod_pic/" + filename1;
            }
            
            if (PhotoUploadControl2.HasFile)
            {
                Random random = new Random();
                filename2 = Convert.ToString(random.Next(10, 200)) + Path.GetFileName(PhotoUploadControl2.PostedFile.FileName);
                PhotoUploadControl2.SaveAs(Server.MapPath("prod_pic/" + filename2));
                filename2 = "prod_pic/" + filename2;
            }
            
            if (PhotoUploadControl3.HasFile)
            {
                Random random = new Random();
                filename3 = Convert.ToString(random.Next(10, 200)) + Path.GetFileName(PhotoUploadControl3.PostedFile.FileName);
                PhotoUploadControl3.SaveAs(Server.MapPath("prod_pic/" + filename3));
                filename3 = "prod_pic/" + filename3;
            }


            SqlCommand objcmd = new SqlCommand("update pro_detail set category_id = '" + category.SelectedValue + "',sub_category_id='" + sub_category.SelectedValue + "',brand ='" + brand.Text + "',weight = '" + weight.Text + "',price = '" + price.Text + "',off_price = '" + off_price.Text + "',tot_qty = '" + stock_qty.Text + "',image1 = '" + filename1 + "',image2 = '" + filename2 + "',image3 = '" + filename3 + "' where id = '" + sno + "'", obj);
            objcmd.ExecuteNonQuery();
            Response.Write(@"<script language='javascript'>alert('Product Successfully Updated');window.location.href='all_products.aspx';</script>");

        }
예제 #2
0
        protected void add_Click(object sender, EventArgs e)
        {
            string        conn = ConfigurationManager.ConnectionStrings["sqlconnection"].ToString();
            SqlConnection obj  = new SqlConnection(conn);

            obj.Open();

            string filename1 = "";
            string filename2 = "";
            string filename3 = "";

            if (PhotoUploadControl1.HasFile)
            {
                Random random = new Random();
                filename1 = Convert.ToString(random.Next(10, 200)) + Path.GetFileName(PhotoUploadControl1.PostedFile.FileName);
                PhotoUploadControl1.SaveAs(Server.MapPath("prod_pic/" + filename1));
                filename1 = "prod_pic/" + filename1;
            }
            if (PhotoUploadControl2.HasFile)
            {
                Random random = new Random();
                filename2 = Convert.ToString(random.Next(10, 200)) + Path.GetFileName(PhotoUploadControl2.PostedFile.FileName);
                PhotoUploadControl2.SaveAs(Server.MapPath("prod_pic/" + filename2));
                filename2 = "prod_pic/" + filename2;
            }
            if (PhotoUploadControl3.HasFile)
            {
                Random random = new Random();
                filename3 = Convert.ToString(random.Next(10, 200)) + Path.GetFileName(PhotoUploadControl3.PostedFile.FileName);
                PhotoUploadControl3.SaveAs(Server.MapPath("prod_pic/" + filename3));
                filename3 = "prod_pic/" + filename3;
            }

            SqlCommand objcmd = new SqlCommand("insert into pro_detail(category_id,sub_category_id,brand,weight,image1,image2,image3,price,off_price,tot_qty) values ('" + category.SelectedValue + "','" + sub_category.SelectedValue + "','" + brand.Text + "','" + weight.Text + "','" + filename1 + "','" + filename2 + "','" + filename3 + "','" + price.Text + "','" + off_price.Text + "','" + stock_qty.Text + "')", obj);

            objcmd.ExecuteNonQuery();
            Response.Write(@"<script language='javascript'>alert('Product Details Successfully Saved');window.location.href='add_product.aspx';</script>");
        }