private void UpdateAmount(CRE exps) { if (exps != null) { textBoxAmount.Text = textBoxAmount.Text.Replace('.', ','); if (_rexFloat.IsMatch(textBoxAmount.Text)) { try { exps.Amount = float.Parse(textBoxAmount.Text); } catch (FormatException fexp) { Console.WriteLine(fexp.Message); } catch (Exception exp) { Console.WriteLine(exp.Message); } } else { textBoxAmount.Text = exps.Amount.ToString(); } } }
private void LaunchCurrencyModif() { _currentActivity.CurrencyProject = CRE.GetCurrency(_tsm.Currencies.SelectedItem.Text); _currentActivity.Balance(); RefreshPanel(); SheetDisplayRequested?.Invoke(null); }
public ExpsDelete(InterfaceFinance intfnc, CRE exps) { _intFnc = intfnc; _currentMovement = new CRE(); InitializeComponent(); LoadMovementList(); Display(exps); }
public ExpsDelete(InterfaceFinance intfnc) { _intFnc = intfnc; _currentMovement = new CRE(); InitializeComponent(); LoadMovementList(); comboBoxListMovements.SelectedItem = comboBoxListMovements.Items[0]; }
private void Display(CRE exps) { labelNameValue.Text = exps.Name; labelGopValue.Text = exps.StrGop; comboBoxListMovements.Text = exps.StrGop + " " + exps.Name; _currentMovement = exps; }
private void buttonValidateMovement_Click(object sender, EventArgs e) { SaveExpense(checkBoxNewMovement.Checked); if (checkBoxNewMovement.Checked) { _expsCurrent = _expsNew; } this.Close(); }
private bool SearchAmount(CRE exps, string s) { Regex r = new Regex(@"^[0-9]*(?:\,[0-9]*)?$"); if (r.IsMatch(s)) { exps._amount = double.Parse(s); return(true); } return(false); }
private bool SearchDate(CRE exps, string s) { DateTime dt; if (DateTime.TryParse(s, out dt)) { exps._startDate = dt; exps._startDate = dt.AddDays(1); return(true); } return(false); }
private void LaunchImport() { using (OpenFileDialog ofd = new OpenFileDialog()) { if (ofd.ShowDialog() == DialogResult.OK) { CRE.ImportExps(ofd.FileName, this); _viewWelcome.RefreshData(); } } SheetDisplayRequested?.Invoke(null); }
private bool SearchGop(CRE exps) { foreach (string gopList in _gopExample) { string[] tab = gopList.Split('|'); if (tab.Length > 1 && tab[1].Contains(exps.Name.ToLower())) { exps.StrGop = tab[0]; return(true); } } return(false); }
public ExpsEdit(InterfaceFinance intFnc, string picPath) { _intFnc = intFnc; InitializeComponent(); checkBoxNewMovement.Checked = true; textBoxBillPath.Text = picPath; _expsNew = new CRE(); LoadPrj(null); _expsCurrent = _expsNew; if (!string.IsNullOrEmpty(picPath)) { LoadPicture(); } this.comboBoxMovement.SelectedValueChanged += new System.EventHandler(this.comboBoxMovement_SelectionChanged); }
public ExpsDelete(InterfaceFinance intfnc, int?expsId) { _intFnc = intfnc; _currentMovement = new CRE(); InitializeComponent(); LoadMovementList(); if (expsId != null) { Display(expsId); } else { return; } }
private void LoadPrj(int?expsId) { comboBoxCurrency.Items.Add("AUD"); comboBoxCurrency.Items.Add("EUR"); comboBoxCurrency.Items.Add("GBP"); comboBoxCurrency.Items.Add("JPY"); comboBoxCurrency.Items.Add("INR"); comboBoxCurrency.Items.Add("USD"); comboBoxCurrency.Items.Add("XXX"); comboBoxWho.Items.Clear(); comboBoxParticipantList.Items.Clear(); comboBoxMovement.Items.Clear(); foreach (EntityFinancialDecorator usr in _intFnc.CurrentActivity.Entities) { comboBoxWho.Items.Add((usr.GetName()).Trim()); comboBoxParticipantList.Items.Add((usr.GetName()).Trim()); } foreach (CRE exps in _intFnc.CurrentActivity.ListCRE) { comboBoxMovement.Items.Add(exps.Name); if (expsId != null && exps.Id.Equals(expsId)) { _expsCurrent = exps; } } if (comboBoxMovement.Items.Count > 0) { comboBoxMovement.SelectedItem = comboBoxMovement.Items[0]; } if (expsId == null) { _expsCurrent = new CRE(); _expsNew = new CRE(); checkBoxNewMovement.Checked = true; LoadExpense(_expsNew); } else { LoadExpense(_expsCurrent); } comboBoxMovement.Enabled = !checkBoxNewMovement.Checked; }
private void Import(CRE source, CRE target) { target._allParticipant = source._allParticipant; target._amount = source._amount; target._billPath = source._billPath; target._currency = source._currency; target._description = source._description; target._endDate = source._endDate; target._gop = source._gop; target._gopExample = source._gopExample; target._id = source._id; target._isPartial = source._isPartial; target._name = source._name; target._movements = source._movements; target._startDate = source._startDate; target._subMovement = source._subMovement; source = null; }
public ExpsEdit(InterfaceFinance intFnc, int?expsId) { _intFnc = intFnc; InitializeComponent(); LoadPrj(expsId); _expsNew = new CRE(); if (expsId != null) { textBoxMovementName.Visible = false; buttonValidateMovement.Text = "Update movement"; checkBoxNewMovement.Checked = false; } else { _expsCurrent = _expsNew; checkBoxNewMovement.Checked = true; } this.comboBoxMovement.SelectedValueChanged += new System.EventHandler(this.comboBoxMovement_SelectionChanged); }
public object Clone() { CRE exps = new CRE(); exps.Amount = _amount; exps.Name = _name; exps.Gop = _gop; exps.BillPath = _billPath; exps.Currency = _currency; exps.Description = _description; exps.Id = _id; exps.StartDate = _startDate; exps.EndDate = _endDate; exps._gopExample = new List <string>(_gopExample); exps.IsPartial = _isPartial; exps.Movements = new List <Movement>(_movements); exps.AllParticipant = _allParticipant; exps.SubMovement = _subMovement; return(exps); }
private static void ExtractMovement(string line) { float tmpAmount = 0; string[] dump = line.Split(';'); DateTime tmpDate = DateTime.MinValue; Movement mvt = new Movement(); DateTime.TryParse(dump[0], out tmpDate); if (tmpDate != DateTime.MinValue) { mvt.StartDate = tmpDate; } mvt.Name = dump[1]; mvt.Description = dump[1]; if (string.IsNullOrEmpty(dump[2]) && !string.IsNullOrEmpty(dump[3])) { float.TryParse(dump[3], out tmpAmount); mvt.Amount = tmpAmount; } if (!string.IsNullOrEmpty(dump[2]) && string.IsNullOrEmpty(dump[3])) { float.TryParse(dump[2], out tmpAmount); mvt.Amount = -tmpAmount; } CRE exp = new CRE(); exp.Gop = DetermineGOP(mvt.Name); exp.Movements.Add(mvt); exp.Amount = tmpAmount; exp.Description = mvt.Name; exp.IsPartial = false; _extractedActivity.ListCRE.Add(exp); //Expense activityExpense = _extractedActivity.ListExpenses.Where(e => e.Gop == exp.Gop).FirstOrDefault(); //if (activityExpense == null) { _extractedActivity.ListExpenses.Add(exp); } //else { activityExpense.Movements.Add(mvt); } }
private List <CRE> Parse(List <string> listFlatExps) { string analyseString = string.Empty; List <CRE> lstExps = new List <CRE>(); foreach (string flatExps in listFlatExps) { CRE exps = new CRE(); string[] tab = flatExps.Split(';'); foreach (string item in tab) { analyseString = CleanString(item); if (!string.IsNullOrEmpty(analyseString)) { if (SearchDate(exps, analyseString)) { } else if (SearchAmount(exps, analyseString)) { } else { if (string.IsNullOrEmpty(exps.Name)) { exps.Name = analyseString; } exps.Description += analyseString + " "; } } } SearchGop(exps); lstExps.Add(exps); } return(lstExps); }
private void LoadExpense(CRE exps) { if (exps != null) { checkBoxAllRegardingParticipants.Checked = exps.AllParticipant; checkBoxIsPartial.Checked = exps.IsPartial; if (exps.StartDate > dateTimePickerStartDate.MinDate && exps.StartDate < dateTimePickerStartDate.MaxDate) { dateTimePickerStartDate.Value = exps.StartDate; } else { dateTimePickerStartDate.Value = DateTime.Now; } if (exps.EndDate > dateTimePickerEndDate.MinDate && exps.EndDate < dateTimePickerEndDate.MaxDate) { dateTimePickerEndDate.Value = exps.EndDate; } else { dateTimePickerEndDate.Value = DateTime.Now; } if (!string.IsNullOrEmpty(exps.Name)) { comboBoxMovement.SelectedItem = comboBoxMovement.Items.IndexOf(exps.Name) == -1 ? null : comboBoxMovement.Items[comboBoxMovement.Items.IndexOf(exps.Name)]; } comboBoxCurrency.SelectedItem = (string.IsNullOrEmpty(exps.Currency) || comboBoxCurrency.Items.IndexOf(exps.Currency) == -1) ? comboBoxCurrency.Items[0] : comboBoxCurrency.Items[comboBoxCurrency.Items.IndexOf(exps.Currency)]; textBoxDescription.Text = exps.Description; textBoxAmount.Text = exps.Amount.ToString(); textBoxMovementName.Text = exps.Name; textBoxBillPath.Text = exps.BillPath; LoadPicture(); EntityFinancialDecorator userTmp; List <string> ls = new List <string>(); foreach (string s in comboBoxParticipantList.Items) { ls.Add(s); } foreach (string userStr in ls) { userTmp = _intFnc.CurrentActivity.Entities.Find(x => (x.GetName()).Trim().Equals(userStr.Trim())); if (userTmp != null && exps.Movements.Where(p => p.UserId.Equals(userTmp.Id)).Count() > 0) { if (comboBoxParticipantList.Items.IndexOf(userStr.Trim()) != -1) { comboBoxParticipantList.SetItemChecked(comboBoxParticipantList.Items.IndexOf(userStr.Trim()), true); } } } foreach (string s in comboBoxWho.Items) { ls.Add(s); } foreach (string userStr in ls) { userTmp = _intFnc.CurrentActivity.Entities.Find(x => (x.GetName()).Trim().Equals(userStr.Trim())); //if (userTmp != null && exps. UserId.Contains(userTmp.ID)) //{ // if (comboBoxWho.Items.IndexOf(userStr.Trim()) != -1) comboBoxWho.SetItemChecked(comboBoxWho.Items.IndexOf(userStr.Trim()), true); //} } switch (exps.Gop) { case CRE.GOP.COMODITIES: radioButtonComodities.Checked = true; break; case CRE.GOP.ACTIVITIES: radioButtonActivities.Checked = true; break; case CRE.GOP.FOOD: radioButtonFood.Checked = true; break; case CRE.GOP.OTHER: radioButtonOther.Checked = true; break; case CRE.GOP.TRANSPORT: radioButtonTransport.Checked = true; break; case CRE.GOP.CLOTHES: radioButtonClothe.Checked = true; break; case CRE.GOP.LOGEMENT: radioButtonLogement.Checked = true; break; case CRE.GOP.ABONMENT: radioButtonAbonmnent.Checked = true; break; case CRE.GOP.LOANS: radioButtonLoan.Checked = true; break; } if (!checkBoxNewMovement.Checked) { foreach (var item in comboBoxMovement.Items) { if (item.ToString().Equals(exps.Name)) { comboBoxMovement.SelectedItem = item; break; } } } else { textBoxMovementName.Text = exps.Name; } } }