Esempio n. 1
0
        void deleteData(DataPesanan dp)
        {
            string    request = JsonConvert.SerializeObject(dp);
            WebClient client  = new WebClient();

            client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
            string result = client.UploadString(address.basuri + "deletedata", request);
        }
Esempio n. 2
0
        void addData(DataPesanan pesanan)
        {
            //serialization : dari objek ke string json
            string    request = JsonConvert.SerializeObject(pesanan);
            WebClient client  = new WebClient();

            client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
            string result = client.UploadString(address.basuri + "adddata", request);
        }
Esempio n. 3
0
        void getData(string inp)
        {
            DataPesanan pesanan = new DataPesanan();
            string      result  = new WebClient().DownloadString(address.basuri + "getdata/id=" + inp);

            pesanan      = JsonConvert.DeserializeObject <DataPesanan>(result);
            txt_psn.Text = pesanan.pesanan;
            txt_hrg.Text = pesanan.harga;
        }
Esempio n. 4
0
        private void del_btn_Click(object sender, EventArgs e)
        {
            int         id      = Convert.ToInt32(dgv.CurrentRow.Cells[0].Value);
            DataPesanan pesanan = new DataPesanan();

            pesanan.id = id;

            deleteData(pesanan);
            getDataAll();
        }
Esempio n. 5
0
        void getData(string inp)
        {
            DataPesanan pesanan = new DataPesanan();
            string      result  = new WebClient().DownloadString(address.basuri + "getdata/id=" + inp);

            pesanan = JsonConvert.DeserializeObject <DataPesanan>(result);
            List <DataPesanan> pesananList = new List <DataPesanan>();

            pesananList.Add(pesanan);
            dgv.DataSource = pesananList;
        }
Esempio n. 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            DataPesanan input = new DataPesanan();

            if (txt_psn.Text != "" && txt_hrg.Text != "")
            {
                try
                {
                    input.pesanan = txt_psn.Text;
                    input.harga   = txt_hrg.Text;
                    if (status == 1)
                    {
                        addData(input);
                        Program.Form.getDataAll();
                        this.Close();
                    }
                    else if (status == 2)
                    {
                        input.id = id;
                        updateData(input);
                        Program.Form.getDataAll();
                        this.Close();
                    }
                    else
                    {
                    }
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message);
                }
            }
            else
            {
                MessageBox.Show("Silahkan isi semua data terlebih dahulu");
            }
        }