예제 #1
0
    protected void Save_Spbe_Click(object sender, EventArgs e)
    {
        string path = Server.MapPath("Images/");

        if (UploadPP_Spbe.HasFile)
        {
            int filesize = UploadPP_Spbe.PostedFile.ContentLength;
            if (filesize > 2097152)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "scriptkey", "<script>alert('Ukuran file gambar maksimal 2 Megabyte.');</script>");
            }
            else
            {
                UploadPP_Spbe.SaveAs(path + UploadPP_Spbe.FileName);
                string name = "~/Images/" + UploadPP_Spbe.FileName;
                string s    = "INSERT INTO spbe(no_vendor_spbe, id_spbe, tipe_spbe, produk_spbe, nama_spbe, alamat1_spbe, alamat2_spbe, kota_spbe, prov_spbe, rayon_spbe, status_spbe, email_spbe, telp_spbe, koor_spbe, jmlsalur_spbe, jmltruk_spbe, kaptruk_spbe, jmlfill_spbe, jmltimbun_spbe, kaptimbun_spbe, jmltabung_spbe, imgpp_spbe) VALUES('" + TextBox_vendor_spbe.Text + "','" + TextBox_kode_spbe.Text + "','" + TextBox_tipe_spbe.Text + "','" + TextBox_produk_spbe.Text + "','" + TextBox_nama_spbe.Text + "','" + TextBox_alamat1_spbe.Text + "','" + TextBox_alamat2_spbe.Text + "','" + TextBox_kota_spbe.Text + "','" + TextBox_provinsi_spbe.Text + "','" + TextBox_rayon_spbe.Text + "','" + TextBox_status_spbe.Text + "','" + TextBox_email_spbe.Text + "','" + TextBox_telp_spbe.Text + "','" + TextBox_koor_spbe.Text + "','" + TextBox_jmlsalur_spbe.Text + "','" + TextBox_jmltruk_spbe.Text + "','" + TextBox_kaptruk_spbe.Text + "','" + TextBox_jmlfill_spbe.Text + "','" + TextBox_jmltimbun_spbe.Text + "','" + TextBox_kaptimbun_spbe.Text + "','" + TextBox_jmltabung_spbe.Text + "','" + name + "')";

                SqlCommand cmd = new SqlCommand(s, con);
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
                Response.Redirect(Request.RawUrl);
            }
        }
        else
        {
            string s = "INSERT INTO spbe(no_vendor_spbe, id_spbe, tipe_spbe, produk_spbe, nama_spbe, alamat1_spbe, alamat2_spbe, kota_spbe, prov_spbe, rayon_spbe, status_spbe, email_spbe, telp_spbe, koor_spbe, jmlsalur_spbe, jmltruk_spbe, kaptruk_spbe, jmlfill_spbe, jmltimbun_spbe, kaptimbun_spbe, jmltabung_spbe) VALUES('" + TextBox_vendor_spbe.Text + "','" + TextBox_kode_spbe.Text + "','" + TextBox_tipe_spbe.Text + "','" + TextBox_produk_spbe.Text + "','" + TextBox_nama_spbe.Text + "','" + TextBox_alamat1_spbe.Text + "','" + TextBox_alamat2_spbe.Text + "','" + TextBox_kota_spbe.Text + "','" + TextBox_provinsi_spbe.Text + "','" + TextBox_rayon_spbe.Text + "','" + TextBox_status_spbe.Text + "','" + TextBox_email_spbe.Text + "','" + TextBox_telp_spbe.Text + "','" + TextBox_koor_spbe.Text + "','" + TextBox_jmlsalur_spbe.Text + "','" + TextBox_jmltruk_spbe.Text + "','" + TextBox_kaptruk_spbe.Text + "','" + TextBox_jmlfill_spbe.Text + "','" + TextBox_jmltimbun_spbe.Text + "','" + TextBox_kaptimbun_spbe.Text + "','" + TextBox_jmltabung_spbe.Text + "')";

            SqlCommand cmd = new SqlCommand(s, con);
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
            Response.Redirect(Request.RawUrl);
        }
    }
예제 #2
0
    protected void SavePP_Spbe_Click(object sender, EventArgs e)
    {
        string vendor2 = Request.QueryString["spbe"];
        string path2   = Server.MapPath("Images/");

        if (UploadPP_Spbe.HasFile)
        {
            int filesize1 = UploadPP_Spbe.PostedFile.ContentLength;
            if (filesize1 > 2097152)
            {
                Response.Write(@"<script language='javascript'>alert('Ukuran file lebih dari 2Mb');</script>");
            }
            else
            {
                UploadPP_Spbe.SaveAs(path2 + UploadPP_Spbe.FileName);
                string name2 = "~/Images/" + UploadPP_Spbe.FileName;
                string s2    = "UPDATE [dbo].[spbe] SET [imgpp_spbe] = '" + name2 + "' WHERE [id_vendor_spbe] = '" + vendor2 + "'";

                SqlCommand cmd2 = new SqlCommand(s2, con);
                con.Open();
                cmd2.ExecuteNonQuery();
                con.Close();
                Response.Redirect(Request.RawUrl);
            }
        }
        else
        {
        }
    }