private async void btnLuu_Click(object sender, EventArgs e) { ResponseData result = null; if (currentKho != null) // Add new { currentKho.Ma = txtMaKho.Text; currentKho.Ten = txtTenKho.Text; currentKho.DiaChi = txtDiaChi.Text; currentKho.GhiChu = txtGhiChu.Text; currentKho.SDT = txtSDT.Text; currentKho.QuanLy = new NhanVien() { Id = (int)cboQuanLy.SelectedValue }; result = await KhoService.ThemMoiKho(currentKho); } else // Update { currentKho = new Kho(); currentKho.Ma = txtMaKho.Text; currentKho.Ten = txtTenKho.Text; currentKho.DiaChi = txtDiaChi.Text; currentKho.GhiChu = txtGhiChu.Text; currentKho.SDT = txtSDT.Text; currentKho.QuanLy = new NhanVien() { Id = (int)cboQuanLy.SelectedValue }; currentKho.Id = int.Parse(txtIdKho.Text); result = await KhoService.CapNhatKho(currentKho); } if (result.Status == Config.CODE_OK) { MessageBoxEx.Show(result.Message, "Thông báo"); ClearLayout(); LoadKho(); } else if (result != null) { MessageBoxEx.Show(result.Message, "Thông báo"); } else { MessageBoxEx.Show("Opps!!!", "Thông báo"); } currentKho = null; }