示例#1
0
        public async Task <IHttpActionResult> Delete(string id)
        {
            var     result   = new TransferObj <bool>();
            CHUNGTU instance = await _service.Repository.FindAsync(id);

            if (instance == null)
            {
                return(NotFound());
            }
            try
            {
                var refund = _service.DeleteChungTu(instance.ID);
                int del    = await _service.UnitOfWork.SaveAsync();

                if (del > 1)
                {
                    result.Data    = true;
                    result.Status  = true;
                    result.Message = "Xóa thành công bản ghi";
                }
                else
                {
                    result.Data    = false;
                    result.Status  = false;
                    result.Message = "Thao tác không thành công";
                }
            }
            catch (Exception e)
            {
                result.Data    = false;
                result.Status  = false;
                result.Message = e.Message;
            }
            return(Ok(result));
        }
示例#2
0
            public List <IQueryFilter> GetFilters()
            {
                var result = new List <IQueryFilter>();
                var refObj = new CHUNGTU();

                if (!string.IsNullOrEmpty(this.MA_CHUNGTU))
                {
                    result.Add(new QueryFilterLinQ
                    {
                        Property = ClassHelper.GetProperty(() => refObj.MA_CHUNGTU),
                        Value    = this.MA_CHUNGTU,
                        Method   = FilterMethod.Like
                    });
                }
                return(result);
            }
示例#3
0
        public async Task <IHttpActionResult> PostApproval(NhapMuaViewModel.ParamApproval instance)
        {
            var    result        = new TransferObj();
            string unitCode      = _service.GetCurrentUnitCode();
            string connectString = ConfigurationManager.ConnectionStrings["ERBusConnection"].ConnectionString;
            //chưa khóa sổ
            List <KyKeToanViewModel.ViewModel> listChuaKhoa = _service.KyKeToanChuaKhoa(unitCode, connectString);

            if (listChuaKhoa != null && listChuaKhoa.Count > 0)
            {
                result.Status  = false;
                result.Data    = listChuaKhoa;
                result.Message = "HAVENOT_CLOSINGOUT_PERIOD";
            }
            else
            {
                if (!string.IsNullOrEmpty(instance.ID))
                {
                    CHUNGTU chungTu = _service.FindById(instance.ID);
                    if (chungTu == null || chungTu.TRANGTHAI == (int)TypeState.APPROVAL)
                    {
                        result.Status  = false;
                        result.Data    = "ISAPROVAL";
                        result.Message = "Không thể duyệt! Phiếu này đã được duyệt rồi";
                    }
                    else
                    {
                        if (_service.Approval(chungTu.ID, connectString, chungTu, unitCode) != null)
                        {
                            //tính lại giá hàng hóa
                            int appro = await _service.UnitOfWork.SaveAsync();

                            if (appro > 0)
                            {
                                if (_service.UpdateMatHangThayDoiGia(instance.ID, unitCode, connectString) > 0)
                                {
                                    result.Data    = chungTu;
                                    result.Status  = true;
                                    result.Message = "Duyệt phiếu [" + chungTu.MA_CHUNGTU + "] thành công ! Cập nhật giá";
                                }
                                else
                                {
                                    result.Data    = chungTu;
                                    result.Status  = true;
                                    result.Message = "Duyệt phiếu [" + chungTu.MA_CHUNGTU + "] thành công ! Lỗi cập nhật giá";
                                }
                            }
                            else
                            {
                                result.Data    = null;
                                result.Status  = false;
                                result.Message = "Duyệt không thành công";
                            }
                        }
                        else
                        {
                            result.Data    = null;
                            result.Status  = false;
                            result.Message = "Duyệt không thành công";
                        }
                    }
                }
                else
                {
                    result.Data    = null;
                    result.Status  = false;
                    result.Message = "ID không tìm thấy";
                }
            }
            return(Ok(result));
        }