예제 #1
0
        private void btn_save_Click(object sender, EventArgs e)
        {
            int      id          = int.Parse(tb_ID.Text);
            string   Hoten       = tb_fullname.Text;
            string   BietDanh    = tb_nickname.Text;
            DateTime?NgaySinh    = dt_birthday.Value;
            string   SoDienThoai = tb_phone.Text;
            string   Email       = tb_email.Text;
            string   DiaChi      = tb_address.Text;

            if (Hoten == null)
            {
                MessageBox.Show("Không được để trống", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            LienHe thongTin = new LienHe(id, Hoten, BietDanh, NgaySinh, SoDienThoai, Email, DiaChi);

            Update(thongTin);
        }
예제 #2
0
 private void Update(LienHe thongTin)
 {
     new Thread(() =>
     {
         var client           = new RestClient("http://danhbadienthoai.somee.com/api/danhba");
         client.Authenticator = new HttpBasicAuthenticator(username, password);
         var request          = new RestRequest(Method.PUT);
         var json             = JsonConvert.SerializeObject(thongTin);
         request.AddJsonBody(json, "Application/Json");
         var response = client.Put(request);
         if (response.StatusCode == HttpStatusCode.OK)
         {
             MessageBox.Show("Cập nhật thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             GetAllDanhBa();
         }
         else
         {
             MessageBox.Show("Cập nhật thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }).Start();
 }