protected override void SetRowFormat(DataGridViewRow row) { if (row.IsNewRow) { return; } if (!row.Displayed) { return; } ExpenseInfo item = (ExpenseInfo)row.DataBoundItem; if (!(new List <moleQule.Base.EEstado>() { moleQule.Base.EEstado.Anulado, moleQule.Base.EEstado.Contabilizado, moleQule.Base.EEstado.Exportado }).Contains(item.EEstado)) { Face.Common.ControlTools.Instance.SetRowColor(row, item.EEstadoPago); } else { Face.Common.ControlTools.Instance.SetRowColor(row, item.EEstado); } row.Cells[FechaPago.Index].Style = (item.FechaPago == DateTime.MinValue) ? Common.ControlTools.Instance.TransparentStyle : row.DefaultCellStyle; }
protected void LinkLineAction(DataGridViewRow row) { if (row == null) { return; } if (_entity.EMedioPago != EMedioPago.CompensacionFactura) { if (_no_asignado == 0) { UnlinkLineAction(row); return; } } ExpenseInfo item = row.DataBoundItem as ExpenseInfo; if (item == null) { return; } _entity.InsertNewTransactionPayment(item, _no_asignado); UpdateAllocated(); MarkAsNoActiva(row); }
private async Task notifyFinanceUser(NotifyType type, ExpenseInfo expense, int userId) { var financeUsers = await _userRepository.FindFinanceUser(); var user = await _userRepository.FindAsync(userId); var notifyBody = new NotifyBodyDto() { ExpenseModel = getFormattedExpense(expense), User = user, AbsoluteUrl = getAbsoluteUrl() }; INotifyBodyCreator bodyCreator = _notifyBodyCreatorAccessor(type); var message = bodyCreator.CreateBody(notifyBody); var subject = getNotifySubjectbyType(type); var notifyData = new NotifyDataDto() { To = financeUsers, Message = message, Subject = _localizer.Localize(subject) }; await notifyUser(notifyData); }
private void nextButton_Click(object sender, EventArgs e) { //expenseInfoGroupBox.Visible = false; //Expense Info GetOutletId(); GetEmployeeId(); expenseInfo = new ExpenseInfo(); expenseInfo.OutletId = outletId; expenseInfo.EmployeeId = employeeId; expenseInfo.ExpenseDate = expenseDateTimePicker.Value; db.ExpenseInfos.Add(expenseInfo); int info = db.SaveChanges(); if (info > 0) { MessageBox.Show("Info Saved!"); GetMaxExpenseInfoId(); // GetExpenseInfo(); expenseDetailsGroupBox.Enabled = true; } else { MessageBox.Show("Info Not saved!"); } }
public void GotoPagoAction() { if (ActiveItem.EEstado == moleQule.Base.EEstado.Anulado) { return; } if (ActiveItem.Total == 0) { return; } if (ActiveItem.OidPago == 0) { //Se obtiene el registro desde la DB para que actualice el pendiente de pago //en el caso de que se haya creado justo antes de esta acción Payment pago = Payment.New(ExpenseInfo.Get(ActiveItem.Oid, false), moleQule.Store.Structs.EnumConvert.ToETipoPago(ActiveItem.ECategoriaGasto)); ExpensePaymentAddForm form = new ExpensePaymentAddForm(pago, this); form.ShowDialog(this); if (form.ActionResult == DialogResult.OK) { ActiveItem.CopyFrom(form.Entity); } } else { ExpensePaymentEditForm form = new ExpensePaymentEditForm(ActiveItem.OidPago, moleQule.Store.Structs.EnumConvert.ToETipoPago(ActiveItem.ECategoriaGasto), this); form.ShowDialog(this); } }
protected override void MarkAsActiva(DataGridViewRow row) { ExpenseInfo item = row.DataBoundItem as ExpenseInfo; item.Vinculado = Library.Store.Resources.Labels.SET_PAGO; base.MarkAsActiva(row); }
public async Task DeleteExpense(ExpenseInfo expenseDetails) { if (db != null) { db.ExpenseInfo.Remove(expenseDetails); await db.SaveChangesAsync(); } }
public static ChargeExpense ToChargExpense(this ExpenseInfo expense) { return(new ChargeExpense { ExpenseId = expense.ExpenseId, From = expense.From, To = expense.To, Amount = expense.Amount, FormulaType = expense.ExpenseCategory.FormulaType }); }
public IActionResult AddExpense(IFormCollection formCollection) { //variables //liste de depenses List <subExpense> subExpenses = new List <subExpense>(); //liste de sous-depenses int count = 0; //pour aller chercher chaque element du formulaire double costTotal = 0; //pour le prix d'une depenses(addition de toute les sous-depenses d'une depense) //récupération de valeurs Project p = projectmanager.getProjet(Convert.ToInt32(formCollection["id"]));//va chercher le bon projet dans la BD List <ExpenseInfo> expenseInfos = new List <ExpenseInfo>(); int counter = 1; foreach (var expense in p.listProjectSoumission()) { ExpenseInfo ex = new ExpenseInfo(); FollowInfo[] follwlist = new JavaScriptSerializer().Deserialize <FollowInfo[]>(formCollection[counter.ToString()]); List <FollowInfo> subex = new List <FollowInfo>(); double total = 0; foreach (var item in follwlist) { total += item.amount; subex.Add(item); } ex.Spending = expense.Spending; ex.subExpenses = subex; ex.amount = total; expenseInfos.Add(ex); counter++; } Expense saveEx = new Expense(); saveEx.ExpenseDate = DateTime.Now; saveEx.JsonExpenseInfo = JsonConvert.SerializeObject(expenseInfos); ProjectExpense projectExpense = new ProjectExpense(); projectExpense.PeExpenseId = Convert.ToInt32(formCollection["id"]); _context.Add(saveEx); _context.SaveChanges(); projectExpense.PeExpenseId = saveEx.ExpenseId; projectExpense.PeProject = p; projectExpense.PeExpense = saveEx; _context.ProjectExpense.Add(projectExpense); _context.SaveChanges(); return(RedirectToAction("Projet", new { id = formCollection["id"] })); }
public static Expenses GetDailyExpenseData(DateTime a_dateTime) { Expenses expenses = new Expenses(); ExpenseInfo l_expenseInfo = m_yearlyExpenseInfo.expenseInfo[a_dateTime.Month - 1]; expenses.Bazaar = l_expenseInfo.Bazaar[a_dateTime.Day - 1]; expenses.Shopping = l_expenseInfo.Shopping[a_dateTime.Day - 1]; expenses.Office = l_expenseInfo.Office[a_dateTime.Day - 1]; expenses.Other = l_expenseInfo.Others[a_dateTime.Day - 1]; return(expenses); }
public Task UpdateAsync(ExpenseInfo entity) { var sql = $"UPDATE {_tblName} SET State = @state, Description = @description, StateDescription = @stateDescription " + $"WHERE Id = @id"; DynamicParameters parameter = new DynamicParameters(); parameter.Add("@state", entity.State, DbType.String, ParameterDirection.Input); parameter.Add("@id", entity.Id, DbType.Int32, ParameterDirection.Input); parameter.Add("@description", entity.Description, DbType.String, ParameterDirection.Input); parameter.Add("@stateDescription", entity.StateDescription, DbType.String, ParameterDirection.Input); return(ExecuteScalarAsync <ExpenseInfo>(sql, parameter)); }
public static ExpenseDto ToDto(this ExpenseInfo expense) { return(new ExpenseDto { Title = expense.Title, ExpenseCategoryId = expense.ExpenseCategoryId, ExpenseId = expense.ExpenseId, From = expense.From, To = expense.To, Amount = expense.Amount, ExpenseCategoryName = expense.ExpenseCategory.ExpenseCategoryName }); }
protected override void SetGastosFormat() { foreach (DataGridViewRow row in Expenses_DGW.Rows) { ExpenseInfo item = row.DataBoundItem as ExpenseInfo; if (item == null) { continue; } row.ReadOnly = (item.OidFactura != 0); row.Cells["FechaFacturaOtroGasto"].Style.ForeColor = (item.OidFactura == 0) ? Color.Transparent : row.Cells["TotalOtroGasto"].Style.ForeColor; row.Cells["TipoAcreedorOtroGasto"].Style.ForeColor = (item.OidFactura == 0) ? Color.Transparent : row.Cells["TotalOtroGasto"].Style.ForeColor; } }
protected void UnlinkLineAction(DataGridViewRow row) { if (row == null) { return; } ExpenseInfo item = row.DataBoundItem as ExpenseInfo; _entity.DeleteTransactionPayment(item); UpdateAllocated(); MarkAsActiva(row); }
private ExpenseDto getFormattedExpense(ExpenseInfo item) { var expenseDto = new ExpenseDto() { Description = item.Description, FileName = item.FileName, Id = item.Id, Link = $"/account/viewexpensefile/{item.Id}", State = item.State, StateDescription = item.StateDescription, UploadDate = item.UploadDate.ToString("MM/dd/yyy HH:mm:ss") }; return(expenseDto); }
public Task <int> AddAsyncById(ExpenseInfo entity) { var sql = $"INSERT INTO {_tblName} (Path, FileName, OwnerId, State, Description, StateDescription, UploadDate)" + $" VALUES (@path, @filename, @ownerid, @state, @description, @stateDescription, @uploadDate) SELECT CAST(SCOPE_IDENTITY() as int) "; DynamicParameters parameter = new DynamicParameters(); parameter.Add("@path", entity.Path, DbType.String, ParameterDirection.Input); parameter.Add("@filename", entity.FileName, DbType.String, ParameterDirection.Input); parameter.Add("@ownerid", entity.OwnerId, DbType.Int32, ParameterDirection.Input); parameter.Add("@state", entity.State, DbType.String, ParameterDirection.Input); parameter.Add("@description", entity.Description, DbType.String, ParameterDirection.Input); parameter.Add("@stateDescription", entity.StateDescription, DbType.String, ParameterDirection.Input); parameter.Add("@uploadDate", DateTime.Now, DbType.DateTime, ParameterDirection.Input); return(ExecuteScalarAsync <int>(sql, parameter)); }
protected override void EditLineAllocationAction(DataGridViewRow row) { InputDecimalForm form = new InputDecimalForm(); form.Message = Resources.Labels.IMPORTE_PAGO_GASTO; if (form.ShowDialog(this) == DialogResult.OK) { ExpenseInfo item = row.DataBoundItem as ExpenseInfo; _no_asignado += item.Asignado; _entity.EditTransactionPayment(item, form.Value); LinkLineAction(row); SetUnlinkedGridValues(Lineas_DGW.Name); Expenses_BS.ResetBindings(false); SetGridColors(Lineas_DGW); } }
/// <summary> /// This will return 30/31 days array of total expense of all day /// </summary> /// <param name="a_monthInYear">A month in year. This value is ranged from 1-12.</param> public static int[] LoadTotalExpense_InAMonth(int a_monthInYear) { Debug.Log("Total length is: " + m_yearlyExpenseInfo.expenseInfo.Count + ". and asking for: " + a_monthInYear); ExpenseInfo l_expenseInfo = m_yearlyExpenseInfo.expenseInfo[a_monthInYear - 1]; int a_MaxDayDataAvailable = l_expenseInfo.Bazaar.Count; int[] a_totalExpenseAllDays = new int[31]; Debug.Log("maxDataAvailable: " + a_MaxDayDataAvailable); for (int count = 0; count < 31; count++) { if (count < a_MaxDayDataAvailable) { if (l_expenseInfo.Bazaar.Count > count) { a_totalExpenseAllDays[count] += l_expenseInfo.Bazaar[count]; } if (l_expenseInfo.Office.Count > count) { a_totalExpenseAllDays[count] += l_expenseInfo.Office[count]; } if (l_expenseInfo.Shopping.Count > count) { a_totalExpenseAllDays[count] += l_expenseInfo.Shopping[count]; } if (l_expenseInfo.Others.Count > count) { a_totalExpenseAllDays[count] += TotalOtherInfo(l_expenseInfo.Others[count]); } } else { a_totalExpenseAllDays[count] = 0; } } return(a_totalExpenseAllDays); }
private async Task <ExpenseInfo> addExpense(ExpenseUploadDto model) { var filePath = _fileService.GetNewExpenseFilePath(); using (var stream = new FileStream(filePath, FileMode.Create)) { await model.ExpensePhoto.CopyToAsync(stream); } var expense = new ExpenseInfo() { FileName = model.ExpensePhoto.FileName, OwnerId = model.UserId, Path = filePath, State = ExpenseState.UnApproved.ToString(), UploadDate = DateTime.Now, Description = model.Description }; expense.Id = await _expenseInfoRepository.AddAsyncById(expense); return(expense); }
protected override void GetFormSourceData(object[] parameters) { if (parameters[0] == null) { _entity = Payment.New((ETipoPago)parameters[1]); _entity.BeginEdit(); _entity.Oid = -1; } else { _entity = (Payment)parameters[0]; _entity.BeginEdit(); _entity.Oid = -1; } _gastos = ExpenseList.GetPendientesList(moleQule.Store.Structs.EnumConvert.ToECategoriaGasto(_entity.ETipoPago), _entity.GetInfo(false), false); //Asociamos los gastos previamente vinculados foreach (TransactionPayment item in _entity.Operations) { ExpenseInfo gasto = _gastos.GetItem(item.OidOperation); gasto.Vincula(); } }
private string SaveDailyInfo() { if (!_hasUnsavedChanges) { return("No changes to save."); } DailyInfo daily = new DailyInfo(); daily.Note = NoteTextBox.ForeColor == Color.Black ? NoteTextBox.Text : "No note"; daily.Day = _selectedDay; daily.Month = _selectedMonth; daily.Year = _selectedYear; daily.TotalEarning = Convert.ToDouble(TotalEarningLabel.Text); daily.TotalExpense = Convert.ToDouble(TotalExpenseLabel.Text); string source; string reason; string category; string comment; double amount; foreach (DataGridViewRow row in ExpenseDataGridView.Rows) { if (IsLastEmptyRow(ExpenseDataGridView, row.Index)) { break; } try { reason = ExpenseDataGridView.Rows[row.Index].Cells[0].Value.ToString(); reason = FilterString(reason); } catch { reason = ""; } try { if (!double.TryParse(ExpenseDataGridView.Rows[row.Index].Cells[1].Value.ToString(), out amount)) { string message = "The value for amount is not correct on row"; message += (row.Index + 1) + " in the expense table. Please correct" + " the amount in order to save."; MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return("Invalid value entered"); } } catch (NullReferenceException) { string message; message = "Looks like you forgot to enter amount on row "; message += (row.Index + 1) + " in the expense table. "; message += "Do you want to save without changing the amount?"; DialogResult dlgResult = MessageBox.Show(message, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dlgResult == DialogResult.Yes) { amount = 0; } else { return("Terminated by user"); } } try { category = ExpenseDataGridView.Rows[row.Index].Cells[2].Value.ToString(); category = FilterString(category); } catch { category = "Other"; } try { comment = ExpenseDataGridView.Rows[row.Index].Cells[3].Value.ToString(); comment = FilterString(comment); } catch { comment = ""; } ExpenseInfo expense = new ExpenseInfo { Reason = reason, Amount = amount, Category = category, Comment = comment }; daily.ExpenseList.Add(expense); } foreach (DataGridViewRow row in EarningDataGridView.Rows) { if (IsLastEmptyRow(EarningDataGridView, row.Index)) { break; } try { source = EarningDataGridView.Rows[row.Index].Cells[0].Value.ToString(); source = FilterString(source); } catch { source = ""; } try { if (!double.TryParse(EarningDataGridView.Rows[row.Index].Cells[1].Value.ToString(), out amount)) { string message = "The value for amount is not correct on row" + (row.Index + 1) + " in the earning table. Please correct the amount in order to save."; MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return("Invalid value entered"); } } catch (NullReferenceException) { string message = "Looks like you forgot to enter amount on row " + (row.Index + 1) + " in the earning table. Do you want to save without changing the amount?"; DialogResult dlgResult = MessageBox.Show(message, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dlgResult == DialogResult.Yes) { amount = 0; } else { return("Terminated by user"); } } try { category = EarningDataGridView.Rows[row.Index].Cells[2].Value.ToString(); category = FilterString(category); } catch { category = "Other"; } try { comment = EarningDataGridView.Rows[row.Index].Cells[3].Value.ToString(); comment = FilterString(comment); } catch { comment = ""; } EarningInfo earning = new EarningInfo { Source = source, Amount = amount, Category = category, Comment = comment, }; daily.EarningList.Add(earning); } string result = WebHandler.SaveDailyInfo(daily); if (result == "SUCCESS") { //if any info on the same date already exists, overwrite that info //otherwise, add this info as new info int index = GlobalSpace.DailyInfoList.FindIndex( d => d.Day == daily.Day && d.Month == daily.Month && d.Year == daily.Year); if (index != -1) { GlobalSpace.DailyInfoList[index] = daily; } else { GlobalSpace.DailyInfoList.Add(daily); } //monthly info should change accordingly since daily info has been modified MonthlyInfo.Fetch(); //MessageBox.Show("The data has been successfully saved!", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information); _hasUnsavedChanges = false; } return(result); }
protected void UpdateExpense(ExpenseInfo item, OrderedDictionary e) { if (item != null) { item.ExpenseDate = ((ASPxDateEdit)grid.FindEditFormTemplateControl("dteExpenseDate")).Date; item.ExpenseUser = e["ExpenseUser"] as String; item.ProjectID = e["ProjectID"] as String; item.AccountID = e["AccountID"] as String; try { item.Amount = Convert.ToDouble(((ASPxSpinEdit)grid.FindEditFormTemplateControl("txtAmount")).Value); } catch { } try { item.Quantity = Convert.ToInt32(((ASPxSpinEdit)grid.FindEditFormTemplateControl("txtQuantity")).Value); } catch { } try { item.UnitCost = Convert.ToDouble(((ASPxSpinEdit)grid.FindEditFormTemplateControl("txtUnitCost")).Value); } catch { } try { item.Mileage = Convert.ToDouble(((ASPxSpinEdit)grid.FindEditFormTemplateControl("txtMileage")).Value); } catch { } item.BillToClient = ((CheckBox)grid.FindEditFormTemplateControl("chkBillClient")).Checked; item.ExpenseType = e["ExpenseType"] as String; item.Currency = e["Currency"] as String; item.EmployeeCurrency = e["EmployeeCurrency"] as String; item.Description = e["Description"] as String; item.Reimbursed = Convert.ToBoolean(e["Reimbursed"]); if(e["ReimbursedDate"] != null) item.ReimbursedDate = Convert.ToDateTime(e["ReimbursedDate"]); item = expenseService.UpdateExpense(item, true); //This method direct updates in-memory collection and used only for mocking purposes MockUpdate(item); } }
protected void MockUpdate(ExpenseInfo item) { var updatedExpenses = Expenses; int index = 0; if (!grid.IsNewRowEditing) { var updatedRow = updatedExpenses.Where(r => r.ID == item.ID); index = updatedExpenses.IndexOf(updatedRow.First()); updatedExpenses.RemoveAt(index); updatedExpenses.Insert(index, item); } else { updatedExpenses.Add(item); } Expenses = updatedExpenses; }
protected void grid_RowInserting(object sender, ASPxDataInsertingEventArgs e) { ExpenseInfo item = new ExpenseInfo(); UpdateExpense(item, e.NewValues); e.Cancel = true; grid.CancelEdit(); }
private void ActionUponFetchDailyInfoSuccess() { string result = _webHandlerObject.Response; string[] rows = result.Split('^'); if (rows[0] == "Server connection error") { //some server error occurred _progressViewerObject.StopProgress(); ShowErrorMessage("Server connection error. Please check your internet connection."); return; } //start fetching categories from database on a seperate thread //before starting to process the fetched daily info FetchCategories(); if (rows[0] == "") { //no daily info found for this user in database //so no need to process the info return; } //process the fetched daily info and store them in StaticStorage class foreach (string row in rows) { string[] cols = row.Split('|'); int day = Convert.ToInt16(cols[0]); int month = Convert.ToInt16(cols[1]); int year = Convert.ToInt16(cols[2]); string note = StringCipher.Decrypt(cols[3], GlobalSpace.CypherKey); string[] expenseReasons = StringCipher.Decrypt(cols[4], GlobalSpace.CypherKey).Split('~'); string[] expenseAmounts = StringCipher.Decrypt(cols[5], GlobalSpace.CypherKey).Split('~'); string[] expenseCategories = StringCipher.Decrypt(cols[6], GlobalSpace.CypherKey).Split('~'); string[] expenseComments = StringCipher.Decrypt(cols[7], GlobalSpace.CypherKey).Split('~'); string[] earningSources = StringCipher.Decrypt(cols[8], GlobalSpace.CypherKey).Split('~'); string[] earningAmounts = StringCipher.Decrypt(cols[9], GlobalSpace.CypherKey).Split('~'); string[] earningCategories = StringCipher.Decrypt(cols[10], GlobalSpace.CypherKey).Split('~'); string[] earningComments = StringCipher.Decrypt(cols[11], GlobalSpace.CypherKey).Split('~'); string totalExpense = StringCipher.Decrypt(cols[12], GlobalSpace.CypherKey); string totalEarning = StringCipher.Decrypt(cols[13], GlobalSpace.CypherKey); DailyInfo daily = new DailyInfo { Day = day, Month = month, Year = year, Note = note, TotalEarning = Convert.ToDouble(totalEarning), TotalExpense = Convert.ToDouble(totalExpense) }; if (expenseAmounts[0] != "") { for (int i = 0; i < expenseReasons.Length; i++) { double amount = Convert.ToDouble(expenseAmounts[i]); string reason = expenseReasons[i]; string category = expenseCategories[i]; string comment = expenseComments[i]; ExpenseInfo expense = new ExpenseInfo { Reason = reason, Amount = amount, Category = category, Comment = comment }; daily.ExpenseList.Add(expense); } } if (earningAmounts[0] != "") { for (int i = 0; i < earningSources.Length; i++) { double amount = Convert.ToDouble(earningAmounts[i]); string source = earningSources[i]; string category = earningCategories[i]; string comment = earningComments[i]; EarningInfo earning = new EarningInfo { Source = source, Amount = amount, Category = category, Comment = comment }; daily.EarningList.Add(earning); } } GlobalSpace.DailyInfoList.Add(daily); } }
protected override void GetFormSourceData(long oid, object[] parameters) { _entity = ExpenseInfo.Get(oid, true); }
public IActionResult Addprojet(IFormCollection formCollection) { ProjectFollowUp projectFollowUp = new ProjectFollowUp(); ProjectExpense projectExpense = new ProjectExpense(); Project p = new Project(); p.ProjectName = formCollection["ProjectName"]; p.ProjectDebut = Convert.ToDateTime(formCollection["project_debut"]); p.ProjectFin = Convert.ToDateTime(formCollection["project-fin"]); //TOFIX: La sérialisation JSON Échoue s'il y a plus qu'un mot dans le champ "Spending" //I know on va juste empecher avec des espaces FollowInfo[] follwlist = new JavaScriptSerializer().Deserialize <FollowInfo[]>(formCollection["table"]); List <FollowInfo> soumission = new List <FollowInfo>(); foreach (var item in follwlist) { soumission.Add(item); } FollowUp follow = new FollowUp(); follow.FuDate = DateTime.Now; follow.FuInfo = JsonConvert.SerializeObject(soumission); List <ExpenseInfo> expenseInfo = new List <ExpenseInfo>(); foreach (var item in soumission) { ExpenseInfo expenses = new ExpenseInfo(); List <FollowInfo> subex = new List <FollowInfo>(); FollowInfo ex = new FollowInfo(); expenses.Spending = item.Spending; expenses.amount = 0; ex.Spending = "Title"; ex.amount = 0; subex.Add(ex); expenses.subExpenses = subex; expenseInfo.Add(expenses); } Expense expense = new Expense(); expense.ExpenseDate = DateTime.Now; expense.JsonExpenseInfo = JsonConvert.SerializeObject(expenseInfo); _context.Add(follow); _context.Add(expense); _context.SaveChanges(); projectFollowUp.PfFollowUpId = follow.FuId; projectFollowUp.PfProject = p; projectExpense.PeExpenseId = expense.ExpenseId; projectExpense.PeProject = p; p.ProjectSoumission = JsonConvert.SerializeObject(soumission); Users user = new Users(); user = usermanager.FindUserByID(formCollection["Users"]); projectmanager.addProjet(p); projectFollowUp.PfFollowUp = follow; projectExpense.PeExpense = expense; _context.ProjectFollowUp.Add(projectFollowUp); _context.ProjectExpense.Add(projectExpense); _context.SaveChanges(); return(RedirectToAction("Index")); }
public Task AddAsync(ExpenseInfo entity) { throw new NotImplementedException(); }
/// <summary> /// Change display of the form according to the type of expense being entered. /// </summary> private void SetVisibilityForExpenseType(string mode) { bool updFlag = false; bool fixedxost = false; Amount.ReadOnly = false; bool QuantityType = false; //if (BillToClient.Checked) DoUpdate = true; if (ProjectID.LookupResultValue != "" && AccountID.LookupResultValue != null && ExpenseUser.LookupResultValue != null) { if (ExpenseType.SelectedValue != null) { #region Fetching the Values from DLL (Using PicklistExt and ExpenseDataService) IExpenseDataService expService = ServiceLocator.Instance.GetExpenseDataService(); Sage.SalesLogix.PickLists.PickList er = Sage.SalesLogix.PickLists.PickList.GetPickListItemByName("TLX Expense Type", ExpenseType.Text.ToString().Trim()); PicklistExt pklext = null; pklext = expService.GetPicklistExt(er.ItemId.ToString(), ProjectID.LookupResultValue.ToString()); double expenserate = 0.00; double mileage = 0.00; expenserate = expService.FindExpenseRate(AccountID.LookupResultValue.ToString(), ProjectID.LookupResultValue.ToString(), ProjectTaskID.LookupResultValue.ToString(), ExpenseUser.LookupResultValue.ToString(), ExpenseType.Text, ExpenseData.HalfDayPerDiem); //ITLXAccount objTLXAccount = Sage.Platform.EntityFactory.GetByCompositeId<ITLXAccount>(new string[] { "Accountid" }, new object[] { AccountID.LookupResultValue.ToString() }); IAccount objAccount = Sage.Platform.EntityFactory.GetById<IAccount>(AccountID.LookupResultValue.ToString()); if (objAccount.TLXAccount != null) { if (objAccount.TLXAccount.Roundtripmileage > 0) mileage = Convert.ToDouble(objAccount.TLXAccount.Roundtripmileage); else mileage = expService.FindMileage(AccountID.LookupResultValue.ToString()); } else mileage = expService.FindMileage(AccountID.LookupResultValue.ToString()); #endregion #region Default Visiblity panMileage.Visible = false; panUnits.Visible = false; HalfDayPerDiem.Visible = ExpenseData.ExpenseType == "Per Diem"; InvoiceAmount.Visible = false; lblInvoiceAmount.Visible = false; #endregion #region Setting Visiblity based on Expense Type switch (ExpenseData.ExpenseType) { case "Mileage": panMileage.Visible = true; panUnits.Visible = false; if (ExpenseData == null || string.IsNullOrEmpty(ExpenseData.ID)) { if (getdefaultMileage) { if (DoUpdate) { updFlag = true; Mileage.Visible = true; MileageRate.Visible = true; Label11.Visible = true; Mileage.Text = mileage.ToString(); MileageRate.Text = expenserate.ToString(); Amount.Text = (mileage * expenserate).ToString(); } else updFlag = false; } else { if (!DoUpdate) { updFlag = true; Mileage.Visible = true; MileageRate.Visible = true; Label11.Visible = true; Mileage.Text = ExpenseData.Mileage.ToString(); MileageRate.Text = ExpenseData.MileageRate.ToString(); Amount.Text = (Convert.ToDouble(ExpenseData.Mileage) * Convert.ToDouble(ExpenseData.MileageRate)).ToString(); } else updFlag = false; } } break; case "Per Diem": panMileage.Visible = false; panUnits.Visible = false; if (HalfDayPerDiem.Checked) if (!DoUpdate) { Amount.Text = expenserate.ToString(); updFlag = true; } else updFlag = false; else if (!DoUpdate) { Amount.Text = ExpenseData.Amount.ToString(); updFlag = true; } else updFlag = false; string expUserId = ""; if (ExpenseUser.LookupResultValue != null) { expUserId = Convert.ToString(((Sage.Entity.Interfaces.ITLXUserinfo)ExpenseUser.LookupResultValue).Id); } ExpenseDisplayRules displayRules = new ExpenseDisplayRules(); TimeLinx.Core.Services.IExpenseDataService ExpenseDataService = TimeLinx.Core.Services.ServiceLocator.Instance.GetExpenseDataService(); ExpenseInfo expenseInfo = new ExpenseInfo(); expenseInfo.AccountID = AccountID.LookupResultValue.ToString(); expenseInfo.ProjectID = ProjectID.LookupResultValue.ToString(); expenseInfo.TaskID = ProjectTaskID.LookupResultValue.ToString(); expenseInfo.ExpenseType = ExpenseType.Text; expenseInfo.ExpenseTypeItemID = er.ItemId.ToString(); expenseInfo.ExpenseUser = expUserId; displayRules = ExpenseDataService.GetExpenseDisplayRules(expenseInfo); if (displayRules.AmountEditable) Amount.ReadOnly = false; else Amount.ReadOnly = true; break; default: Amount.ReadOnly = false; if (pklext.QUANTITYTYPE) { panUnits.Visible = true; Label12.Visible = true; UnitCost.Visible = true; Quantity.Visible = true; Amount.ReadOnly = true; QuantityType = true; panMileage.Visible = false; if (TimeLinx.SlxContext.Instance.License.LicenseType == "Premier" || TimeLinx.SlxContext.Instance.License.LicenseType == "Enterprise") { //if (String.IsNullOrEmpty(UnitCost.Text)) //{ if (DoUpdate) { UnitCost.Text = pklext.QUANTITYCOSTPER.ToString(); Amount.Text = Convert.ToDouble(Convert.ToDouble(UnitCost.Text) * Convert.ToDouble(Quantity.Text)).ToString(); updFlag = true; } else updFlag = false; //} } } if (pklext.FIXEDCOST > 0) { if (QuantityType) return; if (Amount.Text != "0.00") { if (ExpenseData == null || string.IsNullOrEmpty(ExpenseData.ID)) { if (ExpenseData.Amount == 0.0 || DoUpdate) { Amount.Text = pklext.FIXEDCOST.ToString(); InvoiceAmount.Text = pklext.FIXEDREVENUE.ToString(); updFlag = true; if (!BillToClient.Checked) InvoiceAmount.Text = "0"; } } else { if (!DoUpdate) { Amount.Text = Convert.ToString(ExpenseData.Amount); if (BillToClient.Checked) { if (ExpenseData.InvoiceAmount == pklext.FIXEDREVENUE) { InvoiceAmount.Text = pklext.FIXEDREVENUE.ToString(); } else InvoiceAmount.Text = Convert.ToString(ExpenseData.InvoiceAmount); } else InvoiceAmount.Text = "0";//now updFlag = true; } else { Amount.Text = pklext.FIXEDCOST.ToString(); InvoiceAmount.Text = pklext.FIXEDREVENUE.ToString(); if (!BillToClient.Checked) InvoiceAmount.Text = "0"; updFlag = false; } } } else pklext.FIXEDCOST = Convert.ToDouble(Amount.Text); fixedxost = true; } if (pklext.FIXEDREVENUE > 0 && pklext.EXPENSEMARKUP > 0) { panUnits.Visible = true; Label12.Visible = false; UnitCost.Visible = false; Quantity.Visible = false; if (pklext.ALLOWPMCHANGE == true && pklext.CanEditCostRevenue == true) { InvoiceAmount.Visible = true; lblInvoiceAmount.Visible = true; } else { lblInvoiceAmount.Visible = false; lblInvoiceAmount.Visible = false; } if (QuantityType) return; if (fixedxost) return; if (ExpenseData == null || string.IsNullOrEmpty(ExpenseData.ID)) { if (BillToClient.Checked) { if (DoUpdate) { Amount.Text = Convert.ToString(ExpenseData.Amount); //now InvoiceAmount.Text = pklext.FIXEDREVENUE.ToString(); //now updFlag = true; } else { updFlag = false; } // throw new Exception(InvoiceAmount.Text + "Invoice Amount"); } else InvoiceAmount.Text = "0.00"; } else { if (BillToClient.Checked) { if (!DoUpdate) { InvoiceAmount.Text = Convert.ToString(ExpenseData.InvoiceAmount); updFlag = true; } else { updFlag = false; } } else InvoiceAmount.Text = "0.00"; } ITLXProject ProjectObj = EntityFactory.GetById<ITLXProject>(ProjectID.LookupResultValue); ITLXAccount AccountObj = EntityFactory.GetById<ITLXAccount>(AccountID.LookupResultValue); if (ProjectObj != null) { if (ProjectObj.DoNotBillExpense == true) { InvoiceAmount.Text = "0.00"; } } } else { if (String.IsNullOrEmpty(InvoiceAmount.Text)) InvoiceAmount.Text = pklext.FIXEDREVENUE.ToString(); InvoiceAmount.Visible = false; lblInvoiceAmount.Visible = false; } break; } #endregion //Reset DoUpdate Flag if (updFlag) DoUpdate = true; else DoUpdate = false; //To Handle the Multicurrency (TimeLinx) HandleMultiCurrency(); if (!String.IsNullOrEmpty(InvoiceAmount.Text)) ExpenseData.InvoiceAmount = Convert.ToDouble(InvoiceAmount.Text); } } else { //To Handle the Visibility of Controls is none of the record is selected and rmb Add is selected. switch (ExpenseData.ExpenseType) { case "Mileage": panMileage.Visible = true; Mileage.Visible = true; MileageRate.Visible = true; Label11.Visible = true; panUnits.Visible = false; break; case "Per Diem": panMileage.Visible = false; panUnits.Visible = false; Mileage.Visible = false; MileageRate.Visible = false; Label11.Visible = false; break; default: panUnits.Visible = false; InvoiceAmount.Visible = false; lblInvoiceAmount.Visible = false; HalfDayPerDiem.Visible = false; Mileage.Visible = false; MileageRate.Visible = false; Label11.Visible = false; break; } //ExpenseData.InvoiceAmount = Convert.ToDouble(InvoiceAmount.Text); } }
public Task UpdateExpense(ExpenseInfo expenseInfo) { throw new NotImplementedException(); }