dlgProtocol.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using Quadarax.Foundation.Core.IO;
  2. using System.IO.Abstractions;
  3. namespace qdr.app.studiou.orders2printpack
  4. {
  5. public partial class dlgProtocol : Form
  6. {
  7. #region *** Properties ***
  8. public string ExternalOrder => tbExternalOrder.Text;
  9. public DateTime ExternalOrderDate => dtExternaOrderDate.Value;
  10. public string ProtocolFile => tbProtocolFile.Text;
  11. #endregion
  12. #region *** Fields ***
  13. private readonly IFileSystem _fs = new FileSystem();
  14. #endregion
  15. #region *** Contructor ***
  16. public dlgProtocol()
  17. {
  18. InitializeComponent();
  19. }
  20. #endregion
  21. #region *** Form Handlers ***
  22. private void dlgProtocol_Load(object sender, EventArgs e)
  23. {
  24. tbExternalOrder.Text = string.Empty;
  25. tbProtocolFile.Text = string.Empty;
  26. }
  27. private void butOk_Click(object sender, EventArgs e)
  28. {
  29. if(tbExternalOrder.Text.Trim().Length == 0)
  30. {
  31. MessageBox.Show("Zadejte číslo externí objednávky", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  32. tbExternalOrder.Focus();
  33. return;
  34. }
  35. if(tbProtocolFile.Text.Trim().Length == 0)
  36. {
  37. MessageBox.Show("Zadejte název souboru protokolu (*.csv)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  38. butOpenProt.Focus();
  39. return;
  40. }
  41. DialogResult = DialogResult.OK;
  42. Close();
  43. }
  44. private void butCancel_Click(object sender, EventArgs e)
  45. {
  46. DialogResult = DialogResult.Cancel;
  47. Close();
  48. }
  49. private void butOpenProt_Click(object sender, EventArgs e)
  50. {
  51. dlgSave.FileName = FileUtils.SanitizedFileName(_fs, $"protocol_border_{tbExternalOrder.Text}.csv", "_");
  52. if (dlgSave.ShowDialog() == DialogResult.OK)
  53. {
  54. tbProtocolFile.Text = dlgSave.FileName;
  55. }
  56. }
  57. #endregion
  58. }
  59. }