AnalyzedOrderSourceReferralFormMain.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  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.Software.MainBusiness.DecisionAssistant
  10. {
  11. public partial class AnalyzedOrderSourceReferralFormMain : LYFZ.Software.UI.DecisionAssistant.AnalyzedOrderSourceReferralFormMain
  12. {
  13. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  14. public AnalyzedOrderSourceReferralFormMain()
  15. {
  16. this.Load += AnalyzedOrderSourceFormMain_Load;
  17. this.Shown += AnalyzedOrderSourceFormMain_Shown;
  18. this.txtQuery.KeyDown += txtQuery_KeyDown;
  19. this.btnQuery.Click += btnQuery_Click;
  20. this.btnQuery2.Click += btnQuery2_Click;
  21. this.listViewData.MouseDoubleClick += listViewData_MouseDoubleClick;
  22. this.Resize += AnalyzedOrderSourceFormMain_Resize;
  23. this.PictImage.Click += PictImage_Click;
  24. this.PictImage.MouseDoubleClick += PictImage_MouseDoubleClick;
  25. this.listViewData.ColumnClick += listViewData_ColumnClick;
  26. this.btn_export2xls.Click += Btn_export2xls_Click;
  27. }
  28. /// <summary>
  29. /// 导出到xls文件中;
  30. /// </summary>
  31. /// <param name="sender"></param>
  32. /// <param name="e"></param>
  33. private void Btn_export2xls_Click( object sender, EventArgs e )
  34. {
  35. this.listViewData.ListViewToDataTable( "转介绍分析.xls" );
  36. }
  37. /// <summary>
  38. /// 用于排序的类
  39. /// </summary>
  40. LYFZ.ComponentLibrary.ListViewColumnSorter lvwColumnSorter;
  41. /// <summary>
  42. /// 窗体加载事件
  43. /// </summary>
  44. /// <param name="sender"></param>
  45. /// <param name="e"></param>
  46. void AnalyzedOrderSourceFormMain_Load( object sender, EventArgs e )
  47. {
  48. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindGroupStoreName( this.cmbtreevStoreName, StrGroupKeyCode: "stA10", StrKeyCode: "stA18", IsShowAllText: false );
  49. this.listViewData.View = View.Details;
  50. this.listViewData.GridLines = true;
  51. ImageList imgList = new ImageList();
  52. imgList.ImageSize = new Size( 1, 25 );
  53. this.listViewData.SmallImageList = imgList;
  54. string[] StrColumns = "客户姓名,客户电话,介绍次数,成交次数,成交率,成交金额,".Split( ',' );
  55. for ( int i = 0; i < StrColumns.Length; i++ )
  56. {
  57. ColumnHeader ch = new ColumnHeader();
  58. ch.Text = StrColumns[i].Trim();
  59. switch ( StrColumns[i].Trim() )
  60. {
  61. case "": ch.Width = this.listViewData.Width / 4; break;
  62. default: ch.Width = (((this.listViewData.Width / 4) * 3) - 23) / 6; break;
  63. }
  64. switch ( StrColumns[i].Trim() )
  65. {
  66. case "成交金额": ch.TextAlign = HorizontalAlignment.Right; break;
  67. default: ch.TextAlign = HorizontalAlignment.Center; break;
  68. }
  69. this.listViewData.Columns.Add( ch );
  70. }
  71. this.lvwColumnSorter = new ComponentLibrary.ListViewColumnSorter();
  72. this.listViewData.ListViewItemSorter = this.lvwColumnSorter;
  73. }
  74. /// <summary>
  75. /// 窗体加载事件
  76. /// </summary>
  77. /// <param name="sender"></param>
  78. /// <param name="e"></param>
  79. void AnalyzedOrderSourceFormMain_Shown( object sender, EventArgs e )
  80. {
  81. bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion( VersionControl.VersionFunctionEnum.决策助手转介绍分析 );
  82. if ( !b )
  83. {
  84. this.Close();
  85. return;
  86. }
  87. this.PublicFunctionRows();
  88. }
  89. /// <summary>
  90. /// 回车查询事件
  91. /// </summary>
  92. /// <param name="sender"></param>
  93. /// <param name="e"></param>
  94. void txtQuery_KeyDown( object sender, KeyEventArgs e )
  95. {
  96. if ( e.KeyCode == Keys.Enter )
  97. {
  98. this.btnQuery_Click( this, null );
  99. }
  100. }
  101. /// <summary>
  102. /// 查询
  103. /// </summary>
  104. /// <param name="sender"></param>
  105. /// <param name="e"></param>
  106. void btnQuery_Click( object sender, EventArgs e )
  107. {
  108. this.PublicFunctionView();
  109. }
  110. /// <summary>
  111. /// 查询
  112. /// </summary>
  113. /// <param name="sender"></param>
  114. /// <param name="e"></param>
  115. void btnQuery2_Click( object sender, EventArgs e )
  116. {
  117. this.PublicFunctionRows();
  118. }
  119. /// <summary>
  120. /// 列表双击事件
  121. /// </summary>
  122. /// <param name="sender"></param>
  123. /// <param name="e"></param>
  124. void listViewData_MouseDoubleClick( object sender, MouseEventArgs e )
  125. {
  126. if ( this.listViewData.Items.Count > 0 )
  127. {
  128. if ( this.listViewData.SelectedItems.Count > 0 )
  129. {
  130. LYFZ.Software.MainBusiness.DecisionAssistant.SetSmallForm.AnalyzedOrderSourceReferralDetailSmallForm frm = new SetSmallForm.AnalyzedOrderSourceReferralDetailSmallForm();
  131. frm.StrClientNumber = this.listViewData.SelectedItems[0].Tag.ToString().Trim();
  132. frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
  133. frm.Location = new Point( LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y );
  134. frm.Size = new Size( LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height );
  135. frm.Show();
  136. }
  137. }
  138. }
  139. /// <summary>
  140. /// 窗体大小发生变化
  141. /// </summary>
  142. /// <param name="sender"></param>
  143. /// <param name="e"></param>
  144. void AnalyzedOrderSourceFormMain_Resize( object sender, EventArgs e )
  145. {
  146. for ( int i = 0; i < this.listViewData.Columns.Count; i++ )
  147. {
  148. switch ( this.listViewData.Columns[i].Text.Trim() )
  149. {
  150. case "": this.listViewData.Columns[i].Width = this.listViewData.Width / 4; break;
  151. default: this.listViewData.Columns[i].Width = (((this.listViewData.Width / 4) * 3) - 23) / 6; break;
  152. }
  153. }
  154. }
  155. bool IsImageMouseDoubleClick = false;
  156. bool IsCanDoubleClick = false;
  157. /// <summary>
  158. /// 点击图片时,图片获取焦点
  159. /// </summary>
  160. /// <param name="sender"></param>
  161. /// <param name="e"></param>
  162. void PictImage_Click( object sender, EventArgs e )
  163. {
  164. this.PictImage.Focus();
  165. }
  166. /// <summary>
  167. /// 图片双击事件
  168. /// </summary>
  169. /// <param name="sender"></param>
  170. /// <param name="e"></param>
  171. void PictImage_MouseDoubleClick( object sender, MouseEventArgs e )
  172. {
  173. if ( IsCanDoubleClick )
  174. {
  175. if ( !this.IsImageMouseDoubleClick )
  176. {
  177. this.IsImageMouseDoubleClick = true;
  178. this.panelEx3.Visible = false;
  179. this.panelEx2.Height = this.panelEx1.Height - 6;
  180. }
  181. else
  182. {
  183. this.panelEx2.Height = 330;
  184. this.IsImageMouseDoubleClick = false;
  185. this.panelEx3.Visible = true;
  186. }
  187. }
  188. }
  189. /// <summary>
  190. /// 点击排序
  191. /// </summary>
  192. /// <param name="sender"></param>
  193. /// <param name="e"></param>
  194. void listViewData_ColumnClick( object sender, ColumnClickEventArgs e )
  195. {
  196. if ( !string.IsNullOrEmpty( this.listViewData.Columns[e.Column].Text.Trim() ) )
  197. {
  198. // 检查点击的列是不是现在的排序列.
  199. if ( e.Column == lvwColumnSorter.SortColumn )
  200. {
  201. // 重新设置此列的排序方法.
  202. if ( lvwColumnSorter.Order == SortOrder.Ascending )
  203. {
  204. lvwColumnSorter.Order = SortOrder.Descending;
  205. }
  206. else
  207. {
  208. lvwColumnSorter.Order = SortOrder.Ascending;
  209. }
  210. }
  211. else
  212. {
  213. // 设置排序列,默认为正向排序
  214. lvwColumnSorter.SortColumn = e.Column;
  215. lvwColumnSorter.Order = SortOrder.Ascending;
  216. }
  217. // 用新的排序方法对ListView排序
  218. this.listViewData.Sort();
  219. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows( this.listViewData );
  220. }
  221. }
  222. /// <summary>
  223. /// 创建行
  224. /// </summary>
  225. private void PublicFunctionRows()
  226. {
  227. string strWhere = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetGroupQueryWhere( this.cmbtreevStoreName, "Ord_DividedShop" );
  228. string ExecuteSql = "select Count(ID) AS CountID from tb_ErpOrder where 1 = 1 " + strWhere + "; " +
  229. "select Count(tb_ErpCustomerGroup.ID) AS CountID from tb_ErpCustomerGroup Left Join tb_ErpOrder on Ord_Number = GP_OrderNumber Where GP_OrderNumber != '' And GP_IntroducerCustomerID != '' " + strWhere + "; " +
  230. "select Count(tb_ErpCustomerGroup.ID) AS CountID from tb_ErpCustomerGroup Left Join tb_ErpOrder on Ord_Number = GP_OrderNumber Where GP_OrderNumber != '' And GP_IntroducerCustomerID != '' And (GP_CustomerStatus = '正常' or GP_CustomerStatus = '追回')" + strWhere + "";
  231. DataSet dsData = orbll.GetView_Custom( ExecuteSql );
  232. DataTable dtCount = dsData.Tables["ds"];
  233. DataTable dtReferralCount = dsData.Tables["ds1"];
  234. DataTable dtSucceedCount = dsData.Tables["ds2"];
  235. #region 创建画布
  236. Bitmap newBmp = new Bitmap( this.PictImage.Width, this.PictImage.Height );
  237. Graphics g = Graphics.FromImage( newBmp );
  238. g.Clear( System.Drawing.Color.White );
  239. Brush b = Brushes.Black;
  240. Pen p = LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.PenborderColor;
  241. Font ft12b = new Font( "微软雅黑", 12 );
  242. Font ft11b = new Font( "微软雅黑", 11 );
  243. Font ft11 = new Font( "微软雅黑", 11, FontStyle.Italic );
  244. Font ft15 = new Font( "微软雅黑", 15 );
  245. int TopAdd = 7;
  246. int LeftWidth = 30;
  247. int TableWidth = newBmp.Width - LeftWidth * 2;
  248. int ColumnWidth1 = TableWidth / 5;
  249. int ColumnWidth2 = TableWidth / 5;
  250. int ColumnWidth3 = TableWidth / 5;
  251. int ColumnWidth4 = TableWidth / 5;
  252. int ColumnWidth5 = TableWidth / 5;
  253. int RowHeight = 240 / 7;
  254. #endregion
  255. string StrValue = "老客户转介绍统计表";
  256. SizeF sizef = g.MeasureString( StrValue, ft15 );
  257. int FtWidth = Convert.ToInt32( sizef.Width ) + 1;
  258. Rectangle rec = new Rectangle( TableWidth / 2 - FtWidth / 2, 10, FtWidth, Convert.ToInt32( sizef.Height ) );
  259. g.DrawString( StrValue, ft15, b, rec );//画消费法规
  260. #region 标题
  261. Rectangle rec1 = new Rectangle( LeftWidth, rec.Y + rec.Height, TableWidth, RowHeight );
  262. g.DrawRectangle( p, rec1 );//画标题矩形
  263. Rectangle recBackColor1 = new Rectangle( rec1.X + 1, rec1.Y + 1, rec1.Width - 1, rec1.Height - 1 );
  264. g.FillRectangle( LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.backColortitle, recBackColor1 );//画标题矩形
  265. Rectangle rec1_1 = new Rectangle( rec1.X + ColumnWidth1 / 2 - 30, rec1.Y + TopAdd, ColumnWidth1, RowHeight );
  266. g.DrawString( "总订单数", ft12b, LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.btitle, rec1_1 );
  267. Point p11_1 = new Point( rec1.X + ColumnWidth1, rec1.Y );
  268. Point p11_2 = new Point( rec1.X + ColumnWidth1, rec1.Y + rec1.Height );
  269. g.DrawLine( LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.ptitle, p11_1, p11_2 );
  270. Rectangle rec2_1 = new Rectangle( p11_1.X + ColumnWidth2 / 2 - 30, p11_1.Y + TopAdd, ColumnWidth2, RowHeight );
  271. g.DrawString( "转介绍客户数", ft12b, LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.btitle, rec2_1 );
  272. Point p21_1 = new Point( p11_1.X + ColumnWidth2, rec1.Y );
  273. Point p21_2 = new Point( p11_1.X + ColumnWidth2, rec1.Y + rec1.Height );
  274. g.DrawLine( LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.ptitle, p21_1, p21_2 );
  275. Rectangle rec3_1 = new Rectangle( p21_1.X + ColumnWidth3 / 2 - 20, p21_1.Y + TopAdd, ColumnWidth3, RowHeight );
  276. g.DrawString( "转介绍率", ft12b, LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.btitle, rec3_1 );
  277. Point p31_1 = new Point( p21_1.X + ColumnWidth3, rec1.Y );
  278. Point p31_2 = new Point( p21_1.X + ColumnWidth3, rec1.Y + rec1.Height );
  279. g.DrawLine( LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.ptitle, p31_1, p31_2 );
  280. Rectangle rec4_1 = new Rectangle( p31_1.X + ColumnWidth4 / 2 - 20, p31_1.Y + TopAdd, ColumnWidth4, RowHeight );
  281. g.DrawString( "转介绍成交数", ft12b, LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.btitle, rec4_1 );
  282. Point p41_1 = new Point( p31_1.X + ColumnWidth4, rec1.Y );
  283. Point p41_2 = new Point( p31_1.X + ColumnWidth4, rec1.Y + rec1.Height );
  284. g.DrawLine( LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.ptitle, p41_1, p41_2 );
  285. Rectangle rec5_1 = new Rectangle( p41_1.X + ColumnWidth5 / 2 - 20, p41_1.Y + TopAdd, ColumnWidth5, RowHeight );
  286. g.DrawString( "成交率", ft12b, LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.btitle, rec5_1 );
  287. #endregion
  288. #region 内容
  289. decimal CountID = 0;
  290. decimal ReferralCountID = 0;
  291. decimal SucceedCountID = 0;
  292. if ( dtCount.Rows.Count > 0 )
  293. {
  294. CountID = Convert.ToDecimal( dtCount.Rows[0]["CountID"] );
  295. }
  296. if ( dtReferralCount.Rows.Count > 0 )
  297. {
  298. ReferralCountID = Convert.ToDecimal( dtReferralCount.Rows[0]["CountID"] );
  299. }
  300. if ( dtSucceedCount.Rows.Count > 0 )
  301. {
  302. SucceedCountID = Convert.ToDecimal( dtSucceedCount.Rows[0]["CountID"] );
  303. }
  304. Rectangle rec1A = new Rectangle( LeftWidth, rec1.Y + rec1.Height, TableWidth, RowHeight );
  305. g.DrawRectangle( p, rec1A );//画标题矩形
  306. Rectangle rec1AColor1 = new Rectangle( rec1A.X + 1, rec1A.Y + 1, rec1A.Width - 1, rec1A.Height - 1 );
  307. g.FillRectangle( LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.brSingle, rec1AColor1 );
  308. //订单数
  309. sizef = g.MeasureString( LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero( CountID ), ft11 );
  310. FtWidth = Convert.ToInt32( sizef.Width ) + 1;
  311. Rectangle rec1A_1 = new Rectangle( rec1A.X + (ColumnWidth1 - FtWidth) / 2, rec1A.Y + TopAdd, ColumnWidth1, RowHeight );
  312. g.DrawString( LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero( CountID ).ToString().Trim(), ft11, b, rec1A_1 );
  313. Point p11A_1 = new Point( rec1A.X + ColumnWidth1, rec1A.Y );
  314. Point p11A_2 = new Point( rec1A.X + ColumnWidth1, rec1A.Y + rec1A.Height );
  315. g.DrawLine( p, p11A_1, p11A_2 );
  316. //转介绍客户数
  317. sizef = g.MeasureString( LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero( ReferralCountID ), ft11 );
  318. FtWidth = Convert.ToInt32( sizef.Width ) + 1;
  319. Rectangle rec2A_1 = new Rectangle( p11A_1.X + (ColumnWidth2 - FtWidth) / 2, p11A_1.Y + TopAdd, ColumnWidth2, RowHeight );
  320. g.DrawString( LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero( ReferralCountID ), ft11, b, rec2A_1 );
  321. Point p21A_1 = new Point( p11A_1.X + ColumnWidth2, rec1A.Y );
  322. Point p21A_2 = new Point( p11A_1.X + ColumnWidth2, rec1A.Y + rec1A.Height );
  323. g.DrawLine( p, p21A_1, p21A_2 );
  324. //转介绍率
  325. string strValue = "0";
  326. if ( CountID > 0 )
  327. {
  328. strValue = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero( (ReferralCountID / CountID * 100).ToString( "0.00" ) );
  329. }
  330. sizef = g.MeasureString( strValue, ft11 );
  331. FtWidth = Convert.ToInt32( sizef.Width ) + 1;
  332. Rectangle rec3A_1 = new Rectangle( p21A_1.X + (ColumnWidth3 - FtWidth) / 2, p21A_1.Y + TopAdd, ColumnWidth3, RowHeight );
  333. g.DrawString( strValue.Trim() + "%", ft11, b, rec3A_1 );
  334. Point p31A_1 = new Point( p21A_1.X + ColumnWidth3, rec1A.Y );
  335. Point p31A_2 = new Point( p21A_1.X + ColumnWidth3, rec1A.Y + rec1A.Height );
  336. g.DrawLine( p, p31A_1, p31A_2 );
  337. //转介绍成交数
  338. sizef = g.MeasureString( LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero( SucceedCountID ), ft11 );
  339. FtWidth = Convert.ToInt32( sizef.Width ) + 1;
  340. Rectangle rec4A_1 = new Rectangle( p31A_1.X + (ColumnWidth4 - FtWidth) / 2, p31A_1.Y + TopAdd, ColumnWidth4, RowHeight );
  341. g.DrawString( LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero( SucceedCountID ), ft11, b, rec4A_1 );
  342. Point p41A_1 = new Point( p31A_1.X + ColumnWidth4, rec1A.Y );
  343. Point p41A_2 = new Point( p31A_1.X + ColumnWidth4, rec1A.Y + rec1A.Height );
  344. g.DrawLine( p, p41A_1, p41A_2 );
  345. //成交率
  346. string strValue1 = "0";
  347. if ( ReferralCountID > 0 )
  348. {
  349. strValue1 = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero( (ReferralCountID / CountID * 100).ToString( "0.00" ) );
  350. }
  351. sizef = g.MeasureString( strValue1, ft11 );
  352. FtWidth = Convert.ToInt32( sizef.Width ) + 1;
  353. Rectangle rec5A_1 = new Rectangle( p41A_1.X + (ColumnWidth5 - FtWidth) / 2, p41A_1.Y + TopAdd, ColumnWidth5, RowHeight );
  354. g.DrawString( strValue1.Trim() + "%", ft11, b, rec5A_1 );
  355. #endregion
  356. this.PictImage.Image = newBmp;
  357. this.PublicFunctionView();
  358. }
  359. /// <summary>
  360. /// 创建图表
  361. /// </summary>
  362. private void PublicFunctionView()
  363. {
  364. this.listViewData.Items.Clear();
  365. string StrWhereA = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetGroupQueryWhere( this.cmbtreevStoreName, "Ord_DividedShop" );
  366. string StrWhere = "";
  367. string StrQueryText = this.txtQuery.Text.Trim();
  368. if ( !string.IsNullOrEmpty( StrQueryText ) )
  369. {
  370. StrWhere = "And (Cus_Name like '%" + StrQueryText + "%' or Cus_NamePinyin like '%" + StrQueryText + "%' or Cus_Telephone like '%" + StrQueryText + "%')";
  371. }
  372. string ExecuteSql = "with t AS " +
  373. "(" +
  374. "select " + " ROW_NUMBER() OVER (ORDER BY ID ASC) AS tempID, " +
  375. "Cus_CustomerNumber," +
  376. "Cus_Name,Cus_Telephone," +
  377. "(select Count(tb_ErpCustomerGroup.ID) AS CountID from tb_ErpCustomerGroup Left Join tb_ErpOrder on Ord_Number = GP_OrderNumber Where GP_IntroducerCustomerID != '' And GP_IntroducerCustomerID = Cus_CustomerNumber " + StrWhereA + ") AS CountID," +
  378. "(select Count(tb_ErpCustomerGroup.ID) AS CountID from tb_ErpCustomerGroup Left Join tb_ErpOrder on Ord_Number = GP_OrderNumber Where GP_IntroducerCustomerID != '' And GP_IntroducerCustomerID = Cus_CustomerNumber And (GP_CustomerStatus = '正常' or GP_CustomerStatus = '追回')" + StrWhereA + ") AS SucceedCount," +
  379. "(select isnull(Sum(Ord_SeriesPrice),0) AS SumAmount from tb_ErpCustomerGroup Left Join tb_ErpOrder on Ord_Number = GP_OrderNumber Where GP_IntroducerCustomerID != '' And GP_IntroducerCustomerID = Cus_CustomerNumber And (GP_CustomerStatus = '正常' or GP_CustomerStatus = '追回') " + StrWhereA + ") AS SumAmount " +
  380. "from tb_ErpCustomer Where Cus_Type != '儿童' " + StrWhere + " " +
  381. ")" +
  382. "select * from t where CountID > 0";
  383. DataSet dsData = new DataSet();
  384. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod( delegate ( object obj, BackgroundWorker backgroundWorker )
  385. {
  386. dsData = orbll.GetView_Custom( ExecuteSql );
  387. } );
  388. DataTable tbl = dsData.Tables["ds"];
  389. for ( int i = 0; i < tbl.Rows.Count; i++ )
  390. {
  391. ListViewItem lvItem = new ListViewItem();
  392. lvItem.Tag = tbl.Rows[i]["Cus_CustomerNumber"].ToString().Trim();
  393. lvItem.Text = tbl.Rows[i]["Cus_Name"].ToString().Trim();
  394. ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
  395. ListSubItem.Name = "客户电话";
  396. ListSubItem.Text = tbl.Rows[i]["Cus_Telephone"].ToString().Trim();
  397. lvItem.SubItems.Add( ListSubItem );
  398. ListSubItem = new ListViewItem.ListViewSubItem();
  399. ListSubItem.Name = "介绍次数";
  400. ListSubItem.Text = tbl.Rows[i]["CountID"].ToString().Trim();
  401. lvItem.SubItems.Add( ListSubItem );
  402. ListSubItem = new ListViewItem.ListViewSubItem();
  403. ListSubItem.Name = "成交次数";
  404. ListSubItem.Text = tbl.Rows[i]["SucceedCount"].ToString().Trim();
  405. lvItem.SubItems.Add( ListSubItem );
  406. string StrValue = "0";
  407. if ( Convert.ToDecimal( tbl.Rows[i]["CountID"] ) > 0 )
  408. {
  409. StrValue = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero( (Convert.ToDecimal( tbl.Rows[i]["SucceedCount"] ) / Convert.ToDecimal( tbl.Rows[i]["CountID"] ) * 100).ToString( "0.00" ) );
  410. }
  411. ListSubItem = new ListViewItem.ListViewSubItem();
  412. ListSubItem.Name = "成交率";
  413. ListSubItem.Text = StrValue + "%";
  414. lvItem.SubItems.Add( ListSubItem );
  415. ListSubItem = new ListViewItem.ListViewSubItem();
  416. ListSubItem.Name = "成交金额";
  417. ListSubItem.Text = tbl.Rows[i]["SumAmount"].ToString().Trim();
  418. lvItem.SubItems.Add( ListSubItem );
  419. if ( (this.listViewData.Items.Count % 2) > 0 )
  420. {
  421. lvItem.BackColor = System.Drawing.Color.PapayaWhip;
  422. }
  423. else
  424. {
  425. lvItem.BackColor = System.Drawing.Color.PowderBlue;
  426. }
  427. this.listViewData.Items.Add( lvItem );
  428. }
  429. }
  430. }
  431. }