protected void BtnUpload_Click(object sender, EventArgs e)
        {
            if (FileUploadId.HasFile)
            {
                FileUploadId.SaveAs(Server.MapPath("~/Uploaded_Projects/" + FileUploadId.FileName));
            }
            else
            {
                LblErrorMsg.Text      = "Please select a file";
                LblErrorMsg.ForeColor = Color.Red;
            }

            string CS    = ConfigurationManager.ConnectionStrings["communityDB"].ConnectionString;
            string query = "INSERT INTO Project VALUES(@pId, @pType, @filename, @fileType, @logId)";

            using (SqlConnection conn = new SqlConnection(CS))
            {
                SqlCommand cmd = new SqlCommand(query, conn);
                cmd.Parameters.AddWithValue("pId", LblPojectId.Text);
                cmd.Parameters.AddWithValue("pType", TxtProjectType.Text);
                cmd.Parameters.AddWithValue("filename", FileUploadId.FileName);
                cmd.Parameters.AddWithValue("fileType", Path.GetExtension(FileUploadId.FileName).ToUpper());
                cmd.Parameters.AddWithValue("logId", Session["LoginId"]);
                conn.Open();
                cmd.ExecuteNonQuery();
            }
        }
示例#2
0
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        FileUploadId.SaveAs(Server.MapPath("~/Admin/blood_bank_ID/") + FileUploadId.FileName);

        string sql = "insert into TblBloodBank(BloodBankName,HospitalName,State,District,Address,Email,Phone,Website,fax,LicenseId,Types)values('" + TxtBloodBankName.Text + "','" + TxtHospitalName.Text + "','" + DropDownState.SelectedItem.Value.ToString() + "','" + DropDownDistrict.SelectedItem.Value.ToString() + "','" + TxtAddress.Text + "','" + TxtEmail.Text + "','" + TxtPhone.Text + "','" + TxtWebsite.Text + "','" + TxtFax.Text + "','" + FileUploadId.FileName + "','" + DropDownType.SelectedItem.Value.ToString() + "')";



        SqlCommand cmd = new SqlCommand(sql, con);

        con.Open();
        cmd.ExecuteNonQuery();
        con.Close();

        grid_bind();

        Response.Write("<script>alert('Save Successfully')</script>");
    }