Пример #1
0
 private void btnSend_Click(object sender, EventArgs e)
 {
     CoverObjectUtility.GetAutoBindingData(this, _mReq);
     _mReq.SetCreate();
     _mReq.Email = txtEmail.Text;
     try
     {
         using (IUnitOfWork uow = new UnitOfWork())
         {
             uow.RequestPaymentBaseRepository.Add(_mReq);
             uow.Commit();
         }
         InformationMailModel mail = new InformationMailModel();
         mail.Subject         = _mReq.Title;
         mail.SendersAddress  = "*****@*****.**";
         mail.SenderPassword  = "******";
         mail.Content         = _mReq.RequestContent;
         mail.ReceiverAddress = _mReq.Email;
         IMailHandler iMailHandler = new MailHandler();
         iMailHandler.SendMail(mail);
         if (AddRequestCode != null)
         {
             DebtDetail detail = new DebtDetail();
             detail.Payment            = 0;
             detail.PaymentDate        = null;
             detail.RequestPaymentCode = _mReq.RequestCode;
             AddRequestCode(detail, Utility.CRUD.Insert);
         }
         lblNotify.SetText(UI.success, ToolBoxCS.LabelNotify.EnumStatus.Success);
     }
     catch
     {
         lblNotify.SetText(UI.failed, ToolBoxCS.LabelNotify.EnumStatus.Failed);
     }
 }
Пример #2
0
 private void InitializeForm(DebtDetail detail)
 {
     //txtNote.Text = detail.Note;
     //txtThanhtien.Text = CurrencyUtility.DecimalToString(detail.Payment);
     //dtpPaymentDay.DateTime = detail.PaymentDate != null ? detail.PaymentDate.Value : DateTime.MinValue;
     //txtReqCode.Text = detail.RequestPaymentCode;
     //txtDetailId.Text = detail.DebtDetailId.ToString();
     CoverObjectUtility.SetAutoBindingData(this, detail);
 }
Пример #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,PaymentDate,CreditLimit,Balance,MinimumPayment,DebtCategoryId,CreditorCategoryId,Ignore")] DebtDetail debtDetail)
        {
            _userId           = GetCurrentUserId();
            debtDetail.UserId = _userId;
            ModelState.Clear();
            TryValidateModel(debtDetail);
            if (id != debtDetail.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                //Checks if the debt detail name has already been added by user
                var checksIfDetailExists = _context.DebtDetails.Include(c => c.DebtCategory).Include(c => c.CreditorCategory)
                                           .Where(s => s.Name == debtDetail.Name && s.DebtCategory.Id != debtDetail.DebtCategoryId ||
                                                  s.CreditorCategory.Id != debtDetail.CreditorCategoryId &&
                                                  s.UserId == _userId && s.Name.ToLower().Contains(debtDetail.Name.ToLower()));

                //var x = _context.DebtDetails.Where(s => s.Id == id && s.AvailableCredit == debtDetail.AvailableCredit);

                if (checksIfDetailExists.Count() > 0)
                {
                    //Error
                    StatusMessage = "Error : Account exists with " + checksIfDetailExists.First().CreditorCategory.Name + " . Please use another name.";
                }
                else
                {
                    try
                    {
                        _context.Update(debtDetail);
                        await _context.SaveChangesAsync();
                    }
                    catch (DbUpdateConcurrencyException)
                    {
                        if (!DebtDetailExists(debtDetail.Id))
                        {
                            return(NotFound());
                        }
                        else
                        {
                            throw;
                        }
                    }
                    return(RedirectToAction(nameof(Index)));
                }
            }
            ViewData["CreditorCategoryId"] = new SelectList(_context.CreditorCategories
                                                            .Where(c => c.UserId == _userId), "Id", "Name", debtDetail.CreditorCategoryId);
            ViewData["DebtCategoryId"] = new SelectList(_context.DebtCategories
                                                        .Where(c => c.UserId == _userId), "Id", "Name", debtDetail.DebtCategoryId);
            ViewBag.StatusMessage = StatusMessage;
            return(View(debtDetail));
        }
Пример #4
0
        private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            gridUtility.SetRowColor();
            int        i      = gridView1.GetSelectedRows().FirstOrDefault();
            DebtDetail detail = gridView1.GetRow(i) as DebtDetail;

            if (detail == null)
            {
                return;
            }
            InitializeForm(detail);
        }
Пример #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DebtDetail detail = new DebtDetail();

            if (!string.IsNullOrWhiteSpace(txtThanhtien.Text) || DateTime.Compare(dtpPaymentDay.DateTime, UtilityFunction.minDate) > 0)
            {
                detail.SetCreate();
                //detail.Payment = CurrencyUtility.ToDecimal(txtThanhtien.Text);
                //detail.PaymentDate = UtilityFunction.GetDatetime(dtpPaymentDay);
                //detail.RequestPaymentCode = txtReqCode.Text;
                //detail.Note = txtNote.Text;
                detail.DebtId = m_Debt.DebtId;
                CoverObjectUtility.GetAutoBindingData(this, detail);
                //detail.DebtDetailId = string.IsNullOrWhiteSpace(txtDetailId.Text)==false? Convert.ToInt32(txtDetailId.Text):0;
            }
            else
            {
                detail = null;
            }
            m_Debt.Bill = txtBill.Text;
            try
            {
                using (IUnitOfWork uow = new UnitOfWork())
                {
                    if (detail != null)
                    {
                        DebtDetail exist = uow.DebtDetailRepository.Find(detail.DebtDetailId);
                        if (exist == null)
                        {
                            uow.DebtDetailRepository.Add(detail);
                            gridUtility.AddNewRow <DebtDetail>(detail);
                        }
                        else
                        {
                            uow.DebtDetailRepository.Update(detail);
                            gridUtility.UpdateRow <DebtDetail>(detail);
                        }
                    }
                    uow.DebtRepository.Update(m_Debt);
                    uow.Commit();
                }
                m_Debt.TotalPayment += detail.Payment;
                if (UpdateRow != null)
                {
                    UpdateRow(m_Debt, CRUD.Update);
                }
                gridView1.RefreshData();
            }
            catch
            {
            }
        }
Пример #6
0
 private void AddOrUpdate(DebtDetail detail, CRUD flag)
 {
     if (flag == CRUD.Insert)
     {
         try
         {
             using (IUnitOfWork uow = new UnitOfWork())
             {
                 uow.DebtDetailRepository.Add(detail);
                 uow.Commit();
             }
             gridUtility.AddNewRow <DebtDetail>(detail);
         }
         catch
         { }
     }
 }
Пример #7
0
        public async Task <IActionResult> Create([Bind("Id,Name,PaymentDate,CreditLimit,Balance,MinimumPayment,DebtCategoryId,CreditorCategoryId,Ignore")] DebtDetail debtDetail)
        {
            _userId = GetCurrentUserId();

            debtDetail.UserId = _userId;
            ModelState.Clear();
            TryValidateModel(debtDetail);
            if (ModelState.IsValid)
            {
                //Checks if the debt type has already been added by user
                var checksIfdebtdetailExists = _context.DebtDetails.Include(c => c.DebtCategory).Include(c => c.CreditorCategory)
                                               .Where(s => s.Name == debtDetail.Name && s.DebtCategory.Id == debtDetail.DebtCategoryId &&
                                                      s.CreditorCategory.Id == debtDetail.CreditorCategoryId &&
                                                      s.UserId == _userId && s.Name.ToLower().Contains(debtDetail.Name.ToLower()));

                if (checksIfdebtdetailExists.Count() > 0)
                {
                    //Error
                    StatusMessage = "Error : Creditor exists under " + checksIfdebtdetailExists.First().DebtCategory.Name
                                    + " category. Please use another name.";
                }
                else
                {
                    ViewBag.Available = debtDetail.AvailableCredit;

                    _context.Add(debtDetail);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            ViewData["CreditorCategoryId"] = new SelectList(_context.CreditorCategories.Where(c => c.UserId == _userId), "Id", "Name");
            ViewData["DebtCategoryId"]     = new SelectList(_context.DebtCategories.Where(c => c.UserId == _userId), "Id", "Name");
            ViewBag.StatusMessage          = StatusMessage;
            return(View(debtDetail));
        }