frmLoginSettings.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace LYFZ.ERPCloudClient
  10. {
  11. public partial class frmLoginSettings : LYFZ.ComponentLibrary.BaseContentsFormMain
  12. {
  13. public frmLoginSettings()
  14. {
  15. InitializeComponent();
  16. this.btnEnter.Click += btnEnter_Click;
  17. this.btnClose.Click += btnClose_Click;
  18. this.Shown += frmLoginSettings_Shown;
  19. }
  20. void frmLoginSettings_Shown(object sender, EventArgs e)
  21. {
  22. this.txtHostName.Text = this.clientCon.ServerIP;
  23. this.txtHostPort.Text = this.clientCon.Port.ToString();
  24. }
  25. LYFZ.CloudServerData.Model.CloudClientConfig clientCon;
  26. public LYFZ.CloudServerData.Model.CloudClientConfig ClientCon
  27. {
  28. get { return clientCon; }
  29. set { clientCon = value; }
  30. }
  31. void btnClose_Click(object sender, EventArgs e)
  32. {
  33. this.Close();
  34. }
  35. void btnEnter_Click(object sender, EventArgs e)
  36. {
  37. this.ClientCon.ServerIP = this.txtHostName.Text.Trim();
  38. if (String.IsNullOrEmpty(this.ClientCon.ServerIP.Trim()))
  39. {
  40. MessageBoxCustom.Show(LYFZ.WinAPI.UserTips.GetCanNotBeEmptyTips(this.lbHostName.Text));
  41. return;
  42. }
  43. if (String.IsNullOrEmpty(this.txtHostPort.Text.Trim()))
  44. {
  45. MessageBoxCustom.Show(LYFZ.WinAPI.UserTips.GetCanNotBeEmptyTips(this.lbHostPort.Text));
  46. return;
  47. }
  48. try
  49. {
  50. this.ClientCon.Port = Convert.ToUInt16(this.txtHostPort.Text.Trim());
  51. }
  52. catch
  53. {
  54. MessageBoxCustom.Show(this.lbHostPort.Text + "输入的格式不正确");
  55. return;
  56. }
  57. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  58. {
  59. backgroundWorker.ReportProgress(0, "正在更新...");
  60. if (!LYFZ.CloudServerData.SystemConfig.WriteCloudClientConfig(this.ClientCon))
  61. {
  62. MessageBoxCustom.Show("更新失败,请重新启动程序后重试", backgroundWorker: backgroundWorker);
  63. }
  64. else {
  65. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  66. }
  67. });
  68. }
  69. }
  70. }