예제 #1
0
        public async Task <bool> upateNhomThuNhap(NHOMTHUNHAP nhomThuNhap)
        {
            try
            {
                await _connectionToDatabaseAsync.UpdateAsync(nhomThuNhap);

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        public async Task <NHOMTHUNHAP> getNhomThuNhap(int maNhomThuNhap)
        {
            try
            {
                NHOMTHUNHAP nhomCongViec = await _connectionToDatabaseAsync.Table <NHOMTHUNHAP>().Where(ncv =>
                                                                                                        (ncv.MaNhomThuNhap == maNhomThuNhap)).FirstOrDefaultAsync();

                return(nhomCongViec);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
 public bool insertThuNhap(THUNHAP thuNhap)
 {
     try
     {
         _connectionToDatabase.RunInTransaction(
             () =>
         {
             NHOMTHUNHAP nhomThuNhap = _connectionToDatabase.Table <NHOMTHUNHAP>().Where(ie =>
                                                                                         (ie.MaNhomThuNhap == thuNhap.MaNhomThuNhap)).FirstOrDefault();
             if (nhomThuNhap == null)
             {
                 throw new Exception("Không tìm nhóm thu nhập này.");
             }
             THUCHITHANG thuChiThang = _connectionToDatabase.Table <THUCHITHANG>().Where(ie =>
                                                                                         (ie.MaThuChiThang == thuNhap.MaThuChiThang)).FirstOrDefault();
             if (thuChiThang == null)
             {
                 throw new Exception("Không tìm thấy thu-chi tháng với mã '" + thuNhap.MaThuChiThang + "'");
             }
             THUNHAP currentThuNhap = _connectionToDatabase.Table <THUNHAP>().Where(tn =>
                                                                                    (tn.MaThuNhap == thuNhap.MaThuNhap)).FirstOrDefault();
             if (currentThuNhap != null)
             {
                 throw new Exception("Thu nhập với mã này đã tồn tại.");
             }
             _connectionToDatabase.Insert(thuNhap);
             thuChiThang.SoDu += (Int32)thuNhap.SoTien;
             _connectionToDatabase.Update(thuChiThang);
         });
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        private async Task<bool> asyncDataNhomThuNhap()
        {
            try
            {
                var respone = await _serverModel.getAllNhomThuNhapAsync();
                ObservableCollection<ServerDatabaseService.NhomThuNhap> listNhomThuNhap = respone.Body.getAllNhomThuNhapResult;

                foreach (ServerDatabaseService.NhomThuNhap nhom in listNhomThuNhap)
                {
                    NHOMTHUNHAP nhomThuNhap = await _localModel.getNhomThuNhap(nhom.MaNhomThuNhap);
                    if (nhomThuNhap == null)        // add new
                    {
                        nhomThuNhap = new NHOMTHUNHAP(nhom.MaNhomThuNhap, nhom.TieuDe, nhom.MoTa);
                        await _localModel.insertNhomThuNhap(nhomThuNhap);
                    }
                    else        // update
                    {
                        nhomThuNhap.TieuDe = nhom.TieuDe;
                        nhomThuNhap.MoTa = nhom.MoTa;
                        await _localModel.upateNhomThuNhap(nhomThuNhap);
                    }
                }
                return true;
            }
            catch (EndpointNotFoundException e)
            {
                throw new HttpRequestException("Không thể kết nối đến server. Vui lòng kiểm tra kết nối internet và thử lại.");
            }
            catch (HttpRequestException e)
            {
                throw new HttpRequestException("Không thể kết nối đến server. Vui lòng kiểm tra kết nối internet và thử lại.");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #5
0
 public async Task<bool> upateNhomThuNhap(NHOMTHUNHAP nhomThuNhap)
 {
     try
     {
         await _connectionToDatabaseAsync.UpdateAsync(nhomThuNhap);
         return true;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        private async Task<bool> asyncDataNhomThuNhap()
        {
            try
            {
                var respone = await _serverModel.getAllNhomThuNhapAsync();
                ObservableCollection<ServerDatabaseService.NhomThuNhap> listNhomThuNhap = respone.Body.getAllNhomThuNhapResult;

                foreach (ServerDatabaseService.NhomThuNhap nhom in listNhomThuNhap)
                {
                    NHOMTHUNHAP nhomThuNhap = await _localModel.getNhomThuNhap(nhom.MaNhomThuNhap);
                    if (nhomThuNhap == null)        // add new
                    {
                        nhomThuNhap = new NHOMTHUNHAP(nhom.MaNhomThuNhap, nhom.TieuDe, nhom.MoTa);
                        await _localModel.insertNhomThuNhap(nhomThuNhap);
                    }
                    else        // update
                    {
                        nhomThuNhap.TieuDe = nhom.TieuDe;
                        nhomThuNhap.MoTa = nhom.MoTa;
                        await _localModel.upateNhomThuNhap(nhomThuNhap);
                    }
                }
                return true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }