Esempio n. 1
0
        public async Task <bool> upateNhomChiTieu(NHOMCHITIEU nhomChiTieu)
        {
            try
            {
                await _connectionToDatabaseAsync.UpdateAsync(nhomChiTieu);

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        public async Task <NHOMCHITIEU> getNhomChiTieu(int maNhomChiTieu)
        {
            try
            {
                NHOMCHITIEU nhomCongViec = await _connectionToDatabaseAsync.Table <NHOMCHITIEU>().Where(ncv =>
                                                                                                        (ncv.MaNhomChiTieu == maNhomChiTieu)).FirstOrDefaultAsync();

                return(nhomCongViec);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
 public bool insertChiTieu(CHITIEU chiTieu)
 {
     try
     {
         _connectionToDatabase.RunInTransaction(
             () =>
         {
             NHOMCHITIEU nhomChiTieu = _connectionToDatabase.Table <NHOMCHITIEU>().Where(ie =>
                                                                                         (ie.MaNhomChiTieu == chiTieu.MaNhomChiTieu)).FirstOrDefault();
             if (nhomChiTieu == null)
             {
                 throw new Exception("Không tìm nhóm chi tiêu này.");
             }
             THUCHITHANG thuChiThang = _connectionToDatabase.Table <THUCHITHANG>().Where(ie =>
                                                                                         (ie.MaThuChiThang == chiTieu.MaThuChiThang)).FirstOrDefault();
             if (thuChiThang == null)
             {
                 throw new Exception("Không tìm thấy thu-chi tháng với mã '" + chiTieu.MaThuChiThang + "'");
             }
             CHITIEU currentChiTieu = _connectionToDatabase.Table <CHITIEU>().Where(ct =>
                                                                                    (ct.MaChiTieu == chiTieu.MaChiTieu)).FirstOrDefault();
             if (currentChiTieu != null)
             {
                 throw new Exception("Chi tiêu với mã tương ứng đã tồn tại.");
             }
             _connectionToDatabase.Insert(chiTieu);
             thuChiThang.SoDu -= (Int32)chiTieu.SoTien;
             _connectionToDatabase.Update(thuChiThang);
         });
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        private async Task<bool> asyncDataNhomChiTieu()
        {
            try
            {
                var respone = await _serverModel.getAllNhomChiTieuAsync();
                ObservableCollection<ServerDatabaseService.NhomChiTieu> listNhomChiTieu = respone.Body.getAllNhomChiTieuResult;

                foreach (ServerDatabaseService.NhomChiTieu nhom in listNhomChiTieu)
                {
                    NHOMCHITIEU nhomChiTieu = await _localModel.getNhomChiTieu(nhom.MaNhomChiTieu);
                    if (nhomChiTieu == null)        // add new
                    {
                        nhomChiTieu = new NHOMCHITIEU(nhom.MaNhomChiTieu, nhom.TieuDe, nhom.MoTa);
                        await _localModel.insertNhomChiTieu(nhomChiTieu);
                    }
                    else        // update
                    {
                        nhomChiTieu.TieuDe = nhom.TieuDe;
                        nhomChiTieu.MoTa = nhom.MoTa;
                        await _localModel.upateNhomChiTieu(nhomChiTieu);
                    }
                }
                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;
            }
        }
Esempio n. 5
0
 public async Task<bool> upateNhomChiTieu(NHOMCHITIEU nhomChiTieu)
 {
     try
     {
         await _connectionToDatabaseAsync.UpdateAsync(nhomChiTieu);
         return true;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        private async Task<bool> asyncDataNhomChiTieu()
        {
            try
            {
                var respone = await _serverModel.getAllNhomChiTieuAsync();
                ObservableCollection<ServerDatabaseService.NhomChiTieu> listNhomChiTieu = respone.Body.getAllNhomChiTieuResult;

                foreach (ServerDatabaseService.NhomChiTieu nhom in listNhomChiTieu)
                {
                    NHOMCHITIEU nhomChiTieu = await _localModel.getNhomChiTieu(nhom.MaNhomChiTieu);
                    if (nhomChiTieu == null)        // add new
                    {
                        nhomChiTieu = new NHOMCHITIEU(nhom.MaNhomChiTieu, nhom.TieuDe, nhom.MoTa);
                        await _localModel.insertNhomChiTieu(nhomChiTieu);
                    }
                    else        // update
                    {
                        nhomChiTieu.TieuDe = nhom.TieuDe;
                        nhomChiTieu.MoTa = nhom.MoTa;
                        await _localModel.upateNhomChiTieu(nhomChiTieu);
                    }
                }
                return true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }