Spara ny /ändrad införd

This commit is contained in:
2023-09-15 17:59:58 +02:00
parent 0c0533f9d5
commit ef14ce2aaa
4 changed files with 70 additions and 0 deletions

View File

@ -8,6 +8,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WinFormDiApp.BL.Helpers;
using WinFormDiApp.BL.Models;
using WinFormDiApp.BLI;
namespace WinFormDiApp
@ -65,5 +66,35 @@ namespace WinFormDiApp
}
}
}
private void btnSave_Click(object sender, EventArgs e)
{
AccountRecord saveRecord = new AccountRecord();
if(rbEdit.Checked)
{
saveRecord.Id = Convert.ToInt32( txtId.Text);
saveRecord.Stored = DateTime.Parse(txtSaved.Text);
}
saveRecord.Konto = txtAccount.Text;
saveRecord.Belopp = Convert.ToDouble(txtAmount.Text);
saveRecord.Avisering = txtPayInfo.Text;
saveRecord.Mottagare = txtReceiver.Text;
saveRecord.BetalDatum =dtpPayDate.Value;
;
_recordRepository.SaveAcountRecord(saveRecord);
if (saveRecord != null)
{
rbEdit.Checked = true;
txtId.Text = saveRecord.Id.ToString();
txtAccount.Text = saveRecord.Konto.ToString();
txtAmount.Text = saveRecord.Belopp.ToString();
txtPayInfo.Text = saveRecord.Avisering.ToString();
txtReceiver.Text = saveRecord.Mottagare.ToString();
dtpPayDate.Value = saveRecord.BetalDatum;
txtSaved.Text = saveRecord.Stored.ToLongDateString();
}
}
}
}