PlanComm.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  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 System.IO;
  10. using System.Collections;
  11. using System.Runtime.Serialization;
  12. using System.Runtime.Serialization.Formatters.Binary;
  13. using Microsoft.Office.Interop.Excel; //APP
  14. using System.Xml;
  15. using System.Data.SqlClient;
  16. using System.Diagnostics;
  17. using System.Reflection; //MISSIN
  18. using Infragistics.Win.UltraWinGrid;
  19. using Infragistics.Win;
  20. using Infragistics.Win.UltraWinGrid.ExcelExport;
  21. using Infragistics.Excel;
  22. using Infragistics.Win.UltraWinDataSource;
  23. using Infragistics.Win.UltraWinEditors;
  24. using Core.Mes.Client.Comm.Server;
  25. using Core.Mes.Client.Comm.Tool;
  26. namespace Core.StlMes.Client.PlnSaleOrd
  27. {
  28. public class PlanComm
  29. {
  30. public static double PI = 3.1415926;
  31. /// <summary>
  32. /// 管米单重计算(t/m)
  33. /// </summary>
  34. /// <param name="outdiameter">外径(mm)</param>
  35. /// <param name="aimwallthick">壁厚(mm)</param>
  36. /// <returns></returns>
  37. public static double WeightOfMi(double outdiameter, double aimwallthick)
  38. {
  39. double weightOfmi = 0.02466 * aimwallthick * (outdiameter - aimwallthick) / 1000;
  40. return weightOfmi;
  41. }
  42. /// <summary>
  43. /// 管坯米单重(t/m)
  44. /// </summary>
  45. /// <param name="outdiameter">管坯断面(mm)</param>
  46. /// <returns></returns>
  47. public static double GpweightOfmi(double outdiameter)
  48. {
  49. return (7.8 * PI / 4 * outdiameter * outdiameter) / 1000 / 1000;
  50. }
  51. /// <summary>
  52. /// 单位英尺长度转米
  53. /// </summary>
  54. /// <param name="lenth">英尺长度</param>
  55. /// <returns>米长度</returns>
  56. public static double FootoMi(double lenth)
  57. {
  58. double converate = 0.3048; //换算率
  59. return Math.Round((lenth * converate), 3);
  60. }
  61. /// <summary>
  62. /// 单位英磅转吨
  63. /// </summary>
  64. /// <param name="weight"></param>
  65. /// <returns></returns>
  66. public static double PoundtoTon(double weight)
  67. {
  68. double converate = 0.45392 / 1000; //换算率
  69. return Math.Round((weight * converate), 3);
  70. }
  71. /// <summary>
  72. /// 导出
  73. /// </summary>
  74. /// <param name="myGrid1"></param>
  75. /// <param name="strFileName"></param>
  76. public static void Export(ref UltraGrid myGrid1, string strFileName)
  77. {
  78. try
  79. {
  80. if (myGrid1.Rows.Count == 0) return;
  81. if (strFileName.Length == 0) strFileName = "未命名";
  82. SaveFileDialog dlg = new SaveFileDialog();
  83. dlg.Title = "保存";
  84. dlg.OverwritePrompt = true;
  85. dlg.Filter = "Excel文件(*.xls)|*.xls";
  86. dlg.AddExtension = true;
  87. dlg.FileName = strFileName;
  88. if (dlg.ShowDialog() == DialogResult.OK)
  89. {
  90. strFileName = dlg.FileName;
  91. using (UltraGridExcelExporter ultraGridExcelExporter1 = new UltraGridExcelExporter())
  92. {
  93. ultraGridExcelExporter1.Export(myGrid1, strFileName);
  94. }
  95. if (MessageBox.Show("数据导出成功!\n需要打开所导出文件吗?", "提示",
  96. MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  97. {
  98. ProcessStartInfo p = new ProcessStartInfo(strFileName);
  99. p.WorkingDirectory = Path.GetDirectoryName(strFileName);
  100. Process.Start(p);
  101. }
  102. }
  103. }
  104. catch (Exception ex)
  105. {
  106. MessageBox.Show(ex.Message);
  107. }
  108. }
  109. /// <summary>
  110. /// 导出
  111. /// </summary>
  112. /// <param name="myGrid1"></param>
  113. /// <param name="strFileName"></param>
  114. /// <param name="GridExcelExporter"></param>
  115. public static void Export(ref UltraGrid myGrid1, string strFileName, UltraGridExcelExporter GridExcelExporter)
  116. {
  117. try
  118. {
  119. if (myGrid1.Rows.Count == 0) return;
  120. if (strFileName.Length == 0) strFileName = "未命名";
  121. SaveFileDialog dlg = new SaveFileDialog();
  122. dlg.Title = "保存";
  123. dlg.OverwritePrompt = true;
  124. dlg.Filter = "Excel文件(*.xls)|*.xls";
  125. dlg.AddExtension = true;
  126. dlg.FileName = strFileName;
  127. if (dlg.ShowDialog() == DialogResult.OK)
  128. {
  129. strFileName = dlg.FileName;
  130. using (UltraGridExcelExporter ultraGridExcelExporter1 = new UltraGridExcelExporter())
  131. {
  132. GridExcelExporter.Export(myGrid1, strFileName);
  133. }
  134. if (MessageBox.Show("数据导出成功!\n需要打开所导出文件吗?", "提示",
  135. MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  136. {
  137. ProcessStartInfo p = new ProcessStartInfo(strFileName);
  138. p.WorkingDirectory = Path.GetDirectoryName(strFileName);
  139. Process.Start(p);
  140. }
  141. }
  142. }
  143. catch (Exception ex)
  144. {
  145. MessageBox.Show(ex.Message);
  146. }
  147. }
  148. /// <summary>
  149. /// 设置grid单元格可编辑
  150. /// </summary>
  151. /// <param name="band">grid表格</param>
  152. /// <param name="strs">可编辑的列头名称数组</param>
  153. public static void setGridActivation(UltraGridBand band, params string[] strs)
  154. {
  155. foreach (UltraGridColumn column in band.Columns)
  156. {
  157. if (!strs.Contains(column.Key))
  158. {
  159. column.CellActivation = Activation.ActivateOnly;
  160. }
  161. else
  162. {
  163. column.CellActivation = Activation.AllowEdit;
  164. column.CellAppearance.BackColor = Color.FromArgb(255, 255, 128);
  165. }
  166. }
  167. }
  168. /// <summary>
  169. /// 表格下拉框,可以有ValueList来提供,可以选择的样式
  170. /// </summary>
  171. /// <param name="table"></param>
  172. /// <param name="strKey"></param>
  173. /// <param name="strText"></param>
  174. /// <returns></returns>
  175. public static ValueList GeneralValuelist(ref System.Data.DataTable table, string strKey, string strText)
  176. {
  177. if (table == null || !table.Columns.Contains(strKey) || !table.Columns.Contains(strText))
  178. {
  179. return null;
  180. }
  181. ArrayList alist = new ArrayList();
  182. ValueList vlist = new ValueList();
  183. for (int i = 0; i < table.Rows.Count; i++)
  184. {
  185. try
  186. {
  187. if (!alist.Contains(table.Rows[i][strKey]))
  188. {
  189. alist.Add(table.Rows[i][strKey]);
  190. vlist.ValueListItems.Add(table.Rows[i][strKey], Convert.ToString(table.Rows[i][strText]));
  191. }
  192. }
  193. catch { }
  194. }
  195. return vlist;
  196. }
  197. /// <summary>
  198. /// 自定义对象深拷贝
  199. /// </summary>
  200. /// <typeparam name="T">类名</typeparam>
  201. /// <param name="RealObject">源对象</param>
  202. /// <returns></returns>
  203. public static T Clone<T>(T RealObject)
  204. {
  205. using (Stream objectStream = new MemoryStream())
  206. {
  207. //利用 System.Runtime.Serialization序列化与反序列化完成引用对象的复制
  208. IFormatter formatter = new BinaryFormatter();
  209. formatter.Serialize(objectStream, RealObject);
  210. objectStream.Seek(0, SeekOrigin.Begin);
  211. return (T)formatter.Deserialize(objectStream);
  212. }
  213. }
  214. /// <summary>
  215. /// 键盘按下Ctrl+D,拷贝活动单元格的数据到所有已勾选的此列的单元格中
  216. /// </summary>
  217. /// <param name="ugrid">UltraGrid</param>
  218. /// <param name="e"></param>
  219. /// <param name="strs">可以进行列名称</param>
  220. public static void setGridCopyActColumn(UltraGrid ugrid, KeyEventArgs e, params string[] strs)
  221. {
  222. if (e.Control && e.KeyCode == Keys.D)
  223. {
  224. if (ugrid != null && ugrid.ActiveRow != null)
  225. {
  226. UltraGridRow ugr = ugrid.ActiveRow;
  227. foreach (string colName in strs)
  228. {
  229. if (ugrid.ActiveCell.Column.Key.Equals(colName))
  230. {
  231. if (ugr.Cells[colName].Activation != Activation.AllowEdit)
  232. {
  233. return;
  234. }
  235. ugrid.UpdateData();
  236. ArrayList list = new ArrayList();
  237. IQueryable<UltraGridRow> checkRows = ugrid.Rows.AsQueryable().Where(" CHECK = 'True' ");
  238. if (checkRows.Count() == 0)
  239. {
  240. return;
  241. }
  242. foreach (UltraGridRow uRow in checkRows)
  243. {
  244. if (uRow != ugr && uRow.Cells[colName].Activation == Activation.AllowEdit)
  245. {
  246. uRow.Cells[colName].Value = ugr.Cells[colName].Value;
  247. }
  248. }
  249. }
  250. }
  251. }
  252. }
  253. }
  254. /// <summary>
  255. /// 键盘按下Ctrl+D,拷贝活动单元格的数据到所有已勾选的此列的单元格中
  256. /// </summary>
  257. /// <param name="ugrid">UltraGrid</param>
  258. /// <param name="key">选择列名(例如"CHC")</param>
  259. /// <param name="e"></param>
  260. /// <param name="strs">可以进行列名称</param>
  261. public static void setGridCopyActColumn(UltraGrid ugrid, string key, KeyEventArgs e, params string[] strs)
  262. {
  263. if (e.Control && e.KeyCode == Keys.D)
  264. {
  265. if (ugrid != null && ugrid.ActiveRow != null)
  266. {
  267. UltraGridRow ugr = ugrid.ActiveRow;
  268. foreach (string colName in strs)
  269. {
  270. if (ugrid.ActiveCell.Column.Key.Equals(colName))
  271. {
  272. if (ugr.Cells[colName].Activation != Activation.AllowEdit)
  273. {
  274. return;
  275. }
  276. ugrid.UpdateData();
  277. ArrayList list = new ArrayList();
  278. IQueryable<UltraGridRow> checkRows = ugrid.Rows.AsQueryable().Where(key + " = 'True'");
  279. if (checkRows.Count() == 0)
  280. {
  281. return;
  282. }
  283. foreach (UltraGridRow uRow in checkRows)
  284. {
  285. if (uRow != ugr && uRow.Cells[colName].Activation == Activation.AllowEdit)
  286. {
  287. uRow.Cells[colName].Value = ugr.Cells[colName].Value;
  288. }
  289. }
  290. }
  291. }
  292. }
  293. }
  294. }
  295. /// <summary>
  296. /// 返回table的column列中是否存在str
  297. /// </summary>
  298. /// <param name="dt">datable</param>
  299. /// <param name="column">列头名</param>
  300. /// <param name="str">匹配字符串</param>
  301. /// <returns></returns>
  302. public static bool isInDataTable(System.Data.DataTable dt, string column, string str)
  303. {
  304. bool isInTable = false;
  305. if (dt == null || column.Equals(""))
  306. {
  307. return isInTable;
  308. }
  309. if (!dt.Columns.Contains(column))
  310. {
  311. return isInTable;
  312. }
  313. foreach(DataRow dr in dt.Rows)
  314. {
  315. if (dr[column].ToString().Equals(str))
  316. {
  317. isInTable = true;
  318. }
  319. }
  320. return isInTable;
  321. }
  322. /// <summary>
  323. /// 复制DataTable到UltraDataBand
  324. /// </summary>
  325. /// <param name="src">源数据</param>
  326. /// <param name="dest">UltraDataBand</param>
  327. /// <param name="ClearExists">是否清除原数据</param>
  328. public static void CopyDataToDataSource(System.Data.DataTable src, UltraDataBand dest, bool ClearExists)
  329. {
  330. if (src == null || dest == null)
  331. {
  332. return;
  333. }
  334. if (ClearExists)
  335. {
  336. dest.DataSource.Rows.Clear();
  337. }
  338. for (int i = 0; i < src.Rows.Count; i++)
  339. {
  340. DataRow CurRow = src.Rows[i];
  341. object[] cellValues = new object[dest.Columns.Count];
  342. for (int j = 0; j < dest.Columns.Count; j++)
  343. {
  344. if (src.Columns.Contains(dest.Columns[j].Key))
  345. {
  346. cellValues[j] = CurRow[j];
  347. }
  348. else
  349. {
  350. cellValues[j] = null;
  351. }
  352. }
  353. dest.DataSource.Rows.Add(cellValues);
  354. }
  355. }
  356. /// <summary>
  357. /// 设置Grid列是数字类型,显示样式
  358. /// </summary>
  359. /// <param name="band">UltraGridBand</param>
  360. /// <param name="maxDigit">数字最大位数(如:99999.99,最大位数5位)</param>
  361. /// <param name="digit">保留小数位数(如:99999.99,保留2位小数)</param>
  362. /// <param name="strs">数字单元列</param>
  363. public static void setGridDigitalCol(UltraGridBand band, int maxDigit, int digit, params string[] strs)
  364. {
  365. if (band == null)
  366. {
  367. return;
  368. }
  369. string maskInput = "-";
  370. if (maxDigit > 0)
  371. {
  372. string str = "";
  373. for (int i = 0; i < maxDigit; i++)
  374. {
  375. if (i != 0 && (i % 3) == 0)
  376. {
  377. str = "," + str;
  378. }
  379. str = "n" + str;
  380. }
  381. maskInput = maskInput + str;
  382. if (digit > 0)
  383. {
  384. maskInput += ".";
  385. for (int i = 0; i < digit; i++)
  386. {
  387. maskInput += "n";
  388. }
  389. }
  390. foreach (UltraGridColumn column in band.Columns)
  391. {
  392. if (strs.Contains(column.Key))
  393. {
  394. column.MaskDisplayMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.IncludeLiterals;
  395. column.MaskInput = maskInput;
  396. column.CellAppearance.TextHAlign = HAlign.Right;
  397. if (digit > 0)
  398. {
  399. column.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Double;
  400. }
  401. else
  402. {
  403. column.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Integer;
  404. }
  405. }
  406. }
  407. }
  408. }
  409. /// <summary>
  410. /// Grid列添加求和统计,设置数字显示样式
  411. /// </summary>
  412. /// <param name="band">UltraGridBand</param>
  413. /// <param name="digit">保留小数位数(如:99999.99,保留2位小数)</param>
  414. /// <param name="strs">添加统计的列头名</param>
  415. public static void setGridSummarySet(UltraGrid grid, int digit, params string[] strs)
  416. {
  417. grid.DisplayLayout.Override.AllowRowSummaries = Infragistics.Win.UltraWinGrid.AllowRowSummaries.Default;
  418. grid.DisplayLayout.Override.AllowRowSummaries = Infragistics.Win.UltraWinGrid.AllowRowSummaries.BasedOnDataType;
  419. for (int i = 0; i < strs.Count(); i++)
  420. {
  421. string columnKey = strs[i];
  422. UltraGridBand band = grid.DisplayLayout.Bands[0];
  423. if (band == null)
  424. {
  425. return;
  426. }
  427. if (!band.Columns.Exists(columnKey))
  428. {
  429. continue;
  430. }
  431. if (band.Summaries.Exists(columnKey))
  432. {
  433. continue;
  434. }
  435. SummarySettings sumColumn = band.Summaries.Add(columnKey, SummaryType.Sum,
  436. band.Columns[columnKey], SummaryPosition.UseSummaryPositionColumn);
  437. sumColumn.DisplayFormat = "{0:N" + digit + "}";
  438. sumColumn.Appearance.TextHAlign = HAlign.Right;
  439. }
  440. grid.DisplayLayout.Override.SummaryFooterCaptionVisible = Infragistics.Win.DefaultableBoolean.False;
  441. }
  442. /// <summary>
  443. /// 加载基础数据到下拉框中
  444. /// </summary>
  445. /// <param name="cmb">下拉框</param>
  446. /// <param name="dt">源DataTable</param>
  447. /// <param name="strCode">数据值</param>
  448. /// <param name="strName">数据显示</param>
  449. /// <param name="hasBlankLine">是否包含空行</param>
  450. /// <returns></returns>
  451. public static bool FillComBaseInfo(UltraComboEditor cmb, System.Data.DataTable dt,
  452. string strValue, string strName, bool hasBlankLine)
  453. {
  454. if (hasBlankLine && dt != null && dt.Rows.Count > 0)
  455. {
  456. DataRow dr = dt.NewRow();
  457. dt.Rows.InsertAt(dr, 0);
  458. }
  459. cmb.DataSource = dt;
  460. cmb.DisplayMember = strName;
  461. cmb.ValueMember = strValue;
  462. ClsBaseInfo.SetComboItemHeight(cmb);
  463. return true;
  464. }
  465. /// <summary>
  466. /// 等待窗口
  467. /// </summary>
  468. public static void WaitFromOpen(Cursor cursor)
  469. {
  470. cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
  471. if (Constant.WaitingForm == null)
  472. {
  473. Constant.WaitingForm = new WaitingForm();
  474. }
  475. Constant.WaitingForm.ShowToUser = true;
  476. Constant.WaitingForm.Show();
  477. Constant.WaitingForm.Update();
  478. }
  479. /// <summary>
  480. /// 关闭等待
  481. /// </summary>
  482. public static void WaitFromColse(Cursor cursor)
  483. {
  484. cursor = Cursors.Default;
  485. Constant.WaitingForm.ShowToUser = false;
  486. Constant.WaitingForm.Close();
  487. Constant.WaitingForm = null;
  488. }
  489. /// <summary>
  490. //byWenCheng 设置grid的band的列名和描述(列名和描述来自数据库的列名和描述)
  491. /// </summary>
  492. /// <param name="band">需要设置的grid的band</param>
  493. /// <param name="tablename">与band对应的表名</param>
  494. /// <param name="ob">OpenBase对象</param>
  495. public static void SetColandCaption(Infragistics.Win.UltraWinGrid.UltraGridBand band, string tablename,CoreFS.CA06.OpeBase ob)
  496. {
  497. if (band == null)
  498. {
  499. return;
  500. }
  501. System.Data.DataTable dt = GetDataBySql(string.Format(@"select column_name,comments from user_col_comments where table_name = '{0}'", tablename),ob);
  502. if (dt.Rows.Count > 0)
  503. {
  504. foreach (DataRow row in dt.Rows)
  505. {
  506. band.Columns.Add(row[0].ToString(), row[1].ToString());
  507. }
  508. }
  509. }
  510. /// <summary>
  511. ///byWenCheng 执行sql语句
  512. /// </summary>
  513. /// <param name="sqlString"></param>
  514. /// <param name="_ob"></param>
  515. /// <returns></returns>
  516. public static System.Data.DataTable GetDataBySql(string sqlString,CoreFS.CA06.OpeBase _ob)
  517. {
  518. return Core.Mes.Client.Comm.Server.ServerHelper.GetData("com.steering.pss.plnsaleord.ordAmCal.OrderDemo.getDataBySql", new Object[] { sqlString }, _ob);
  519. }
  520. /// <summary>
  521. ///byWenCheng 设置某band的所有列不可编辑,除了ignoreColums里包含的列
  522. /// </summary>
  523. /// <param name="band">需要设置的band</param>
  524. /// <param name="ignoreColums">需要忽略的列</param>
  525. public static void SetGridColNoEdit(Infragistics.Win.UltraWinGrid.UltraGridBand band, string[] ignoreColums)
  526. {
  527. foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn col in band.Columns)
  528. {
  529. if (ignoreColums.Length > 0 && !string.IsNullOrEmpty(ignoreColums.FirstOrDefault(c => c == col.Key)))
  530. {
  531. col.CellAppearance.BackColor = System.Drawing.Color.Yellow;
  532. continue;
  533. }
  534. col.CellActivation = Infragistics.Win.UltraWinGrid.Activation.NoEdit;
  535. }
  536. }
  537. /// <summary>
  538. /// byWenCheng,复制数据到数据表,暂未测试速率,目前发现在查询数据时比较耗时,2000条数据2-3s
  539. /// </summary>
  540. /// <param name="srcDt"></param>
  541. /// <param name="desDt"></param>
  542. /// <param name="ClearExsit"></param>
  543. public static void CopyDatabyDatatable(System.Data.DataTable srcDt,System.Data.DataTable desDt, bool ClearExsit)
  544. {
  545. if (srcDt.Rows.Count <= 0)
  546. {
  547. return;
  548. }
  549. if (ClearExsit)
  550. {
  551. desDt.Rows.Clear();
  552. }
  553. foreach (DataRow row in srcDt.Rows)
  554. {
  555. desDt.LoadDataRow(row.ItemArray, false);
  556. }
  557. }
  558. /// <summary>
  559. ///byWenCheng 设置列宽根据内容自适应方法1
  560. /// </summary>
  561. /// <param name="band">需要设置的band</param>
  562. public static void SetColumnAutoFitSize1(UltraGridBand band)
  563. {
  564. if (band != null)
  565. {
  566. band.PerformAutoResizeColumns(true, PerformAutoSizeType.VisibleRows);
  567. }
  568. }
  569. /// <summary>
  570. ///byWenCheng 设置列宽根据内容自适应方法2
  571. /// </summary>
  572. /// <param name="band">需要设置的band</param>
  573. public static void SetColumnAutoFitSize2(UltraGridBand band)
  574. {
  575. if (band != null)
  576. {
  577. foreach (UltraGridColumn col in band.Columns)
  578. {
  579. col.PerformAutoResize();
  580. }
  581. }
  582. }
  583. /// <summary>
  584. ///byWenCheng 设置行高根据内容自适应
  585. /// </summary>
  586. /// <param name="grid"></param>
  587. public static void SetRowAutoFitSize(UltraGrid grid)
  588. {
  589. if(grid != null)
  590. {
  591. grid.DisplayLayout.Override.RowSizing = RowSizing.AutoFree;
  592. }
  593. }
  594. /// <summary>
  595. ///byWenCheng 获取grid的激活的行,如果该行有对应的父行,则取其父行。和selected选择的行有区别的是,selectedrow是可以有多行,activedrow只能是一行,而且一般是最后选择的那一行
  596. /// </summary>
  597. /// <param name="grid"></param>
  598. /// <returns></returns>
  599. public static UltraGridRow GetActiveRow(UltraGrid grid)
  600. {
  601. if (grid == null || grid.ActiveRow == null)
  602. {
  603. return null;
  604. }
  605. UltraGridRow ugr = grid.ActiveRow;
  606. if (ugr.HasParent())
  607. {
  608. ugr = ugr.ParentRow;
  609. }
  610. return ugr;
  611. }
  612. /// <summary>
  613. /// byWencheng,获取小数点后指定位数的double值
  614. /// </summary>
  615. /// <param name="dsrc">源double</param>
  616. /// <param name="nBit">指定小数点后的位数</param>
  617. /// <returns>结果值</returns>
  618. public static double GetSpecDecimalBit(double dsrc,int nBit)
  619. {
  620. return Convert.ToDouble(dsrc.ToString(string.Format("f{0}",nBit)));
  621. }
  622. }
  623. }