OrdersReportPrintFormMain.cs 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089
  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. using LYFZ.Software.MainBusiness.DoorCityProcess;
  10. using System.Collections;
  11. using System.IO;
  12. using LYFZ.ComponentLibrary;
  13. namespace LYFZ.Software.MainBusiness.ReportPrint
  14. {
  15. public partial class OrdersReportPrintFormMain : LYFZ.Software.UI.ReportPrint.OrdersReportPrintFormMain
  16. {
  17. public OrdersReportPrintFormMain()
  18. {
  19. }
  20. protected override void buttonEx1_Click(object sender, EventArgs e)
  21. {
  22. //LYFZ.Software.MainBusiness.DoorCityProcess.TestFrom frm = new TestFrom();
  23. //frm.Show();
  24. //LYFZ.Software.MainBusiness.ReportPrint.SetSmallForm.PrintPreviewSmallForm frm = new SetSmallForm.PrintPreviewSmallForm();
  25. //frm.ShowDialog(); return;
  26. //LYFZ.Software.MainBusiness.DataSe.ShopMessageSetFormMain ShopMessage = new DataSe.ShopMessageSetFormMain();
  27. //ShopMessage.Show();
  28. //PublicCodeClasses.OrderProcessSendSMS("201411230001", EnumPermissions.ProcessSendSMS.CustomerOrderFulfillment);
  29. //new ReportPrint.ReportFixedFormat().PrintFixedFormat(LYFZ.EnumPublic.PrintTypeEnum.儿童预约单, StrOrd_Number: "H_201412240005");
  30. //测试固定格式
  31. //ReportFixedFormat rpf = new ReportFixedFormat();
  32. //this.panlModel.BackgroundImageLayout = ImageLayout.Zoom;
  33. //Image img = rpf.CameraControlBookFixedFormat();
  34. //this.panlModel.Size = img.Size;
  35. //this.panlModel.BackgroundImage = img;
  36. //this.Size = new Size(this.panlModel.Width + this.panlModel.Location.X, this.panlModel.Height);
  37. }
  38. private string _panelsize = "";
  39. /// <summary>
  40. /// 绘版的大小
  41. /// </summary>
  42. private string PancelSize
  43. { set { _panelsize = value; } get { return _panelsize; } }
  44. private bool _isprint = true;
  45. /// <summary>
  46. /// 是否打印图片背景(true:打印出背景图片; false:不打印出背景图片)
  47. /// </summary>
  48. public bool IsPrint
  49. { get { return _isprint; } set { _isprint = value; } }
  50. private int _lbladdcount = 0;
  51. /// <summary>
  52. /// 当前创建label的数量(即为label Name的更始编号)
  53. /// </summary>
  54. private int lbAddCount
  55. { set { _lbladdcount = value; } get { return _lbladdcount; } }
  56. private string _picturepatht = "";
  57. /// <summary>
  58. /// 选择的图片路径
  59. /// </summary>
  60. private string PicturePath
  61. { set { _picturepatht = value; } get { return _picturepatht; } }
  62. /// <summary>
  63. /// 储存每个label的字间距设置
  64. /// </summary>
  65. private Hashtable htData_Pitch = new Hashtable();
  66. /// <summary>
  67. /// 储存每个label的对齐方式设置
  68. /// </summary>
  69. private Hashtable htData_Align = new Hashtable();
  70. /// <summary>
  71. /// 储存每个label的Decimal类型的金钱格式设置
  72. /// </summary>
  73. private Hashtable htData_Money = new Hashtable();
  74. /// <summary>
  75. /// 储存每个label的DateTime类型的日期格式设置
  76. /// </summary>
  77. private Hashtable htData_Date = new Hashtable();
  78. /// <summary>
  79. /// 储存每个label的DateTime类型的日期格式设置
  80. /// </summary>
  81. private Hashtable htData_ToUpper = new Hashtable();
  82. /// <summary>
  83. /// 窗体加载
  84. /// </summary>
  85. /// <param name="sender"></param>
  86. /// <param name="e"></param>
  87. protected override void OrdersReportPrintFormMain_Load(object sender, EventArgs e)
  88. {
  89. if (LYFZ.Software.MainBusiness.EnumPermissions.BusinessType.儿童版 == LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetBusinessType())
  90. {
  91. this.cmbQueryText.Items.Add(new ListItem("订单报表", "OrderReport_Children"));
  92. this.cmbQueryText.Items.Add(new ListItem("订单派工", "OrderSendWork_Children"));
  93. this.cmbQueryText.Items.Add(new ListItem("订单明细", "OrderDetails_Children"));
  94. this.cmbQueryText.Items.Add(new ListItem("收款凭据", "FinancePayment_Children"));
  95. }
  96. else if (LYFZ.Software.MainBusiness.EnumPermissions.BusinessType.婚纱版 == LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetBusinessType())
  97. {
  98. this.cmbQueryText.Items.Add(new ListItem("订单报表", "OrderReport_Wedding"));
  99. this.cmbQueryText.Items.Add(new ListItem("订单派工", "OrderSendWork_Wedding"));
  100. this.cmbQueryText.Items.Add(new ListItem("订单明细", "OrderDetails_Wedding"));
  101. this.cmbQueryText.Items.Add(new ListItem("收款凭据", "FinancePayment_Wedding"));
  102. }
  103. else if (LYFZ.Software.MainBusiness.EnumPermissions.BusinessType.旗舰版 == LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetBusinessType())
  104. {
  105. //this.cmbQueryText.Items.Add(new ListItem("订单报表_全能版", "OrderReport_Almighty"));
  106. this.cmbQueryText.Items.Add(new ListItem("订单报表_儿童版", "OrderReport_Children"));
  107. this.cmbQueryText.Items.Add(new ListItem("订单报表_婚纱版", "OrderReport_Wedding"));
  108. this.cmbQueryText.Items.Add(new ListItem("订单派工_儿童版", "OrderSendWork_Children"));
  109. this.cmbQueryText.Items.Add(new ListItem("订单派工_婚纱版", "OrderSendWork_Wedding"));
  110. this.cmbQueryText.Items.Add(new ListItem("订单明细_儿童版", "OrderDetails_Children"));
  111. this.cmbQueryText.Items.Add(new ListItem("订单明细_婚纱版", "OrderDetails_Wedding"));
  112. this.cmbQueryText.Items.Add(new ListItem("收款凭据_儿童版", "FinancePayment_Children"));
  113. this.cmbQueryText.Items.Add(new ListItem("收款凭据_婚纱版", "FinancePayment_Wedding"));
  114. }
  115. }
  116. /// <summary>
  117. /// 选择图片
  118. /// </summary>
  119. /// <param name="sender"></param>
  120. /// <param name="e"></param>
  121. protected override void btnView_Click(object sender, EventArgs e)
  122. {
  123. this.openFileDialog1.Filter = "所有文件(*.*)|*.*";
  124. this.openFileDialog1.Multiselect = false;
  125. this.openFileDialog1.FileName = "";
  126. this.openFileDialog1.FilterIndex = 2;
  127. if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
  128. {
  129. PicturePath = this.openFileDialog1.FileName;
  130. //Image image = Image.FromFile(PicturePath);
  131. //this.panlModel.BackgroundImageLayout = ImageLayout.Zoom;
  132. //this.panlModel.BackgroundImage = image;
  133. //this.panlModel.Size =System.Drawing.Image.FromStream(fs).Size;
  134. FileStream fs = new FileStream(PicturePath, FileMode.Open, FileAccess.Read);
  135. this.panlModel.BackgroundImage = System.Drawing.Image.FromStream(fs);
  136. this.panlModel.BackgroundImageLayout = ImageLayout.Zoom;
  137. fs.Close();
  138. this.PancelSize = this.panlModel.Size.Width + "," + this.panlModel.Size.Height;
  139. }
  140. }
  141. /// <summary>
  142. /// 下拉列表更改事件
  143. /// </summary>
  144. /// <param name="sender"></param>
  145. /// <param name="e"></param>
  146. protected override void cmbQueryText_SelectedIndexChanged(object sender, EventArgs e)
  147. {
  148. this.treevListData.Nodes.Clear();
  149. this.panlModel.Controls.Clear();
  150. this.listArray.Clear();
  151. this.htData_Pitch.Clear();
  152. this.htData_Money.Clear();
  153. this.htData_Date.Clear();
  154. this.htData_Align.Clear();
  155. this.htData_ToUpper.Clear();
  156. if (this.cmbQueryText.Text.Trim() != "")
  157. {
  158. ListItem li = (ListItem)this.cmbQueryText.SelectedItem;
  159. string strKey = li.StrText; //得到选中项key(Prod_Name)
  160. string strValue = li.StrValue.ToString(); //得到选中项value (Prod_Class)
  161. string QueryTag = strValue.Split('_')[0].Trim();
  162. string Version = strValue.Split('_')[1].Trim();
  163. string QueryText = strKey;
  164. if (QueryText.IndexOf('_') != -1)
  165. {
  166. QueryText = QueryText.Substring(0, QueryText.IndexOf('_'));
  167. }
  168. switch (QueryText)
  169. {
  170. case "订单报表":
  171. case "订单派工":
  172. new LYFZ.Software.MainBusiness.ReportPrint.ReportGenerationColumnClass().Order_GenerationColumn(this.treevListData, Version, QueryTag); break;
  173. case "收款凭据":
  174. new LYFZ.Software.MainBusiness.ReportPrint.ReportGenerationColumnClass().Order_GenerationColumn(this.treevListData, Version, QueryTag); break;
  175. }
  176. DataTable tbl = new LYFZ.BLL.BLL_ErpReportModel().GetList("Rmd_EnglishName='" + strValue + "'").Tables[0];
  177. if (tbl.Rows.Count > 0)
  178. {
  179. if (tbl.Rows[0]["Rmd_StrJion"].ToString().Trim() != "")
  180. {
  181. Json.JsontoDataTable jdt = new Json.JsontoDataTable();
  182. DataTable tbl_ModelJion = jdt.toObject(tbl.Rows[0]["Rmd_ModelJion"].ToString().Trim());
  183. this.panlModel.Name = tbl_ModelJion.Rows[0]["Name"].ToString().Trim();
  184. this.IsPrint = tbl_ModelJion.Rows[0]["IsPrint"].ToString().Trim() == "true" ? true : false;
  185. this.panlModel.Size = new Size(Convert.ToInt32(tbl_ModelJion.Rows[0]["SizeWidth"].ToString().Trim()), Convert.ToInt32(tbl_ModelJion.Rows[0]["SizeHigh"].ToString().Trim()));
  186. this.PancelSize = tbl_ModelJion.Rows[0]["SizeWidth"].ToString().Trim() + "," + tbl_ModelJion.Rows[0]["SizeHigh"].ToString().Trim();
  187. this.PicturePath = tbl.Rows[0]["Rmd_PhotoPath"].ToString().Trim();
  188. #region 把服务上的图片下载出来
  189. if (!System.IO.File.Exists(PicturePath))
  190. { MessageBoxCustom.Show("报表背景图片不存在"); PanlModelClear(true); return; }
  191. string SavePath = "C:\\LYFZ.Print\\" + PicturePath.Substring(PicturePath.LastIndexOf(@"\") + 1, PicturePath.Length - (PicturePath.LastIndexOf(@"\") + 1));//图片名如:78.jpg
  192. System.IO.File.Copy(PicturePath, SavePath, true);
  193. #endregion
  194. this.PicturePath = SavePath;
  195. this.panlModel.BackgroundImage = null;
  196. FileStream fs = new FileStream(SavePath, FileMode.Open, FileAccess.Read);
  197. panlModel.BackgroundImage = System.Drawing.Image.FromStream(fs);
  198. this.panlModel.BackgroundImageLayout = ImageLayout.Zoom;
  199. fs.Close();
  200. DataTable tbl_Jion = jdt.toObject(tbl.Rows[0]["Rmd_StrJion"].ToString().Trim());
  201. for (int i = 0; i < tbl_Jion.Rows.Count; i++)
  202. {
  203. lbAddCount++;
  204. Label lb = new Label();
  205. lb.Text = SetWordSpacing(tbl_Jion.Rows[i]["Value"].ToString().Trim(), Convert.ToInt32(tbl_Jion.Rows[i]["WordPitch"].ToString().Trim()));//
  206. lb.Tag = tbl_Jion.Rows[i]["Column"].ToString().Trim() + "|" + tbl_Jion.Rows[i]["Type"].ToString().Trim();
  207. lb.Name = tbl_Jion.Rows[i]["Column"].ToString().Trim() + (lbAddCount + 1);
  208. lb.Font = new System.Drawing.Font("微软雅黑", float.Parse(tbl_Jion.Rows[i]["FontSize"].ToString().Trim()));
  209. lb.Location = new Point(Convert.ToInt32(tbl_Jion.Rows[i]["LocationWidth"].ToString().Trim()), Convert.ToInt32(tbl_Jion.Rows[i]["LocationHigh"].ToString().Trim()));//坐标
  210. lb.Size = new Size(Convert.ToInt32(tbl_Jion.Rows[i]["SizeWidth"].ToString().Trim()), Convert.ToInt32(tbl_Jion.Rows[i]["SizeHigh"].ToString().Trim()));
  211. // 储存每个label的字间距设置WordPitch
  212. htData_Pitch[lb.Name] = tbl_Jion.Rows[i]["WordPitch"].ToString().Trim();
  213. // 储存每个label的对齐方式设置
  214. htData_Align[lb.Name] = tbl_Jion.Rows[i]["Align"].ToString().Trim();
  215. // 储存每个label的Decimal类型的金钱格式设置
  216. htData_Money[lb.Name] = tbl_Jion.Rows[i]["MoneyFormat"].ToString().Trim();
  217. // 储存每个label的DateTime类型的日期格式设置
  218. htData_Date[lb.Name] = tbl_Jion.Rows[i]["DateFormat"].ToString().Trim();
  219. /// 储存每个label的DateTime类型的日期格式设置
  220. htData_ToUpper[lb.Name] = tbl_Jion.Rows[i]["ToUpper"].ToString().Trim();
  221. listArray.Add(lb.Name);
  222. lb.ContextMenuStrip = contxtMenu;
  223. lb.AutoSize = false;
  224. RestoreBackColor();
  225. lb.BackColor = SetBackColor(EnumBackColor.Drag);// SetBackColor(EnumBackColor.Create);
  226. if (!IsTouch(lb))//如果不会覆盖,添加到Panel
  227. {
  228. this.panlModel.Controls.Add(lb);
  229. lb.BringToFront();
  230. SetControlProperty(lb);
  231. }
  232. }
  233. }
  234. }
  235. }
  236. }
  237. /// <summary>
  238. /// 窗体大小发生变化
  239. /// </summary>
  240. /// <param name="sender"></param>
  241. /// <param name="e"></param>
  242. protected override void OrdersReportPrintFormMain_Resize(object sender, EventArgs e)
  243. {
  244. if (this.Width > 800)
  245. {
  246. this.btnView.Location = new Point(this.Width - 500, 10);
  247. if (this.PancelSize != "")
  248. { this.panlModel.Size = new Size(Convert.ToInt32(this.PancelSize.Split(',')[0].Trim()), Convert.ToInt32(this.PancelSize.Split(',')[1].Trim())); }
  249. else
  250. { this.panlModel.Size = new Size(this.Width - 215, this.Size.Height - 50); }
  251. }
  252. else
  253. {
  254. this.btnView.Location = new Point(424, 10);
  255. if (this.PancelSize != "")
  256. { this.panlModel.Size = new Size(Convert.ToInt32(this.PancelSize.Split(',')[0].Trim()), Convert.ToInt32(this.PancelSize.Split(',')[1].Trim())); }
  257. else
  258. { this.panlModel.Size = new Size(674, 385); }
  259. }
  260. this.btnReset.Location = new Point(this.btnView.Location.X + this.btnView.Width + 10, 10);
  261. this.btnPreview.Location = new Point(this.btnReset.Location.X + this.btnReset.Width + 10, 10);
  262. this.btnSave.Location = new Point(this.btnPreview.Location.X + this.btnPreview.Width + 10, 10);
  263. this.btnClose.Location = new Point(this.btnSave.Location.X + this.btnSave.Width + 10, 10);
  264. }
  265. /// <summary>
  266. /// 预览
  267. /// </summary>
  268. /// <param name="sender"></param>
  269. /// <param name="e"></param>
  270. protected override void btnPreview_Click(object sender, EventArgs e)
  271. {
  272. Hashtable htData = new Hashtable();
  273. ArrayList alist = new ArrayList();
  274. htData["Alist"] = alist;
  275. LYFZ.Software.MainBusiness.ReportPrint.ReportFixedFormat.PrintFixedFormat(LYFZ.EnumPublic.PrintTypeEnum.拍照明细表, htData);
  276. }
  277. /// <summary>
  278. /// 重置绘板
  279. /// </summary>
  280. /// <param name="sender"></param>
  281. /// <param name="e"></param>
  282. protected override void btnReset_Click(object sender, EventArgs e)
  283. {
  284. this.panlModel.Controls.Clear();
  285. this.listArray.Clear();
  286. this.htData_Pitch.Clear();
  287. this.htData_Money.Clear();
  288. this.htData_Date.Clear();
  289. this.htData_Align.Clear();
  290. this.panlModel.BackgroundImage = null;
  291. }
  292. /// <summary>
  293. /// 保存
  294. /// </summary>
  295. /// <param name="sender"></param>
  296. /// <param name="e"></param>
  297. protected override void btnSave_Click(object sender, EventArgs e)
  298. {
  299. ListItem li = (ListItem)this.cmbQueryText.SelectedItem;
  300. string strKey = li.StrText; //得到选中项key(Prod_Name)
  301. string strValue = li.StrValue.ToString(); //得到选中项value (Prod_Class)
  302. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  303. {
  304. string StrJion = "";
  305. int ForCount = 0;
  306. foreach (Control control in panlModel.Controls)
  307. {
  308. if (control is Label)
  309. {
  310. if (ForCount > 0)
  311. { StrJion += ","; }
  312. StrJion += "{Name:\"" + control.Name.Trim() + "\"";
  313. StrJion += ",Value:\"" + control.Text.Trim() + "\"";
  314. StrJion += ",Column:\"" + control.Tag.ToString().Trim().Split('|')[0].Trim() + "\"";
  315. StrJion += ",Type:\"" + control.Tag.ToString().Trim().Split('|')[1].Trim() + "\"";
  316. StrJion += ",LocationWidth:\"" + control.Location.X + "\"";
  317. StrJion += ",LocationHigh:\"" + control.Location.Y + "\"";
  318. string Align = htData_Align.ContainsKey(control.Name) ? htData_Align[control.Name].ToString().Trim() : "Left";
  319. StrJion += ",Align:\"" + Align + "\"";
  320. string WordPitch = htData_Pitch.ContainsKey(control.Name) ? htData_Pitch[control.Name].ToString().Trim() : "0";
  321. StrJion += ",WordPitch:\"" + WordPitch + "\"";
  322. StrJion += ",SizeWidth:\"" + control.Size.Width + "\"";
  323. StrJion += ",SizeHigh:\"" + control.Size.Height + "\"";
  324. StrJion += ",FontSize:\"" + control.Font.Size + "\"";
  325. string DateFormat = "";
  326. string MoneyFormat = "";
  327. string ToUpper = "";
  328. switch (control.Tag.ToString().Trim().Split('|')[1].Trim())
  329. {
  330. case "DateTime":
  331. DateFormat = htData_Date.ContainsKey(control.Name) ? htData_Date[control.Name].ToString().Trim() : "yyyy-MM-dd";
  332. StrJion += ",DateFormat:\"" + DateFormat + "\"";
  333. StrJion += ",MoneyFormat:\"" + MoneyFormat + "\"";
  334. StrJion += ",ToUpper:\"" + ToUpper + "\"";
  335. break;
  336. case "Decimal":
  337. DateFormat = "";
  338. StrJion += ",DateFormat:\"" + DateFormat + "\"";
  339. MoneyFormat = htData_Money.ContainsKey(control.Name) ? htData_Money[control.Name].ToString().Trim() : "#.00";
  340. StrJion += ",MoneyFormat:\"" + MoneyFormat + "\"";
  341. ToUpper = htData_ToUpper.ContainsKey(control.Name) ? htData_ToUpper[control.Name].ToString().Trim() : "False";
  342. StrJion += ",ToUpper:\"" + ToUpper + "\"";
  343. break;
  344. case "Image":
  345. break;
  346. default:
  347. StrJion += ",DateFormat:\"" + DateFormat + "\"";
  348. StrJion += ",MoneyFormat:\"" + MoneyFormat + "\"";
  349. StrJion += ",ToUpper:\"" + ToUpper + "\"";
  350. break;
  351. }
  352. StrJion += "}";
  353. ForCount++;
  354. }
  355. }
  356. if (StrJion != "")
  357. {
  358. StrJion = ":[" + StrJion + "]";
  359. string ModelJion = ":[{Name:\"" + panlModel.Name + "\"";
  360. ModelJion += ",IsPrint:\"" + this.IsPrint + "\"";
  361. ModelJion += ",SizeWidth:\"" + panlModel.Size.Width + "\"";
  362. ModelJion += ",SizeHigh:\"" + panlModel.Size.Height + "\"}]";
  363. LYFZ.BLL.BLL_ErpReportModel rmbll =new BLL.BLL_ErpReportModel ();
  364. #region 如果以存有则删除
  365. DataTable tbl = rmbll.GetList("Rmd_EnglishName='" + strValue + "'").Tables[0];
  366. if (System.IO.File.Exists(tbl.Rows[0]["Rmd_PhotoPath"].ToString().Trim()))
  367. {
  368. System.IO.FileInfo fi = new System.IO.FileInfo(tbl.Rows[0]["Rmd_PhotoPath"].ToString().Trim());
  369. try
  370. {
  371. fi.Delete();
  372. }
  373. catch { }
  374. }
  375. #endregion
  376. #region 上传图片
  377. if (!System.IO.File.Exists(PicturePath))
  378. { MessageBoxCustom.Show("图片路径错误"); }
  379. string ImagePath = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetReportModelPiece();
  380. string SavePath = ImagePath + @"\" + PicturePath.Substring(PicturePath.LastIndexOf(@"\") + 1, PicturePath.Length - (PicturePath.LastIndexOf(@"\") + 1));//图片名如:78.jpg
  381. System.IO.File.Copy(PicturePath, SavePath, true);
  382. #endregion
  383. LYFZ.Model.Model_ErpReportModel model =rmbll.DataRowToModel(tbl.Rows[0]);
  384. model.Rmd_PhotoPath = SavePath;
  385. model.Rmd_ModelJion = ModelJion;
  386. model.Rmd_StrJion = StrJion;
  387. model.Rmd_UpdateDateTime = SDateTime.Now;
  388. model.Rmd_UpdateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  389. List<LYFZ.Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
  390. clist.Add(rmbll.GetUpdateCommandInfo(model));
  391. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
  392. { MessageBoxCustom.Show("保存成功"); }
  393. else
  394. { MessageBoxCustom.Show("保存失败"); return; }
  395. }
  396. });
  397. }
  398. /// <summary>
  399. /// 关闭
  400. /// </summary>
  401. /// <param name="sender"></param>
  402. /// <param name="e"></param>
  403. protected override void btnClose_Click(object sender, EventArgs e)
  404. { this.Close(); }
  405. /// <summary>
  406. /// 用鼠标双击节点时间发生
  407. /// </summary>
  408. /// <param name="sender"></param>
  409. /// <param name="e"></param>
  410. protected override void treevListData_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
  411. {
  412. if (this.treevListData.SelectedNode != null)
  413. {
  414. if (this.treevListData.SelectedNode.Level > 0)
  415. {
  416. lbAddCount++;
  417. Label lb = new Label();
  418. lb.Location = new Point(20, 20);
  419. lb.Text = e.Node.Text;
  420. lb.Tag = e.Node.Name + "|" + e.Node.Tag;
  421. lb.Name = e.Node.Name + (lbAddCount + 1);
  422. lb.Font = new System.Drawing.Font("宋体", 12);
  423. lb.ContextMenuStrip = contxtMenu;
  424. lb.AutoSize = false;
  425. RestoreBackColor();
  426. lb.BackColor = SetBackColor(EnumBackColor.Create);
  427. if (!IsTouch(lb))//如果不会覆盖,添加到Panel
  428. {
  429. this.panlModel.Controls.Add(lb);
  430. lb.BringToFront();
  431. SetControlProperty(lb);
  432. }
  433. }
  434. }
  435. }
  436. /// <summary>
  437. /// 右键菜单
  438. /// </summary>
  439. /// <param name="sender"></param>
  440. /// <param name="e"></param>
  441. protected override void contxtMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
  442. {
  443. ToolStripItem item = e.ClickedItem;
  444. if (item.Text == "删除")
  445. {
  446. Label lbl = (Label)panlModel.Controls[item.Name];
  447. ControlRemovelbl(lbl);
  448. }
  449. else if (item.Text == "全部删除")
  450. {
  451. PanlModelClear();
  452. }
  453. else if (item.Text == "模板设置")
  454. {
  455. LYFZ.Software.MainBusiness.ReportPrint.SuperSmallForm.ModelSetSuperSmallForm ModelSet = new SuperSmallForm.ModelSetSuperSmallForm();
  456. ModelSet.OldSize = this.panlModel.Size.Width + "," + this.panlModel.Size.Height;
  457. ModelSet.OldIsPrint = this.IsPrint;
  458. ModelSet.ShowDialog();
  459. this.PancelSize = ModelSet.SetSize;
  460. this.IsPrint = ModelSet.IsPrint;
  461. if (this.PancelSize != "")
  462. { this.panlModel.Size = new Size(Convert.ToInt32(this.PancelSize.Split(',')[0].Trim()), Convert.ToInt32(this.PancelSize.Split(',')[1].Trim())); }
  463. }
  464. else if (item.Text == "图片大小设置")
  465. {
  466. LYFZ.Software.MainBusiness.ReportPrint.SuperSmallForm.ImageSizeSetSuperSmallForm ImageSizeSet = new SuperSmallForm.ImageSizeSetSuperSmallForm();
  467. ImageSizeSet.OldSize = this.panlModel.Size.Width + "," + this.panlModel.Size.Height;
  468. ImageSizeSet.ShowDialog();
  469. string StrImageSize = ImageSizeSet.SetSize;
  470. if (StrImageSize != "")
  471. { pulb.Size = new Size(Convert.ToInt32(StrImageSize.Split(',')[0].Trim()), Convert.ToInt32(StrImageSize.Split(',')[1].Trim())); }
  472. }
  473. else if (item.Text == "字体")
  474. {
  475. //FontDialog fd = new FontDialog();
  476. //fd.ShowDialog().ToString();
  477. LYFZ.Software.MainBusiness.ReportPrint.SuperSmallForm.SetFontSizeSuperSmallForm SetFontSize = new SuperSmallForm.SetFontSizeSuperSmallForm();
  478. SetFontSize.OldFontSize = pulb.Font.Size;
  479. SetFontSize.ShowDialog();
  480. if (SetFontSize.NewFontSize != "")
  481. { pulb.Font = new Font("微软雅黑", float.Parse(SetFontSize.NewFontSize)); }
  482. }
  483. else if (item.Text == "字间距")
  484. {
  485. LYFZ.Software.MainBusiness.ReportPrint.SuperSmallForm.WordSpacingSuperSmallForm WordSpacing = new SuperSmallForm.WordSpacingSuperSmallForm();
  486. if (!htData_Pitch.ContainsKey(pulb.Name))
  487. { WordSpacing.OldSpacing = 0; }
  488. else
  489. { WordSpacing.OldSpacing = Convert.ToInt32(htData_Pitch[pulb.Name].ToString()); }
  490. WordSpacing.ShowDialog();
  491. if (htData_Pitch.ContainsKey(pulb.Name))
  492. { htData_Pitch[pulb.Name] = WordSpacing.NewSpacing; pulb.Text = SetWordSpacing(pulb.Text.Trim(), WordSpacing.NewSpacing); }
  493. }
  494. else if (item.Text == "文字左对齐")
  495. {
  496. htData_Align[pulb.Name] = "Left"; pulb.TextAlign = ContentAlignment.MiddleLeft;
  497. }
  498. else if (item.Text == "文字右对齐")
  499. {
  500. htData_Align[pulb.Name] = "Right"; pulb.TextAlign = ContentAlignment.MiddleRight;
  501. }
  502. else if (item.Text == "日期格式设置")
  503. {
  504. LYFZ.Software.MainBusiness.ReportPrint.SuperSmallForm.DateSetSuperSmallForm DateSet = new SuperSmallForm.DateSetSuperSmallForm();
  505. DateSet.ShowDialog();
  506. try
  507. { pulb.Text = Convert.ToDateTime(pulb.Text).ToString(DateSet.SetDateTime); }
  508. catch { }
  509. }
  510. else if (item.Text == "金额格式设置")
  511. {
  512. LYFZ.Software.MainBusiness.ReportPrint.SuperSmallForm.DecimalSetSuperSmallForm DecimalSet = new SuperSmallForm.DecimalSetSuperSmallForm();
  513. DecimalSet.OldDecimal = pulb.Text.ToString().Trim();
  514. DecimalSet.ShowDialog();
  515. try
  516. {
  517. if (DecimalSet.SetDecimal != "")
  518. { htData_Money[pulb.Name] = DecimalSet.SetDecimal; pulb.Text = Convert.ToDecimal(pulb.Text).ToString(DecimalSet.SetDecimal); }
  519. }
  520. catch { }
  521. }
  522. else if (item.Text == "大写显示")
  523. {
  524. try
  525. {
  526. if (LYFZ.Command.Command_Validate.IsNumeric(pulb.Text.Trim()) == false)
  527. { MessageBoxCustom.Show("请先设置值为整数或小数"); }
  528. else { htData_ToUpper[pulb.Name] = "True"; pulb.Text = LYFZ.Software.MainBusiness.ReportPrint.ReportPrintDataClass.ConversionAmount(pulb.Text); }
  529. }
  530. catch { }
  531. }
  532. else if (item.Text == "小写显示")
  533. {
  534. try
  535. { htData_ToUpper[pulb.Name] = "False"; pulb.Text = "5000.00"; }
  536. catch { }
  537. }
  538. else if (item.Text == "设置值")
  539. {
  540. LYFZ.Software.MainBusiness.ReportPrint.SuperSmallForm.SettingValueSuperSmallForm SettingValue = new SuperSmallForm.SettingValueSuperSmallForm();
  541. SettingValue.LoadType = pulb.Tag.ToString().Trim().Split('|')[1];
  542. SettingValue.ShowDialog();
  543. if (SettingValue.StrText != "")
  544. {
  545. if (pulb.Tag.ToString().Trim().Split('|')[1].Trim() != "DateTime") { pulb.Text = SetWordSpacing(SettingValue.StrText, Convert.ToInt32(htData_Pitch[pulb.Name])); }
  546. else { pulb.Text = SettingValue.StrText; }
  547. }
  548. }
  549. }
  550. /// <summary>
  551. /// Panel的右键——删除全部
  552. /// </summary>
  553. /// <param name="sender"></param>
  554. /// <param name="e"></param>
  555. protected override void panlModel_MouseDown(object sender, MouseEventArgs e)
  556. {
  557. //点鼠标右键删除
  558. if (e.Button == MouseButtons.Right)
  559. {
  560. contxtMenu.Items.Clear();
  561. ToolStripMenuItem item = new ToolStripMenuItem();
  562. item.Text = "全部删除";
  563. item.Name = "AllDelete";
  564. contxtMenu.Items.Add(item);
  565. item = new ToolStripMenuItem();
  566. item.Text = "模板设置";
  567. item.Name = "ModelSet";
  568. contxtMenu.Items.Add(item);
  569. lbAddCount = 0;
  570. }
  571. }
  572. /// <summary>
  573. /// 设置文件间隔
  574. /// </summary>
  575. /// <param name="str">文本内容</param>
  576. /// <param name="interval">字符间隔</param>
  577. /// <returns></returns>
  578. private static String SetWordSpacing(String str, int interval)
  579. {
  580. StringBuilder sb = new StringBuilder();
  581. StringBuilder sb1 = new StringBuilder();
  582. for (int i = 0; i < interval; i++)
  583. { sb.Append(" "); }
  584. str = str.Replace(" ", "");
  585. for (int i = 0; i < str.Length; i++)
  586. {
  587. if (i == str.Length - 1)
  588. { sb1.Append(str.Substring(i, 1)); break; }
  589. sb1.Append(str.Substring(i, 1)).Append(sb.ToString());
  590. }
  591. return str = string.Concat(sb1);
  592. }
  593. /// <summary>
  594. /// 清空模板所有参数
  595. /// </summary>
  596. /// <param name="isClearBackImage">是否清除背景图片(true:清除;false:不清除)</param>
  597. private void PanlModelClear(bool isClearBackImage = false)
  598. {
  599. if (isClearBackImage)
  600. { panlModel.BackgroundImage = null; }
  601. panlModel.Controls.Clear();
  602. this.IsPrint = true;
  603. listArray.Clear();
  604. htData_Pitch.Clear();
  605. htData_Money.Clear();
  606. htData_Date.Clear();
  607. htData_Align.Clear();
  608. htData_ToUpper.Clear();
  609. }
  610. /// <summary>
  611. /// 删除模板上的某个控件
  612. /// </summary>
  613. private void ControlRemovelbl(Label lbl)
  614. {
  615. listArray.Remove(lbl.Name);
  616. if (htData_Pitch.ContainsKey(lbl.Name))
  617. { htData_Pitch.Remove(lbl.Name); }
  618. if (htData_Money.ContainsKey(lbl.Name))
  619. { htData_Money.Remove(lbl.Name); }
  620. if (htData_Date.ContainsKey(lbl.Name))
  621. { htData_Date.Remove(lbl.Name); }
  622. if (htData_Align.ContainsKey(lbl.Name))
  623. { htData_Align.Remove(lbl.Name); }
  624. if (htData_ToUpper.ContainsKey(lbl.Name))
  625. { htData_ToUpper.Remove(lbl.Name); }
  626. panlModel.Controls.Remove(lbl);
  627. }
  628. private Label pulb;
  629. const int Band = 5;
  630. const int MinWidth = 10;
  631. const int MinHeight = 10;
  632. private EnumMousePointPosition m_MousePointPosition;
  633. private Point p, p1;
  634. /// <summary>
  635. /// 还原背景颜色
  636. /// </summary>
  637. private void RestoreBackColor()
  638. {
  639. foreach (Control control in panlModel.Controls)
  640. {
  641. if (control is Label)
  642. {
  643. //数组大于0说明有移动过的lbl
  644. if (listArray.Count > 0)
  645. {
  646. foreach (string Strtemp in listArray)
  647. {
  648. if (Strtemp == control.Name)
  649. { control.BackColor = SetBackColor(EnumBackColor.Drag); break; }
  650. else { control.BackColor = SetBackColor(EnumBackColor.Create); }
  651. }
  652. }
  653. else { control.BackColor = SetBackColor(EnumBackColor.Create); }
  654. }
  655. }
  656. }
  657. /// <summary>
  658. /// 在指定坐标上是否有控件存在
  659. /// 如果没有返回false,有则再指定坐标上再加参数,再检索
  660. /// </summary>
  661. /// <param name="c"></param>
  662. /// <returns></returns>
  663. private bool IsTouch(Control c)
  664. {
  665. foreach (Control con in this.panlModel.Controls)
  666. {
  667. //如果在这个范围内,表示此控件会存在覆盖
  668. if (c.Location.X == con.Location.X && c.Location.Y == con.Location.Y)
  669. {
  670. c.Location = new Point(c.Location.X + 4, c.Location.Y + 20);
  671. IsTouch(c);
  672. }
  673. }
  674. return false;
  675. }
  676. /// <summary>
  677. /// 当前选中的Label显示在最上层
  678. /// </summary>
  679. /// <param name="sender"></param>
  680. /// <param name="e"></param>
  681. private void MyClick(object sender, EventArgs e)
  682. {
  683. Label lb = ((Label)sender);
  684. RestoreBackColor();
  685. lb.BackColor = SetBackColor(EnumBackColor.Uppermost);
  686. lb.BringToFront();
  687. }
  688. /// <summary>
  689. /// 定义自己的 MyMouseDown 事件
  690. /// </summary>
  691. /// <param name="sender"></param>
  692. /// <param name="e"></param>
  693. private void MyMouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
  694. {
  695. p.X = e.X; p.Y = e.Y; p1.X = e.X; p1.Y = e.Y;
  696. //点鼠标右键删除
  697. if (e.Button == MouseButtons.Right)
  698. {
  699. Label lb = ((Label)sender);
  700. this.contxtMenu.Items.Clear();
  701. ToolStripMenuItem item = new ToolStripMenuItem();
  702. item.Text = "删除";
  703. item.Name = lb.Name;
  704. this.contxtMenu.Items.Add(item);
  705. item = new ToolStripMenuItem();
  706. item.Text = "设置值";
  707. item.Name = "SetValue";
  708. this.contxtMenu.Items.Add(item);
  709. item = new ToolStripMenuItem();
  710. item.Text = "字体";
  711. item.Name = "Fonts";
  712. this.contxtMenu.Items.Add(item);
  713. item = new ToolStripMenuItem();
  714. item.Text = "字间距";
  715. item.Name = "Spacing";
  716. this.contxtMenu.Items.Add(item);
  717. item = new ToolStripMenuItem();
  718. item.Text = "文字左对齐";
  719. item.Name = "LeftAlign";
  720. this.contxtMenu.Items.Add(item);
  721. item = new ToolStripMenuItem();
  722. item.Text = "文字右对齐";
  723. item.Name = "RightAlign";
  724. this.contxtMenu.Items.Add(item);
  725. if (lb.Tag.ToString().Split('|')[1].Trim() == "DateTime")
  726. {
  727. item = new ToolStripMenuItem();
  728. item.Text = "日期格式设置";
  729. item.Name = "SetDateTime";
  730. this.contxtMenu.Items.Add(item);
  731. }
  732. if (lb.Tag.ToString().Split('|')[1].Trim() == "Decimal")
  733. {
  734. item = new ToolStripMenuItem();
  735. item.Text = "金额格式设置";
  736. item.Name = "SetDecimal";
  737. this.contxtMenu.Items.Add(item);
  738. item = new ToolStripMenuItem();
  739. if (htData_ToUpper.ContainsKey(lb.Name))
  740. {
  741. if (htData_ToUpper[lb.Name].ToString().Trim() == "True")
  742. { item.Text = "小写显示"; }
  743. else { item.Text = "大写显示"; }
  744. }
  745. else { item.Text = "大写显示"; }
  746. item.Name = "ToUpperAmout";
  747. this.contxtMenu.Items.Add(item);
  748. }
  749. if (lb.Tag.ToString().Split('|')[1].Trim() == "Image")
  750. {
  751. item = new ToolStripMenuItem();
  752. item.Text = "图片大小设置";
  753. item.Name = "SetImageSize";
  754. this.contxtMenu.Items.Add(item);
  755. }
  756. this.contxtMenu.RightToLeft = System.Windows.Forms.RightToLeft.No;
  757. pulb = lb;
  758. }
  759. }
  760. /// <summary>
  761. /// 定义自己的 MyMouseEnter 事件
  762. /// </summary>
  763. /// <param name="sender"></param>
  764. /// <param name="e"></param>
  765. private void MyMouseEnter(object sender, System.EventArgs e)
  766. {
  767. try
  768. { Label lCtrl = (sender as Label); lCtrl.BorderStyle = BorderStyle.FixedSingle; }
  769. catch { }
  770. }
  771. /// <summary>
  772. /// 定义自己的 MyMouseLeave 事件
  773. /// </summary>
  774. /// <param name="sender"></param>
  775. /// <param name="e"></param>
  776. private void MyMouseLeave(object sender, System.EventArgs e)
  777. {
  778. m_MousePointPosition = EnumMousePointPosition.MouseSizeNone;
  779. this.Cursor = Cursors.Arrow;
  780. try
  781. { Label lCtrl = (sender as Label); lCtrl.BorderStyle = BorderStyle.None; }
  782. catch { }
  783. }
  784. /// <summary>
  785. /// 设计一个函数,确定光标在控件不同位置的样式
  786. /// </summary>
  787. /// <param name="size"></param>
  788. /// <param name="e"></param>
  789. /// <returns></returns>
  790. private EnumMousePointPosition MousePointPosition(Size size, System.Windows.Forms.MouseEventArgs e)
  791. {
  792. if ((e.X >= -1 * Band) | (e.X <= size.Width) | (e.Y >= -1 * Band) | (e.Y <= size.Height))
  793. {
  794. if (e.X < Band)
  795. {
  796. if (e.Y < Band) { return EnumMousePointPosition.MouseSizeTopLeft; }
  797. else
  798. {
  799. if (e.Y > -1 * Band + size.Height)
  800. { return EnumMousePointPosition.MouseSizeBottomLeft; }
  801. else
  802. { return EnumMousePointPosition.MouseSizeLeft; }
  803. }
  804. }
  805. else
  806. {
  807. if (e.X > -1 * Band + size.Width)
  808. {
  809. if (e.Y < Band)
  810. { return EnumMousePointPosition.MouseSizeTopRight; }
  811. else
  812. {
  813. if (e.Y > -1 * Band + size.Height)
  814. { return EnumMousePointPosition.MouseSizeBottomRight; }
  815. else
  816. { return EnumMousePointPosition.MouseSizeRight; }
  817. }
  818. }
  819. else
  820. {
  821. if (e.Y < Band)
  822. { return EnumMousePointPosition.MouseSizeTop; }
  823. else
  824. {
  825. if (e.Y > -1 * Band + size.Height)
  826. { return EnumMousePointPosition.MouseSizeBottom; }
  827. else
  828. { return EnumMousePointPosition.MouseDrag; }
  829. }
  830. }
  831. }
  832. }
  833. else
  834. { return EnumMousePointPosition.MouseSizeNone; }
  835. }
  836. /// <summary>
  837. /// 定义自己的 MyMouseMove 事件,在这个事件里,会使用上面设计的函数
  838. /// </summary>
  839. /// <param name="sender"></param>
  840. /// <param name="e"></param>
  841. private void MyMouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
  842. {
  843. Control lCtrl = (sender as Control);
  844. if (e.Button == MouseButtons.Left)
  845. {
  846. switch (m_MousePointPosition)
  847. {
  848. case EnumMousePointPosition.MouseDrag:
  849. lCtrl.Left = lCtrl.Left + e.X - p.X;
  850. lCtrl.Top = lCtrl.Top + e.Y - p.Y;
  851. #region 把移动过的lbl写记录
  852. if (e.Clicks == 0)
  853. {
  854. if (listArray.Count <= 0)
  855. { lCtrl.BackColor = SetBackColor(EnumBackColor.Drag); listArray.Add(lCtrl.Name); }
  856. else
  857. {
  858. bool Isbol = true;
  859. foreach (string strtmep in listArray)
  860. {
  861. if (strtmep == lCtrl.Name)
  862. { Isbol = false; break; }
  863. }
  864. if (Isbol)
  865. { lCtrl.BackColor = SetBackColor(EnumBackColor.Drag); listArray.Add(lCtrl.Name); }
  866. }
  867. }
  868. #endregion
  869. break;
  870. case EnumMousePointPosition.MouseSizeBottom:
  871. lCtrl.Height = lCtrl.Height + e.Y - p1.Y;
  872. p1.X = e.X;
  873. p1.Y = e.Y; //'记录光标拖动的当前点
  874. break;
  875. case EnumMousePointPosition.MouseSizeBottomRight:
  876. lCtrl.Width = lCtrl.Width + e.X - p1.X;
  877. lCtrl.Height = lCtrl.Height + e.Y - p1.Y;
  878. p1.X = e.X;
  879. p1.Y = e.Y; //'记录光标拖动的当前点
  880. break;
  881. case EnumMousePointPosition.MouseSizeRight:
  882. lCtrl.Width = lCtrl.Width + e.X - p1.X;
  883. // lCtrl.Height = lCtrl.Height + e.Y - p1.Y;
  884. p1.X = e.X;
  885. p1.Y = e.Y; //'记录光标拖动的当前点
  886. break;
  887. case EnumMousePointPosition.MouseSizeTop:
  888. lCtrl.Top = lCtrl.Top + (e.Y - p.Y);
  889. lCtrl.Height = lCtrl.Height - (e.Y - p.Y);
  890. break;
  891. case EnumMousePointPosition.MouseSizeLeft:
  892. lCtrl.Left = lCtrl.Left + e.X - p.X;
  893. lCtrl.Width = lCtrl.Width - (e.X - p.X);
  894. break;
  895. case EnumMousePointPosition.MouseSizeBottomLeft:
  896. lCtrl.Left = lCtrl.Left + e.X - p.X;
  897. lCtrl.Width = lCtrl.Width - (e.X - p.X);
  898. lCtrl.Height = lCtrl.Height + e.Y - p1.Y;
  899. p1.X = e.X;
  900. p1.Y = e.Y; //'记录光标拖动的当前点
  901. break;
  902. case EnumMousePointPosition.MouseSizeTopRight:
  903. lCtrl.Top = lCtrl.Top + (e.Y - p.Y);
  904. lCtrl.Width = lCtrl.Width + (e.X - p1.X);
  905. lCtrl.Height = lCtrl.Height - (e.Y - p.Y);
  906. p1.X = e.X;
  907. p1.Y = e.Y; //'记录光标拖动的当前点
  908. break;
  909. case EnumMousePointPosition.MouseSizeTopLeft:
  910. lCtrl.Left = lCtrl.Left + e.X - p.X;
  911. lCtrl.Top = lCtrl.Top + (e.Y - p.Y);
  912. lCtrl.Width = lCtrl.Width - (e.X - p.X);
  913. lCtrl.Height = lCtrl.Height - (e.Y - p.Y);
  914. break;
  915. default:
  916. break;
  917. }
  918. if (lCtrl.Width < MinWidth) lCtrl.Width = MinWidth;
  919. if (lCtrl.Height < MinHeight) lCtrl.Height = MinHeight;
  920. }
  921. else
  922. {
  923. m_MousePointPosition = MousePointPosition(lCtrl.Size, e); //'判断光标的位置状态
  924. switch (m_MousePointPosition) //'改变光标
  925. {
  926. case EnumMousePointPosition.MouseSizeNone:
  927. this.Cursor = Cursors.Arrow; //'箭头
  928. break;
  929. case EnumMousePointPosition.MouseDrag:
  930. this.Cursor = Cursors.SizeAll; //'四方向
  931. break;
  932. case EnumMousePointPosition.MouseSizeBottom:
  933. this.Cursor = Cursors.SizeNS; //'南北
  934. break;
  935. case EnumMousePointPosition.MouseSizeTop:
  936. this.Cursor = Cursors.SizeNS; //'南北
  937. break;
  938. case EnumMousePointPosition.MouseSizeLeft:
  939. this.Cursor = Cursors.SizeWE; //'东西
  940. break;
  941. case EnumMousePointPosition.MouseSizeRight:
  942. this.Cursor = Cursors.SizeWE; //'东西
  943. break;
  944. case EnumMousePointPosition.MouseSizeBottomLeft:
  945. this.Cursor = Cursors.SizeNESW; //'东北到南西
  946. break;
  947. case EnumMousePointPosition.MouseSizeBottomRight:
  948. this.Cursor = Cursors.SizeNWSE; //'东南到西北
  949. break;
  950. case EnumMousePointPosition.MouseSizeTopLeft:
  951. this.Cursor = Cursors.SizeNWSE; //'东南到西北
  952. break;
  953. case EnumMousePointPosition.MouseSizeTopRight:
  954. this.Cursor = Cursors.SizeNESW; //'东北到南西
  955. break;
  956. default:
  957. break;
  958. }
  959. }
  960. }
  961. /// <summary>
  962. /// 制作一个初始化过程,将界面 panel1 上的所有控件都绑定 MyMouseDown、 MyMouseLeave、
  963. /// MyMouseMove 事件,记得在 Form 初始化或者 Form_Load 时先执行它。
  964. /// </summary>
  965. private void initProperty()
  966. {
  967. for (int i = 0; i < this.panlModel.Controls.Count; i++)
  968. { SetControlProperty(this.panlModel.Controls[i]); }
  969. }
  970. /// <summary>
  971. /// 写事件
  972. /// </summary>
  973. /// <param name="control"></param>
  974. public void SetControlProperty(Control control)
  975. {
  976. control.MouseDown += new System.Windows.Forms.MouseEventHandler(MyMouseDown);
  977. control.MouseLeave += new System.EventHandler(MyMouseLeave);
  978. control.MouseMove += new System.Windows.Forms.MouseEventHandler(MyMouseMove);
  979. control.MouseEnter += new System.EventHandler(MyMouseEnter);
  980. control.Click += new EventHandler(MyClick);
  981. }
  982. /// <summary>
  983. /// 存储过拖动过的Label
  984. /// </summary>
  985. private ArrayList listArray = new ArrayList();
  986. /// <summary>
  987. /// 返回颜色
  988. /// </summary>
  989. /// <param name="tempEnum">要返回的枚举属性</param>
  990. /// <returns></returns>
  991. private Color SetBackColor(EnumBackColor tempEnum)
  992. {
  993. Color ReturnColor = new Color();
  994. switch (tempEnum)
  995. {
  996. case EnumBackColor.Create: ReturnColor = Color.Gainsboro; break; //创建Label时的背景颜色,说明未拖动过
  997. case EnumBackColor.Drag: ReturnColor = Color.Transparent; break; //拖动后的背景颜色
  998. case EnumBackColor.Uppermost: ReturnColor = Color.LightSkyBlue; break; //当前选中的Label,也就是在最上层的Label
  999. }
  1000. return ReturnColor;
  1001. }
  1002. /// <summary>
  1003. /// 枚举设置背景颜色属性
  1004. /// </summary>
  1005. private enum EnumBackColor
  1006. {
  1007. /// <summary>
  1008. /// Color.Gainsboro
  1009. /// </summary>
  1010. Create, //创建Label时的背景颜色,说明未拖动过
  1011. /// <summary>
  1012. /// Color.Transparent
  1013. /// </summary>
  1014. Drag, //拖动后的背景颜色
  1015. /// <summary>
  1016. /// Color.LightSkyBlue
  1017. /// </summary>
  1018. Uppermost, //当前选中的Label,也就是在最上层的Label
  1019. }
  1020. private void InitializeComponent()
  1021. {
  1022. this.plExMainContainer.SuspendLayout();
  1023. this.plFormMainContent.SuspendLayout();
  1024. this.SuspendLayout();
  1025. //
  1026. // treevListData
  1027. //
  1028. this.treevListData.LineColor = System.Drawing.Color.Black;
  1029. //
  1030. // OrdersReportPrintFormMain
  1031. //
  1032. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  1033. this.ClientSize = new System.Drawing.Size(710, 510);
  1034. this.Name = "OrdersReportPrintFormMain";
  1035. this.Controls.SetChildIndex(this.btnAppFormMaximize, 0);
  1036. this.Controls.SetChildIndex(this.btnAppFormExit, 0);
  1037. this.Controls.SetChildIndex(this.btnAppFormMinimize, 0);
  1038. this.Controls.SetChildIndex(this.btnAppFormMenu, 0);
  1039. this.Controls.SetChildIndex(this.btnAppFormSkin, 0);
  1040. this.Controls.SetChildIndex(this.plFormMainContent, 0);
  1041. this.plExMainContainer.ResumeLayout(false);
  1042. this.plFormMainContent.ResumeLayout(false);
  1043. this.ResumeLayout(false);
  1044. }
  1045. }
  1046. public enum EnumMousePointPosition
  1047. {
  1048. MouseSizeNone = 0, //'无
  1049. MouseSizeRight = 1, //'拉伸右边框
  1050. MouseSizeLeft = 2, //'拉伸左边框
  1051. MouseSizeBottom = 3, //'拉伸下边框
  1052. MouseSizeTop = 4, //'拉伸上边框
  1053. MouseSizeTopLeft = 5, //'拉伸左上角
  1054. MouseSizeTopRight = 6, //'拉伸右上角
  1055. MouseSizeBottomLeft = 7, //'拉伸左下角
  1056. MouseSizeBottomRight = 8, //'拉伸右下角
  1057. MouseDrag = 9 // '鼠标拖动
  1058. }
  1059. }