Exemple #1
0
 public VoucherViewModel()
 {
     Voucher = new VoucherBE();
     Donors = new List<DonorBE>();
     GiftTypes = new List<GiftTypeView>();
     Vouchers = new List<VoucherBE>();
     Names = new List<string>(){
     "Imran"
     ,"Irfan"
     ,"Jameel"
     ,"Ali"
     ,"Adil"
     };
 }
        public VoucherViewModel ModifyVoucher(VoucherBE mod)
        {
            VoucherViewModel model = new VoucherViewModel();

            try
            {
                DBOperations op = mod.IsActive ? DBOperations.Update : DBOperations.Delete;
                mod.SiteCode = AppConstants.SITE_CODE;
                model.Voucher = mod;
                model.IsValid = model.Validate();
                if (op == DBOperations.Delete || model.IsValid)
                {
                    //_bdmSvc.ModifyEntity(mod);
                    _alKhairSvc.ModifyVoucher(mod);

                    model.FieldId = "VoucherName";
                    model.Voucher = new VoucherBE();
                    model.Vouchers = _alKhairSvc.GetViewOfAllVouchers(AppConstants.SITE_CODE);
                    model.Message = op == DBOperations.Update ? string.Format(AppConstants.CRUD_UPDATE, "Voucher Name") : string.Format(AppConstants.CRUD_DELETE, "Voucher Name");
                }
            }
            catch (Exception ex)
            {
                model.IsValid = false;
                model.Message = ex.Message;
                if (ex.Message.Contains("Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=472540 for information on understanding and handling optimistic concurrency exceptions."))
                    model.Message = "Unable to modify Region Code";
            }
            return model;
        }
        public bool ModifyVoucher(VoucherBE mod)
        {
            bool retVal = true;
            try
            {
                _vchRepo.Update(mod);
                _uow.Commit();
            }
            catch (Exception ex)
            {
                retVal = false;
            }

            return retVal;
        }
 public VoucherBE GetVoucherById(string siteCode, int id)
 {
     VoucherBE retVal = new VoucherBE();
     try
     {
         _vchRepo.GetById(siteCode, id);
     }
     catch (Exception ex)
     {
         retVal = null;
     }
     return retVal;
 }
        public int AddVoucher(VoucherBE mod)
        {
            try
            {
                VoucherNoBE vchNo = _vchNoRepo.GetById(mod.UserName);
                if (vchNo != null)
                {
                    vchNo.VoucherNo = mod.VchNo;
                    _vchNoRepo.Update(vchNo);
                }
                else
                {
                    vchNo = new VoucherNoBE();
                    vchNo.VoucherNo = mod.VchNo;
                    vchNo.UserName = mod.UserName;
                    _vchNoRepo.Insert(vchNo);
                }

                _vchRepo.Insert(mod);
                _uow.Commit();
            }
            catch (Exception ex)
            {
                mod.ID = -1;
            }
            return mod.ID;
        }
Exemple #6
0
        public void CRUD_Voucher()
        {
            #region Commented Code

            //    public string VchNo { get; set; }
            //public int GiftTypeId { get; set; }
            //public int ReceivedFrom { get; set; }
            //public string VchTypeCode { get; set; }
            //public int VchMonth { get; set; }
            //public int VchYear { get; set; }
            //public string VchKeyId { get; set; }
            //public DateTime VchDate { get; set; }
            //public decimal VchAmount { get; set; }
            //public string PaymentMode { get; set; }
            //public string ChequeNo { get; set; }
            //public DateTime ChequeDate { get; set; }
            //public int BankId { get; set; }
            #endregion

            VoucherBE mod = new VoucherBE();
            //mod.SiteCode = "QST";
            //mod.VchNo = "1234";
            //mod.GiftTypeId = 10;
            //mod.ReceivedFrom = 39;
            //mod.VchAmount = 3999;
            //mod.PaymentMode = "Cash";

            //int vchId = _alKhairSvc.AddVoucher(mod);

            var list = _alKhairSvc.GetAllVouchers("QST");//.GetViewOfAllVouchers("QST");
            if (list != null && list.Count > 0)
            {
                mod = list[0];
                //mod.VchNo = " ...";
                mod.VchAmount = 39949;

                if (_alKhairSvc.ModifyVoucher(mod))
                {

                }
                //p = _bdmSvc.GetPersonById(pv.SiteCode, pv.EntityTypeCode, pv.ID);
            }
        }