Ejemplo n.º 1
0
        protected void tambah(object sender, EventArgs e)
        {
            int value;

            if (nama.Text != "")
            {
                Koneksi insert = new Koneksi();
                if (jumlah.Text == "")
                {
                    if (insert.newItem(nama.Text))
                    {
                        Response.Write("<script>alert('Berhasil')</script>");
                        this.message = "berhasi";
                    }
                    else
                    {
                        Response.Write("<script>alert('Terjadi Masalah, silahkan hubungi Dev')</script>");
                        this.message = "gagal";
                    }
                }
                else if (int.TryParse(jumlah.Text, out value))
                {
                    if (insert.newItem(nama.Text))
                    {
                        if (insert.AddQuantity(Int32.Parse(jumlah.Text), Convert.ToString(Session["id"])))
                        {
                            Response.Write("<script>alert('Berhasil')</script>");
                            this.message = "berhasil";
                        }
                        else
                        {
                            Response.Write("<script>alert('Terjadi Masalah, silahkan hubungi Dev')</script>");
                            this.message = "gagal";
                        }
                    }
                    else
                    {
                        Response.Write("<script>alert('Terjadi Masalah, silahkan hubungi Dev')</script>");
                        this.message = "gagal";
                    }
                }
                else
                {
                    Response.Write("<script>alert('Terjadi Masalah, silahkan hubungi Dev')</script>");
                    this.message = "gagal";
                }
            }
            else if (nama.Text == "")
            {
                Response.Write("<script>alert('isi dahulu form')</script>");
            }
        }
Ejemplo n.º 2
0
        protected void tambah(object sender, EventArgs e)
        {
            int value;

            if (barang.SelectedItem.Value != "" && (Tipe.SelectedItem.Value == "1" || Tipe.SelectedItem.Value == "0") && jumlah.Text != "" && int.TryParse(jumlah.Text, out value))
            {
                if (k.AddQuantity(Int32.Parse(jumlah.Text), Convert.ToString(Session["id"]), Int16.Parse(barang.SelectedItem.Value), Int16.Parse(Tipe.SelectedItem.Value)))
                {
                    Response.Write("<script>alert('berhasil')</script>");
                }
                else
                {
                    Response.Write("<script>alert('gagal,terjadi masalah')</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('isi form dengan benar')</script>");
            }

            //barang.SelectedItem.Value
        }