Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. using HKLib.DB;
  2. using HKCardManager.UserPages;
  3. namespace HKCardManager
  4. {
  5. public partial class Form1 : Form
  6. {
  7. public Form1()
  8. {
  9. InitializeComponent();
  10. splitContainer1.SplitterDistance = 240;
  11. Task.Factory.StartNew(() =>
  12. {
  13. DbContext.InitTable();
  14. });
  15. ShowPage(new PersonnelEntryPage());
  16. this.SizeChanged += Form1_SizeChanged;
  17. this.button1.SizeChanged += Button1_SizeChanged;
  18. MessageLogNotify.GetInstance.Info = new Action<string, Brush>((s, br) =>
  19. {
  20. this.Invoke(() => { AddListToListBox(listBox1, s, br, true); });
  21. });
  22. }
  23. private void Write(string msg)
  24. {
  25. //boolĬΪļ涨,Զκα
  26. //bool temp = Convert.ToBoolean(iniFile.IniReadValue("", "Ϣ", AppDomain.CurrentDomain.BaseDirectory + ".ini"));
  27. //if (temp)
  28. //{
  29. // string logPath = Path.GetDirectoryName(Application.ExecutablePath);
  30. // // System.IO.StreamWriter sw = System.IO.File.AppendText(logPath + "/" + DateTime.Now.ToString("yyMMdd") + ".txt");
  31. // System.IO.StreamWriter sw = System.IO.File.AppendText(logPath + "\\log\\" + DateTime.Now.ToString("yyMMdd") + ".txt");
  32. // sw.WriteLine(DateTime.Now.ToString("HH:mm:ss ") + msg);
  33. // sw.Close();
  34. // sw.Dispose();
  35. //}
  36. }
  37. private void AddListToListBox(ListBox rtbox, string text, Brush foreColor, bool addTime = true)
  38. {
  39. rtbox.DrawMode = DrawMode.OwnerDrawVariable;
  40. rtbox.Font = new Font("", 12);
  41. if (rtbox.ItemHeight != 24)
  42. {
  43. rtbox.ItemHeight = 1;
  44. rtbox.DrawItem += ((sender, e) => //ؼػ¼
  45. {
  46. if (e.Index == -1) return;
  47. e.DrawBackground();
  48. ListBoxItem item = (ListBoxItem)rtbox.Items[e.Index];
  49. if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
  50. {
  51. e.DrawFocusRectangle();
  52. Brush b = Brushes.Khaki;//ѡɫ
  53. e.Graphics.FillRectangle(b, e.Bounds);
  54. }
  55. if (item != null)
  56. {
  57. Brush brush = item.ForeColor;
  58. Rectangle r = e.Bounds;
  59. r.Height = e.Bounds.Height;
  60. r.Width = e.Bounds.Width + 100;
  61. e.Graphics.DrawString(item.Text, e.Font, brush, r, StringFormat.GenericDefault);
  62. }
  63. else
  64. {
  65. e.Graphics.DrawString(item.Text, e.Font, Brushes.Black, e.Bounds, StringFormat.GenericDefault);
  66. }
  67. });
  68. }
  69. rtbox.ItemHeight = 25;//õи߶
  70. if (rtbox.InvokeRequired)
  71. {
  72. rtbox.Invoke(new Action<ListBox, string, Brush, bool>((rtb, str, color, addtime) => AddListToListBox(rtb, str, color, addtime)), rtbox, text, foreColor, addTime);
  73. return;
  74. }
  75. //text = string.Format("{0}-{1}", rtbox.Items.Count.ToString("000"), text);
  76. if (addTime)
  77. {
  78. //text = string.Format("[{0}]:{1}", DateTime.Now.ToString("HH:mm:ss"), text);
  79. text = $"{DateTime.Now.ToString("HH:mm:ss")}{text}";
  80. }
  81. if (rtbox.Items.Count > 0)
  82. rtbox.Items.Insert(0, new ListBoxItem(text, foreColor));
  83. else
  84. rtbox.Items.Add(new ListBoxItem(text, foreColor));
  85. try
  86. {
  87. Write(text);
  88. }
  89. catch { }
  90. //
  91. //if (rtbox.Items.Count > 100)
  92. //{
  93. // int count = rtbox.Items.Count - 100;
  94. // List<object> temp = new List<object>();
  95. // for (int i = 0; i < count; i++)
  96. // {
  97. // temp.Add(rtbox.Items[i]);
  98. // }
  99. // foreach (object obj in temp)
  100. // {
  101. // rtbox.Items.Remove(obj);
  102. // }
  103. //}
  104. //rtbox.SelectedIndex = rtbox.Items.Count - 1;
  105. }
  106. private void Button1_SizeChanged(object? sender, EventArgs e)
  107. {
  108. groupBox1.Width = button1.Width;
  109. groupBox2.Width = button1.Width;
  110. groupBox3.Width = button1.Width;
  111. groupBox4.Width = button1.Width;
  112. button2.Left = 10;
  113. button2.Width = (groupBox1.Width - 20);
  114. button3.Left = 10;
  115. button3.Width = (groupBox1.Width - 20);
  116. button4.Left = 10;
  117. button4.Width = (groupBox2.Width - 20);
  118. button5.Left = 10;
  119. button5.Width = (groupBox2.Width - 20);
  120. button6.Left = 10;
  121. button6.Width = (groupBox2.Width - 20);
  122. button7.Left = 10;
  123. button7.Width = (groupBox2.Width - 20);
  124. button9.Left = 10;
  125. button9.Width = (groupBox3.Width - 20);
  126. button10.Left = 10;
  127. button10.Width = (groupBox3.Width - 20);
  128. button11.Left = 10;
  129. button11.Width = (groupBox3.Width - 20);
  130. button12.Left = 10;
  131. button12.Width = (groupBox4.Width - 20);
  132. }
  133. UserControl tempUserControl;
  134. private void Form1_SizeChanged(object? sender, EventArgs e)
  135. {
  136. if (tempUserControl != null)
  137. {
  138. tempUserControl.Width = this.panel1.Width;
  139. tempUserControl.Height = this.panel1.Height;
  140. }
  141. splitContainer1.SplitterDistance = 240;
  142. if (this.WindowState == FormWindowState.Maximized || this.WindowState == FormWindowState.Normal)
  143. {
  144. Task.Factory.StartNew(() =>
  145. {
  146. Thread.Sleep(100);
  147. this.Invoke(() =>
  148. {
  149. if (tempUserControl != null)
  150. {
  151. tempUserControl.Width = this.panel1.Width;
  152. tempUserControl.Height = this.panel1.Height;
  153. }
  154. splitContainer1.SplitterDistance = 240;
  155. });
  156. });
  157. }
  158. }
  159. //private void Ա¼ToolStripMenuItem_Click(object sender, EventArgs e)
  160. //{
  161. // new PersonnelEntry().ShowDialog();
  162. //}
  163. //private void ¼ToolStripMenuItem_Click(object sender, EventArgs e)
  164. //{
  165. // new InstitutionalEntry().ShowDialog();
  166. //}
  167. //private void ToolStripMenuItem_Click(object sender, EventArgs e)
  168. //{
  169. // new Hairpin().ShowDialog();
  170. //}
  171. //private void ToolStripMenuItem_Click(object sender, EventArgs e)
  172. //{
  173. // Cancellation cancellation = new Cancellation();
  174. // cancellation.Text = "";
  175. // cancellation.ShowDialog();
  176. //}
  177. //private void ʧToolStripMenuItem_Click(object sender, EventArgs e)
  178. //{
  179. // Cancellation cancellation = new Cancellation();
  180. // cancellation.Text = "ʧ";
  181. // cancellation.ShowDialog();
  182. //}
  183. //private void ToolStripMenuItem_Click(object sender, EventArgs e)
  184. //{
  185. // Cancellation cancellation = new Cancellation();
  186. // cancellation.Text = "";
  187. // cancellation.ShowDialog();
  188. //}
  189. //private void ²ͶλܱToolStripMenuItem_Click(object sender, EventArgs e)
  190. //{
  191. // DailyConsumptionTable dailyConsumptionTable = new DailyConsumptionTable();
  192. // dailyConsumptionTable.Text = "²Ͷλܱ";
  193. // dailyConsumptionTable.ShowDialog();
  194. //}
  195. //private void ƴξͲѱToolStripMenuItem_Click(object sender, EventArgs e)
  196. //{
  197. // DailyConsumptionTable dailyConsumptionTable = new DailyConsumptionTable();
  198. // dailyConsumptionTable.Text = "ƴξͲѱ";
  199. // dailyConsumptionTable.ShowDialog();
  200. //}
  201. //private void ƴξͲϸToolStripMenuItem_Click(object sender, EventArgs e)
  202. //{
  203. // DailyConsumptionTable dailyConsumptionTable = new DailyConsumptionTable();
  204. // dailyConsumptionTable.Text = "ƴξͲϸ";
  205. // dailyConsumptionTable.ShowDialog();
  206. //}
  207. //private void ͶToolStripMenuItem_Click(object sender, EventArgs e)
  208. //{
  209. // new MealSegmentSet().ShowDialog();
  210. //}
  211. //Ա¼
  212. private void button2_Click(object sender, EventArgs e)
  213. {
  214. ShowPage(new PersonnelEntryPage());
  215. }
  216. //¼
  217. private void button3_Click(object sender, EventArgs e)
  218. {
  219. ShowPage(new InstitutionalEntryPage());
  220. }
  221. //
  222. private void button5_Click(object sender, EventArgs e)
  223. {
  224. ShowPage(new CarMangerPage());
  225. }
  226. //ʧ
  227. private void button4_Click(object sender, EventArgs e)
  228. {
  229. ShowPage(new CancellationPage(), ((Button)sender)?.Tag.ToString());
  230. }
  231. //²Ͷλܱ
  232. private void button11_Click(object sender, EventArgs e)
  233. {
  234. ShowPage(new ReportFormPage(), ((Button)sender)?.Tag.ToString());
  235. }
  236. //Ͷ
  237. private void button12_Click(object sender, EventArgs e)
  238. {
  239. ShowPage(new MealSegmentSetPage());
  240. }
  241. private void ShowPage(UserControl userControl, string? name = "")
  242. {
  243. panel1.Controls.Clear();
  244. userControl.Width = panel1.Width;
  245. userControl.Height = panel1.Height;
  246. tempUserControl = userControl;
  247. userControl.Tag = name;
  248. userControl.Show();
  249. panel1.Controls.Add(userControl);
  250. }
  251. private void button8_Click(object sender, EventArgs e)
  252. {
  253. ShowPage(new AdvertisingSetPage());
  254. }
  255. }
  256. }