Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] IncomeType incomeType)
        {
            if (id != incomeType.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(incomeType);
                    await _context.SaveChangesAsync();

                    TempData["confirmation"] = "Income type " + incomeType.Name + " was successfully updated!";
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!IncomeTypeExists(incomeType.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(incomeType));
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(long id, [Bind("Id,Name,Status")] IncomeType incomeType)
        {
            if (id != incomeType.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(incomeType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!IncomeTypeExists(incomeType.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(incomeType));
        }
Beispiel #3
0
        private void ExecueDeleteDetail()
        {
            MessageBoxResult result = MessageBox.Show("Are you sure to delete " + CurrentContributionDetail.MemberName, "Delete", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (result == MessageBoxResult.Yes)
            {
                if (CurrentContributionDetail != null)
                {
                    using (var unitOfWork = new UnitOfWork(new MahalluDBContext())) {
                        ContributionDetail contributionDetail = unitOfWork.ContributionDetails.Get(CurrentContributionDetail.Id);
                        if (contributionDetail != null)
                        {
                            unitOfWork.ContributionDetails.Remove(contributionDetail);
                            unitOfWork.Complete();

                            decimal amount = CurrentContributionDetail.Amount;
                            ContributionDetailList.Remove(CurrentContributionDetail);
                            CurrentContributionDetail = null;

                            //To update total amount
                            CurrentContribution.ToatalAmount = Convert.ToDecimal(TotalAmount) - amount;
                            TotalAmount = (Convert.ToDecimal(TotalAmount) - amount).ToString();
                            unitOfWork.Contributions.Update(CurrentContribution);
                            unitOfWork.Complete();
                            IncomeType incomeType = new IncomeType()
                            {
                                Contribution = CurrentContribution
                            };
                            eventAggregator.GetEvent <PubSubEvent <IncomeType> >().Publish(incomeType);
                        }
                    }
                }
            }
        }
Beispiel #4
0
        private async void OnAddIncomeType()
        {
            try
            {
                string name = await DialogService.Prompt("Add income type", "Introduce the name of the new income type", StringConstants.Ok, "cancel", "Name");

                if (!string.IsNullOrWhiteSpace(name))
                {
                    if (await DatabaseService.GetIncomeTypeByName(name) == null)
                    {
                        IncomeType newIncomeType = await DatabaseService.InsertIncomeType(name);

                        if (newIncomeType != null)
                        {
                            await DialogService.DisplayAlert("Add income type", $"{newIncomeType.Name} add as an income type", StringConstants.Ok);
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                        await DialogService.DisplayAlert(StringConstants.Error, $"There's already an income type with the name: {name}", StringConstants.Ok);
                    }
                }
            }
            catch (Exception ex)
            {
                await DialogService.DisplayAlert(StringConstants.Error, $"There was an error trying to insert the income type. {StringConstants.Error}: {ex.Message}", StringConstants.Ok);
            }
        }
Beispiel #5
0
        private void ExecuteDeleteContribution()
        {
            MessageBoxResult result = MessageBox.Show("Deleting Contribution will delete all of the details also, \nAre you sure to delete", "Delete", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (result == MessageBoxResult.Yes)
            {
                if (CurrentContribution != null)
                {
                    using (var unitofWork = new UnitOfWork(new MahalluDBContext())) {
                        MahalluManager.Model.Contribution contribution = unitofWork.Contributions.Get(CurrentContribution.Id);
                        unitofWork.Contributions.Remove(contribution);
                        unitofWork.Complete();

                        IncomeType incomeType = new IncomeType()
                        {
                            Contribution = CurrentContribution, Operation = MahalluManager.Model.Common.Operation.Delete
                        };
                        eventAggregator.GetEvent <PubSubEvent <IncomeType> >().Publish(incomeType);

                        ContributionList.Remove(CurrentContribution);
                        CurrentContribution = null;
                    }
                }
            }
        }
Beispiel #6
0
        public async void Initialize()
        {
            if (!_initialized)
            {
                string dbPath = Path.Combine(FileSystem.AppDataDirectory, /*"InGasDB"*/ "testsDB");
                _connection = new SQLiteAsyncConnection(dbPath);

                await _connection.CreateTableAsync <IncomeType>();

                await _connection.CreateTableAsync <ExpenseType>();

                await _connection.CreateTableAsync <Income>();

                await _connection.CreateTableAsync <Expense>();

                IncomeType defaultIncomeType = new IncomeType {
                    Name = "Others"
                };
                ExpenseType defaultExpenseType = new ExpenseType {
                    Name = "Others"
                };

                if (await _connection.Table <IncomeType>().FirstOrDefaultAsync(incomeType => incomeType.Name == defaultIncomeType.Name) == null)
                {
                    await _connection.InsertAsync(defaultIncomeType);
                }

                if (await _connection.Table <ExpenseType>().FirstOrDefaultAsync(expenseType => expenseType.Name == defaultExpenseType.Name) == null)
                {
                    await _connection.InsertAsync(defaultExpenseType);
                }

                _initialized = true;
            }
        }
        /// <summary>
        /// Fill method for populating an entire collection of IncomeTypes
        /// </summary>
        public virtual void Fill(IncomeTypes incomeTypes)
        {
            // create the connection to use
            SqlConnection cnn = new SqlConnection(IncomeType.GetConnectionString());


            try
            {
                using (cnn)
                {
                    // open the connection
                    cnn.Open();


                    // create an instance of the reader to fill.
                    SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectIncomeTypes");


                    // Send the collection and data to the object factory
                    CreateObjectsFromData(incomeTypes, datareader);


                    // close the connection
                    cnn.Close();
                }


                // nullify the connection
                cnn = null;
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }
        }
        private void LoadType()
        {
            int        id    = Convert.ToInt32(Request.QueryString["id"]);
            IncomeType model = IncomeTypeManager.GetModel(id);

            txtTypeName.Text = model.TypeName;
        }
Beispiel #9
0
 public Employment(IncomeType incomeType, DateTime startDate, DateTime nextPayDate, string occupation)
 {
     IncomeType  = incomeType;
     StartDate   = startDate;
     NextPayDate = nextPayDate;
     Occupation  = occupation;
 }
        public ActionResult EditIncomeType([FromBody] IncomeType[] incomeTypes)
        {
            if (_context.IncomeType.Where(i => i.Defenition == incomeTypes[0].Defenition).Count() > 0)
            {
                return(Json("Bu mədaxil növü mövcuddur"));
            }
            string result = "Sistem xətası";

            try
            {
                IncomeType incomeType = new IncomeType();
                incomeType.Id         = incomeTypes[0].Id;
                incomeType.Defenition = incomeTypes[0].Defenition;

                _context.Update(incomeType);
                _context.SaveChanges();
                result = "Əməliyyat uğurla tamamlandı!";
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }


            return(Json(result));
        }
Beispiel #11
0
        public void AddIncomeTax(decimal incomeTax, IncomeType incomeType)
        {
            _taxPerIncomeType[incomeType] = _taxPerIncomeType[incomeType] + incomeTax;

            _incomeTax += incomeTax;
            _totalTax  += incomeTax;
        }
        public JsonResult SaveDataInDatabase(IncomeType model)
        {
            var result = false;

            try
            {
                if (model.Id > 0)
                {
                    _context.Update(model);
                    _context.SaveChanges();
                    result = true;
                }
                else
                {
                    _context.Add(model);
                    _context.SaveChanges();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Json(result));
        }
        /// <summary>
        /// The object factory for a particular data collection instance.
        /// </summary>
        public virtual void CreateObjectsFromData(IncomeTypes incometypes, System.Data.DataSet data)
        {
            // Do nothing if we have nothing
            if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
            {
                return;
            }


            // Create a local variable for the new instance.
            IncomeType newobj = null;

            // Create a local variable for the data row instance.
            System.Data.DataRow dr = null;


            // Iterate through the table rows
            for (int i = 0; i < data.Tables[0].Rows.Count; i++)
            {
                // Get a reference to the data row
                dr = data.Tables[0].Rows[i];
                // Create a new object instance
                newobj = System.Activator.CreateInstance(incometypes.ContainsType[0]) as IncomeType;
                // Let the instance set its own members
                newobj.SetMembers(ref dr);
                // Add the new object to the collection instance
                incometypes.Add(newobj);
            }
        }
        /// <summary>
        /// Saves the income type information.
        /// </summary>
        /// <param name="incomeTypeView">The income type view.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentException">AdminSaveIncomeType</exception>
        public string SaveIncomeTypeInfo(IIncomeTypeListView incomeTypeView)
        {
            var result = string.Empty;

            if (incomeTypeView == null)
            {
                throw new ArgumentException("AdminSaveIncomeType");
            }

            var newRecord = new IncomeType
            {
                IncomeTypeName = incomeTypeView.IncomeTypeName,
                WHT_Rate       = "10",
                IsActive       = true,
            };

            try
            {
                using (
                    var dbContext = (PitalyticsEntities)this.dbContextFactory.GetDbContext())
                {
                    dbContext.IncomeTypes.Add(newRecord);
                    dbContext.SaveChanges();
                }
            }
            catch (Exception e)
            {
                result = string.Format("SaveIncomeType - {0} , {1}", e.Message,
                                       e.InnerException != null ? e.InnerException.Message : "");
            }

            return(result);
        }
Beispiel #15
0
        public async Task <IncomeItemModel> Topup(TopupAccountModel topup)
        {
            var account = await _repository.LoadAsync <Account>(topup.AccountId).ConfigureAwait(false);

            var incomeTypeId = topup.IncomeTypeId;

            if (incomeTypeId == null)
            {
                var incomeType = new IncomeType
                {
                    Name    = topup.AddIncomeTypeName,
                    OwnerId = _currentSession.UserId
                };
                _repository.Create(incomeType);
                await _repository.SaveChangesAsync().ConfigureAwait(false);

                incomeTypeId = incomeType.Id;
            }

            var income = new IncomeItemModel
            {
                AccountId    = account.Id,
                DateTime     = topup.TopupDate,
                IncomeTypeId = incomeTypeId.Value,
                Total        = topup.Amount,
                IsCorrection = topup.Correction,
            };

            await _incomeItemCommands.Update(income).ConfigureAwait(false);

            await _repository.SaveChangesAsync().ConfigureAwait(false);

            return(income);
        }
Beispiel #16
0
        public IncomeType CreateIncomeType(IncomeTypeRequest IncomeType)
        {
            var entity = new IncomeType();

            this.MergeIncomeType(entity, IncomeType);
            this.IncomeTypeRepository.Insert(entity);
            return(entity);
        }
Beispiel #17
0
        public void GiveIncomeFor(IncomeType incomeType, float multiplier = 1f)
        {
            Income income = GetIncome(incomeType);

            income.Give(multiplier);

            m_incomes.Remove(incomeType);
        }
Beispiel #18
0
 public IncomeDetailView(IncomeType type, List <StructEarn> tem, int temyear, int temmonth)
 {
     InitializeComponent();
     incomeType = type;
     earns      = tem;
     year       = temyear;
     month      = temmonth;
     InitUI();
 }
Beispiel #19
0
        void CheckOperation(IncomeType incomeType)
        {
            lblRouteList.Visible             = yEntryRouteList.Visible
                                             = incomeType == IncomeType.DriverReport;

            if (incomeType == IncomeType.DriverReport)
            {
                Entity.IncomeCategory = UoW.GetById <IncomeCategory>(1);
            }
        }
 public ActionResult Edit([Bind(Include = "IncomeTypeID,Description")] IncomeType incomeType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(incomeType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("IncomeType"));
     }
     return(View(incomeType));
 }
 public Upgrade(IScheme scheme, IncomeType type)
 {
     if (scheme == null)
     {
         Console.WriteLine("WTF??");
     }
     _scheme    = scheme;
     IncomeType = type;
     Price      = _scheme.StartPrice;
 }
Beispiel #22
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (hid.Value == "Update")
                {
                    IncomeType exp = null; bool rst = false;
                    exp = LookUpBLL.GetIncomeType(Convert.ToInt32(txtID.Text));
                    if (exp != null)
                    {
                        exp.Name = txtDept.Text.ToUpper();
                        rst      = LookUpBLL.UpdateIncomeType(exp);
                        if (rst != false)
                        {
                            BindGrid();
                            success.Visible   = true;
                            success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>&times;</button> Record updated successfully!!.";
                            return;
                        }
                    }

                    else
                    {
                        error.Visible   = true;
                        error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>&times;</button>Record could Not updated. Kindly try again. If error persist contact Administrator!!.";
                    }
                }
                else
                {
                    bool       result = false;
                    IncomeType exp    = new IncomeType();
                    exp.Name = txtDept.Text.ToUpper();
                    result   = LookUpBLL.AddIncomeType(exp);
                    if (result)
                    {
                        BindGrid();
                        txtDept.Text      = "";
                        success.Visible   = true;
                        success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>&times;</button> Record added successfully!!.";
                        return;
                    }
                    else
                    {
                        error.Visible   = true;
                        error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>&times;</button>Record could Not added. Kindly try again. If error persist contact Administrator!!.";
                    }
                }
            }
            catch (Exception ex)
            {
                error.Visible   = true;
                error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> An error occurred. kindly try again!!!";
                Utility.WriteError("Error: " + ex.Message);
            }
        }
Beispiel #23
0
        public async Task <IActionResult> Create([Bind("Id,Name,Status")] IncomeType incomeType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(incomeType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(incomeType));
        }
        public ActionResult Create(CreateEditViewModel model)
        {
            var incomeType = new IncomeType();

            Mapper.DynamicMap(model, incomeType);
            incomeTypeProvider.AddIncomeType(incomeType);

            var jsonViewModel = new AjaxViewModel(true, model, null);

            return(Json(jsonViewModel));
        }
        public ActionResult Create([Bind(Include = "IncomeTypeID,Description")] IncomeType incomeType)
        {
            if (ModelState.IsValid)
            {
                db.IncomeTypes.Add(incomeType);
                db.SaveChanges();
                return(RedirectToAction("IncomeType"));
            }

            return(View(incomeType));
        }
Beispiel #26
0
        public async Task <IActionResult> Create(IncomeType expenseType)
        {
            if (ModelState.IsValid)
            {
                TempData["confirm"] = "Tipo de receita " + expenseType.Name + " cadastrado com sucesso.";
                await _incomeTypeService.InsertAsync(expenseType);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(expenseType));
        }
Beispiel #27
0
        public IncomeType CreateIncomeType(string name)
        {
            var commands = _unitOfWork.GetCommandRepository <IncomeType>();
            var entity   = new IncomeType
            {
                Name    = name,
                OwnerId = UserSession.UserId
            };

            commands.Create(entity);
            return(entity);
        }
Beispiel #28
0
        public async Task <IActionResult> Create([Bind("Id,Name")] IncomeType incomeType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(incomeType);
                await _context.SaveChangesAsync();

                TempData["confirmation"] = "Income type " + incomeType.Name + " was successfully created!";
                return(RedirectToAction(nameof(Index)));
            }
            return(View(incomeType));
        }
Beispiel #29
0
        public static bool Add(IncomeType type)
        {
            string sql = "insert into IncomeType(typename) values (@typename)";

            SqlParameter[] sp = new SqlParameter[]
            {
                new SqlParameter("@typename", type.TypeName)
            };
            int result = DBHelper.ExecuteCommand(sql, sp);

            return(result > 0);
        }
Beispiel #30
0
 internal Income(IncomeType incomeType, decimal value, DateTime incomeDate, int incomeMonth, string from, string details1, string details2, Guid?sourceId)
 {
     IncomeId    = Guid.NewGuid();
     IncomeType  = incomeType;
     Value       = value;
     IncomeDate  = incomeDate;
     IncomeMonth = incomeMonth;
     From        = from;
     Details1    = details1;
     Details2    = details2;
     SourceId    = sourceId;
 }