Ejemplo n.º 1
0
    protected void ButtonAdd_Click2(object sender, EventArgs e)
    {
        string CS = ConfigurationManager.ConnectionStrings["CustomerInfoConnectionString"].ConnectionString;

        if (FileImage.HasFile)
        {
            SavePath = Server.MapPath("~/Images/ProductImage/") + PID;
            if (!Directory.Exists(SavePath))
            {
                Directory.CreateDirectory(SavePath);
            }
            Extention = Path.GetExtension(FileImage.PostedFile.FileName);
            FileImage.SaveAs(SavePath + "\\" + TextBoxCarName.Text.ToString().Trim() + TextBoxCarModel.Text + Extention);
        }


        using (SqlConnection con = new SqlConnection(CS))
        {
            SqlCommand command = new SqlCommand("insert into CarRent values('" + TextBoxCarName.Text + "', '" + TextBoxCarModel.Text + "', '" + TextBoxCarPrice.Text + "', '" + TextBoxCarName.Text + TextBoxCarModel.Text.ToString().Trim() + "', '" + Extention + "', '" + TextBoxDescription.Text + "', '" + TextBoxReviewLink.Text + "' , '" + TextBoxAvailable.Text + "')", con);

            con.Open();
            command.ExecuteNonQuery();

            LabelAdd.Text           = "Successfully Added ! ";
            TextBoxCarName.Text     = "";
            TextBoxCarPrice.Text    = "";
            TextBoxCarModel.Text    = "";
            TextBoxAvailable.Text   = "";
            TextBoxReviewLink.Text  = "";
            TextBoxDescription.Text = "";
        }
    }
        private string save()
        {
            string root     = Server.MapPath("~");
            string savePath = root + "\\Images\\";
            string filename = TextCode.Text + ".jpg";

            FileImage.SaveAs(savePath + filename);
            return("\\Images\\" + filename);
        }
Ejemplo n.º 3
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (FileImage.HasFile)
     {
         string extension = (string)Path.GetExtension(FileImage.FileName);
         if (extension == ".jpg" || extension == ".png" || extension == ".jpeg" || extension == ".gif" || extension == ".bmp")
         {
             string s = ("~/Error Screenshot/" + FileImage.FileName).ToString();
             FileImage.SaveAs(Server.MapPath(s));
             lblStatus.Visible   = true;
             lblStatus.ForeColor = System.Drawing.Color.Blue;
             lblStatus.Text      = "Email Sent";
             imgProduct.Visible  = true;
             imgProduct.ImageUrl = "~/Error Screenshot/" + FileImage.FileName;
             SendEmail  se  = new SendEmail();
             string     msg = "This is a new Error that the user is facing reported by " + (string)Session["Email"] + "   Description Of the Error: " + TextBox1.Text;
             SqlCommand cmd = con.CreateCommand();
             cmd.CommandText = "Select Admin_email_id from Admin";
             DataTable      dt = new DataTable();
             SqlDataAdapter da = new SqlDataAdapter(cmd);
             da.Fill(dt);
             foreach (DataRow dr in dt.Rows)
             {
                 string email = (string)dr["Admin_email_id"];
                 se.sendEMail(email, msg, "E:\\Project\\CMSW\\Error Screenshot\\" + FileImage.FileName);
             }
             SendEmail1 sq   = new SendEmail1();
             string     mess = "We have Acknowledged Your Request Thank You For Reporting We will Get Back To You as Soon as possible " + (string)Session["Name"];
             sq.sendEMail((string)Session["Email"], mess);
         }
         else
         {
             imgProduct.Visible = false;
             lblStatus.Visible  = true;
             lblStatus.Text     = "Please Upload Correct Format File";
         }
     }
     else
     {
         imgProduct.Visible = false;
         lblStatus.Visible  = true;
         lblStatus.Text     = "Please Upload Image File";
     }
 }
Ejemplo n.º 4
0
 protected void btnNext_Click(object sender, EventArgs e)
 {
     if (FileImage.HasFile)
     {
         string extension = (string)Path.GetExtension(FileImage.FileName);
         if (extension == ".jpg" || extension == ".png" || extension == ".jpeg" || extension == ".gif" || extension == ".bmp")
         {
             string s = ("~/Uploads/" + FileImage.FileName).ToString();
             FileImage.SaveAs(Server.MapPath(s));
             lblStatus.Visible  = true;
             lblStatus.Text     = "File Uploaded";
             imgProduct.Visible = true;
             if (CheckBox1.Checked == true)
             {
                 abc = true;
             }
             else
             {
                 abc = false;
             }
             imgProduct.ImageUrl = "~/Uploads/" + FileImage.FileName;
             InsertDetail(s, abc);
             Response.Redirect("Products.aspx");
         }
         else
         {
             imgProduct.Visible = false;
             lblStatus.Visible  = true;
             lblStatus.Text     = "Please Upload Correct Format File";
         }
     }
     else
     {
         imgProduct.Visible = false;
         lblStatus.Visible  = true;
         lblStatus.Text     = "Please Upload Image File";
     }
 }
        protected void btnChange_Click(object sender, EventArgs e)
        {
            if (FileImage.HasFile)
            {
                string fileName      = FileImage.FileName.Trim();
                string fileExtension = Path.GetExtension(fileName).Trim();

                // check for the file extension
                if (fileExtension.ToLower() == ".jpg" || fileExtension.ToLower() == ".png")
                {
                    // save file in Uploads folder
                    FileImage.SaveAs(Server.MapPath("~/Resources/") + fileName);
                    imageButtonProfile.ImageUrl = "~/Resources/" + fileName;
                    //lblMessage.Text = "File successfully uploaded";
                    lblMessage.ForeColor = Color.Green;
                }

                else
                {
                    lblMessage.Text      = "Only .jpg or .png files are allowed";
                    lblMessage.ForeColor = Color.Red;
                }
            }
        }