Esempio n. 1
0
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        //deklarasi variabel
        string nama  = string.Empty;
        string email = string.Empty;
        string pass  = string.Empty;
        string ttl   = string.Empty;

        nama  = TxtNama.Text;
        email = TxtEmail.Text;
        pass  = TxtPswd.Text;
        ttl   = TxtTTL.Text;
        //Pemanggilan fungsi
        Koneksi cn    = new Koneksi();
        string  Hasil = cn.KelasKoneksi_Insert(nama, pass, email, ttl);

        if (Hasil == "1")
        {
            string sqlselect = "select max(member_id) as member_id from Ms_member";

            List <string> memberid = cn.KelasKoneksi_SelectGlobal(sqlselect, "5");
            foreach (string item in memberid)
            {
                string isipesan = "<div style='background:linear-gradient(#c0c0c0, #f5f5f5);border-bottom:1px solid #d60000;padding:5px;font-family:verdana;'>Pemberitahuan IT Web System</div><div style='font-family:verdana;font-size:10pt;padding:4px;margin:5px auto;border-left:3px solid #0080c0;'><div style='margin:0 auto;background: #FFfFD5;width:50%;padding:5px;border-radius:4px;border-left:3px solid #0080c0;font-family:verdana;font-size:10pt;'> Selamat, Registrasi Anda Berhasil!<br/> Berikut Adalah Detail Akun Anda Untuk Login ; <br/> Username : "******"<br/>Password : "******"<br/> Jaga selalu Kerahasiaan Akun Anda. Kami Tidak Bertanggung Jawab atas Kelalaian yang di sebabkan Oleh Pengguna.  <br/><span style='color:blue;font-size:8pt;'></span></div><br/><br><center style='color: blue; '></center><br/><center>Atas perhatian dan kerjasamanya kami ucapkan terimakasih.</center><br/><br/><br/><strong style='color:blue;font-family:verdana;'>Regards,<br/><i style='font-size:8pt;color:#666;'>Web System | IT Departement</i></strong><br/><strong>IT Group</strong><br/><i>PT. YourCompanyName</i><br/><span style='font-size:9pt;color:#666;'>Jakarta - Indonesia<br/>Branch Address</span><br/>Phone Number<br/>Website : <a href=# target='_blank'>Your Web</a><br/></div>";
                HasilEmail = cn.email_otomatis(email, isipesan);
                //Response.Write("<script language='javascript'>window.alert('Sukses Menyimpan Data !');window.location='../Login.aspx';</script>");
            }
            if (HasilEmail == "OK")
            {
                Response.Write("<script language='javascript'>window.alert('Sukses Menyimpan Data, Cek Email Anda Segera !');window.location='../Login.aspx';</script>");
            }
            else
            {
                Response.Write("<script language='javascript'>window.alert('Gagal Menyimpan Data!');window.location='../Login.aspx';</script>");
            }

            //kirim email id login dan passwordnya
            //redirect ke menu login
        }
        else
        {
            Response.Write("<script language=javascript>alert('gagal Insert Data, dengan Error : " + Hasil + "');</script>");
        }
    }
Esempio n. 2
0
    protected void BtnLogin_Click(object sender, EventArgs e)
    {
        //ke tb userakses berdasarkan member id
        //Panggil Kelas Konksi Login
        Koneksi cn = new Koneksi();
        bool    hasil;

        hasil = cn.KelasKoneksi_Login(TxtUsername.Text, TxtPasswd.Text);
        if (Validate())
        {
            if (hasil)
            {
                Session["Member_ID"] = TxtUsername.Text;
                //ke tb userakses berdasarkan member id -- 1:menu master 2:menu pengguna
                string        sql_akses = "select id_akses from User_akses where Member_id = " + Convert.ToInt32(TxtUsername.Text) + "";
                List <string> akses     = cn.KelasKoneksi_SelectGlobal(sql_akses, "3");
                if (akses.Count == 0)
                {
                    Response.Write("<script language='javascript'>window.alert('Gagal Login! Hak Akses Anda tidak Di Temukan');window.location='../Login.aspx';</script>");
                }
                else
                {
                    if (akses[0].ToString() == "1")
                    {
                        Response.Write("<script language='javascript'>window.alert('Berhasil Login!');window.location='../Halaman/Master.aspx';</script>");
                    }
                    else
                    {
                        Response.Write("<script language='javascript'>window.alert('Berhasil Login!');window.location='../Halaman/Form_Pengguna.aspx';</script>");
                    }
                }
            }
            else
            {
                Response.Write("<script language='javascript'>window.alert('Gagal Login!');window.location='../Login.aspx';</script>");
            }
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Gagal menyimpan, Harap Centang Captcha !')", true);
        }
    }
    protected void BtnSimpanKeranjang_Click(object sender, EventArgs e)
    {
        //get chk keranjang belanja
        //get listview item chk
        foreach (ListViewDataItem item in ListViewHakAkses.Items)
        {
            CheckBox chkSelect = (CheckBox)item.FindControl("chkbar");
            if (chkSelect != null)
            {
                int ID = Convert.ToInt32(chkSelect.Attributes["value"]);
                if (chkSelect.Checked && !this.ID_bar.Contains(ID))
                {
                    this.ID_bar.Add(ID);
                }
                else if (!chkSelect.Checked && this.ID_bar.Contains(ID))
                {
                    this.ID_bar.Remove(ID);
                }
            }
        }

        //insert ke KeranjangBelanja
        foreach (int item in ID_bar)
        {
            Koneksi cn = new Koneksi();
            //get nama barang
            string        sqlnama    = "select nama_barang from stock where id_barang = " + item + "";
            List <string> namaBarang = cn.KelasKoneksi_SelectGlobal(sqlnama, "4");
            string        sqlupdt    = "insert into KeranjangBelanja values (" + memid + "," + item + ",'" + namaBarang[0].ToString() + "', " + Convert.ToInt32(TxtJumlah.Text) + ", GETDATE())";//insert ke KeranjangBelanja
            Hasil = cn.KelasKoneksi_CRUD(sqlupdt);
            if (Hasil == "1")
            {
                Response.Write("<script language='javascript'>window.alert('Berhasil Insert Data dengan ID :" + Convert.ToString(item) + "');window.location='../Halaman/Form_Pengguna.aspx';</script>");
            }
            else
            {
                Response.Write("<script language='javascript'>window.alert('Gagal Insert Data dengan ID : " + Convert.ToString(item) + "');window.location='../Halaman/Form_Pengguna.aspx';</script>");
            }
        }
    }