FrmFrmOrdersReceivables.cs 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835
  1. using LYFZ.ComponentLibrary;
  2. using LYFZ.Software.MainBusiness.FinancialManagement.SetSmallForm;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Windows.Forms;
  12. namespace LYFZ.Software.MainBusiness.FinancialManagement
  13. {
  14. public partial class FrmFrmOrdersReceivables : LYFZ.Software.UI.FinancialManagement.FrmFrmOrdersReceivables
  15. {
  16. private delegate void UpdateControl();
  17. List<LYFZ.Software.MainBusiness.EnumPermissions.BusinessType> Versions = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetBusinessTypeList();
  18. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  19. public FrmFrmOrdersReceivables()
  20. {
  21. this.Load += FrmFrmOrdersReceivables_Load;
  22. this.btnExport.Click += btnExport_Click;
  23. this.btnPrePayment.Click += btnPrePayment_Click;
  24. this.btnLatePayment.Click += btnLatePayment_Click;
  25. this.btnClose.Click += btnClose_Click;
  26. this.btnSlect.Click += btnSlect_Click;
  27. this.btnConditionQuery.Click += btnConditionQuery_Click;
  28. this.chkArrears.Click += chkqk_Click;
  29. this.chkQJ.Click += chkQJ_Click;
  30. this.Shown += FrmFrmOrdersReceivables_Shown;
  31. this.chkDressVersion.Click += chkHs_Click;
  32. this.chkKidsVersion.Click += chkEt_Click;
  33. this.chkPortraitVersion.Click += chkXz_Click;
  34. this.chkFw.Click += chkFw_Click;
  35. this.chkHQ.Click += chkHQ_Click;
  36. this.Resize += FrmFrmOrdersReceivables_Resize;
  37. this.dgvData.CellClick += dgv_CellClick;
  38. this.dgvData.MouseDoubleClick += dgv_MouseDoubleClick;
  39. this.dgvData.ColumnHeaderMouseClick += dgv_ColumnHeaderMouseClick;
  40. this.cmbtreevStoreName.ComboBoxTree_NodeMouseClick += cmbtreevStoreName_ComboBoxTree_NodeMouseClick;
  41. this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging;
  42. this.cmbQueryText.KeyDown += CmbQueryText_KeyDown;
  43. }
  44. private void CmbQueryText_KeyDown(object sender, KeyEventArgs e)
  45. {
  46. if (e.KeyCode == Keys.Enter)
  47. {
  48. btnSlect_Click(null,null);
  49. }
  50. }
  51. int ucPagerEx1_EventPaging(UCPager.EventPagingArg e)
  52. {
  53. //pageData.PageSize = LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ReportFormPageSize;
  54. this.ucPagerEx1.PageSize = LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ReportFormPageSize;
  55. PublicFunctionRows();
  56. return ucPagerEx1.NMax;
  57. }
  58. public void BindPageData(int pageIndx, int pageSize, int totalCount)
  59. {
  60. ucPagerEx1.NMax = totalCount;
  61. ucPagerEx1.CurrentPageCount = (pageSize);
  62. ucPagerEx1.PageCurrent = pageIndx;
  63. }
  64. /// <summary>
  65. /// 查询条件
  66. /// </summary>
  67. private Dictionary<string, string> DictData = new Dictionary<string, string>();
  68. /// <summary>
  69. /// 员工编号
  70. /// </summary>
  71. string StrUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  72. /// <summary>
  73. /// 列表单击事件
  74. /// </summary>
  75. /// <param name="sender"></param>
  76. /// <param name="e"></param>
  77. void dgv_CellClick(object sender, DataGridViewCellEventArgs e)
  78. {
  79. if (this.dgvData.CurrentRow != null)
  80. {
  81. LYFZ.BLL.BLL_ErpOrder.CurrentSelectedOrderNumber = this.dgvData.CurrentRow.Cells["订单号"].Value.ToString().Trim();
  82. }
  83. }
  84. /// <summary>
  85. /// 对列表控件双击事件
  86. /// </summary>
  87. /// <param name="sender"></param>
  88. /// <param name="e"></param>
  89. void dgv_MouseDoubleClick(object sender, MouseEventArgs e)
  90. {
  91. Point hit = this.dgvData.PointToClient(Cursor.Position);
  92. DataGridView.HitTestInfo hitTest = this.dgvData.HitTest(hit.X, hit.Y);
  93. if (hitTest.RowIndex < 0 && hitTest.ColumnIndex < 0)
  94. {
  95. if (!string.IsNullOrEmpty(this.cmbQueryText.Text.Trim()))
  96. {
  97. LYFZ.BLL.BLL_ErpOrder.CurrentSelectedOrderNumber = "";
  98. this.cmbQueryText.Text = "";
  99. //this.PublicFunctionRows();
  100. this.ucPagerEx1.PageCurrent = 1;
  101. this.ucPagerEx1.Bind();
  102. }
  103. }
  104. }
  105. bool IsFirstRun = true;
  106. /// <summary>
  107. /// 窗体加载事件
  108. /// </summary>
  109. /// <param name="sender"></param>
  110. /// <param name="e"></param>
  111. void FrmFrmOrdersReceivables_Load(object sender, EventArgs e)
  112. {
  113. this.PublicFunctionRights();
  114. }
  115. /// <summary>
  116. /// 窗体加载事件
  117. /// </summary>
  118. /// <param name="sender"></param>
  119. /// <param name="e"></param>
  120. void FrmFrmOrdersReceivables_Shown(object sender, EventArgs e)
  121. {
  122. //this.PublicFunctionRows();
  123. this.ucPagerEx1.PageCurrent = 1;
  124. this.ucPagerEx1.Bind();
  125. this.IsFirstRun = false;
  126. this.FrmFrmOrdersReceivables_Resize(this, null);
  127. }
  128. /// <summary>
  129. /// 前期收款
  130. /// </summary>
  131. /// <param name="sender"></param>
  132. /// <param name="e"></param>
  133. void btnPrePayment_Click(object sender, EventArgs e)
  134. {
  135. if (this.dgvData.SelectedRows.Count == 0)
  136. { MessageBoxCustom.Show("请选中你要收款的客户!"); return; }
  137. LYFZ.Software.MainBusiness.FinancialManagement.OrdersReceivables.FrmPrePayment frm = new OrdersReceivables.FrmPrePayment();
  138. frm.IsShowButtonPayment = false;
  139. //frm.StrOrdType = dgv.CurrentRow.Cells["Ord_Type"].Value.ToString();
  140. frm.StrOrdNumber = this.dgvData.CurrentRow.Cells["Ord_Number"].Value.ToString();
  141. //frm.StrCope = Convert.ToDecimal(dgv.CurrentRow.Cells["Cope"].Value);
  142. //frm.StrPaid = Convert.ToDecimal(dgv.CurrentRow.Cells["Paid"].Value);
  143. //frm.StrArrears = Convert.ToDecimal(dgv.CurrentRow.Cells["Arrears"].Value);
  144. frm.ShowDialog();
  145. if (frm.IsSaveed)
  146. {
  147. //this.PublicFunctionRows();
  148. this.ucPagerEx1.PageCurrent = 1;
  149. this.ucPagerEx1.Bind();
  150. }
  151. }
  152. /// <summary>
  153. /// 后期收款
  154. /// </summary>
  155. /// <param name="sender"></param>
  156. /// <param name="e"></param>
  157. void btnLatePayment_Click(object sender, EventArgs e)
  158. {
  159. if (this.dgvData.SelectedRows.Count == 0)
  160. { MessageBoxCustom.Show("请选中你要收款的客户!"); return; }
  161. LYFZ.Software.MainBusiness.FinancialManagement.OrdersReceivables.FrmLatePayment frm = new OrdersReceivables.FrmLatePayment();
  162. frm.StrOrdType = this.dgvData.CurrentRow.Cells["订单类型"].Value.ToString();
  163. frm.StrOrdNumber = this.dgvData.CurrentRow.Cells["Ord_Number"].Value.ToString();
  164. frm.StrCope = Convert.ToDecimal(this.dgvData.CurrentRow.Cells["应付"].Value);
  165. frm.StrPaid = Convert.ToDecimal(this.dgvData.CurrentRow.Cells["已付"].Value);
  166. frm.StrArrears = Convert.ToDecimal(this.dgvData.CurrentRow.Cells["欠款"].Value);
  167. frm.ShowDialog();
  168. if (frm.IsSaveed)
  169. {
  170. //this.PublicFunctionRows();
  171. this.ucPagerEx1.PageCurrent = 1;
  172. this.ucPagerEx1.Bind();
  173. }
  174. }
  175. /// <summary>
  176. /// 列表双击事件
  177. /// </summary>
  178. /// <param name="sender"></param>
  179. /// <param name="e"></param>
  180. void dgv_DoubleClick(object sender, EventArgs e)
  181. {
  182. //try
  183. //{
  184. // if (dgv.Rows.Count > 0)
  185. // {
  186. // #region 订单收款
  187. // if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OrdersReceivablesCompetence, CustomAttributes.OperatingAuthority.OrdersReceivables))
  188. // {
  189. // btnPrePayment.Enabled = true;
  190. // btnLatePayment.Enabled = true;
  191. // }
  192. // else
  193. // {
  194. // btnPrePayment.Enabled = false;
  195. // btnLatePayment.Enabled = false;
  196. // return;
  197. // }
  198. // #endregion
  199. // if (this.dgv.SelectedRows.Count == 0)
  200. // {
  201. // MessageBoxCustom.Show("请选中你要收款的客户!");
  202. // return;
  203. // }
  204. // string Ord_Type = dgv.CurrentRow.Cells["Ord_Type"].Value.ToString();
  205. // if (Ord_Type == "婚纱订单")
  206. // {
  207. // LYFZ.Software.MainBusiness.FinancialManagement.OrdersReceivables.FrmSelectCategory set = new OrdersReceivables.FrmSelectCategory();
  208. // set.Type = "婚纱版";
  209. // set.Ord_Number = dgv.CurrentRow.Cells["Ord_Number"].Value.ToString();
  210. // set.Cope = Convert.ToDecimal(dgv.CurrentRow.Cells["Cope"].Value);
  211. // set.Paid = Convert.ToDecimal(dgv.CurrentRow.Cells["Paid"].Value);
  212. // set.Arrears = Convert.ToDecimal(dgv.CurrentRow.Cells["Arrears"].Value);
  213. // set.ShowDialog();
  214. // if (set.Rx == "ok")
  215. // {
  216. // Bind();
  217. // }
  218. // }
  219. // if (Ord_Type == "儿童订单")
  220. // {
  221. // LYFZ.Software.MainBusiness.FinancialManagement.OrdersReceivables.FrmSelectCategory set = new OrdersReceivables.FrmSelectCategory();
  222. // set.Type = "儿童版";
  223. // set.Ord_Number = dgv.CurrentRow.Cells["Ord_Number"].Value.ToString();
  224. // set.Cope = Convert.ToDecimal(dgv.CurrentRow.Cells["Cope"].Value);
  225. // set.Paid = Convert.ToDecimal(dgv.CurrentRow.Cells["Paid"].Value);
  226. // set.Arrears = Convert.ToDecimal(dgv.CurrentRow.Cells["Arrears"].Value);
  227. // if (set.ShowDialog() == DialogResult.OK)
  228. // {
  229. // Bind();
  230. // }
  231. // }
  232. // if (Ord_Type == "写真订单")
  233. // {
  234. // LYFZ.Software.MainBusiness.FinancialManagement.OrdersReceivables.FrmSelectCategory set = new OrdersReceivables.FrmSelectCategory();
  235. // set.Type = "写真版";
  236. // set.Ord_Number = dgv.CurrentRow.Cells["Ord_Number"].Value.ToString();
  237. // set.Cope = Convert.ToDecimal(dgv.CurrentRow.Cells["Cope"].Value);
  238. // set.Paid = Convert.ToDecimal(dgv.CurrentRow.Cells["Paid"].Value);
  239. // set.Arrears = Convert.ToDecimal(dgv.CurrentRow.Cells["Arrears"].Value);
  240. // if (set.ShowDialog() == DialogResult.OK)
  241. // {
  242. // Bind();
  243. // }
  244. // }
  245. // if (Ord_Type == "服务订单")
  246. // {
  247. // LYFZ.Software.MainBusiness.FinancialManagement.OrdersReceivables.FrmSelectCategory set = new OrdersReceivables.FrmSelectCategory();
  248. // set.Type = "服务版";
  249. // set.Ord_Number = dgv.CurrentRow.Cells["Ord_Number"].Value.ToString();
  250. // set.Cope = Convert.ToDecimal(dgv.CurrentRow.Cells["Cope"].Value);
  251. // set.Paid = Convert.ToDecimal(dgv.CurrentRow.Cells["Paid"].Value);
  252. // set.Arrears = Convert.ToDecimal(dgv.CurrentRow.Cells["Arrears"].Value);
  253. // if (set.ShowDialog() == DialogResult.OK)
  254. // {
  255. // Bind();
  256. // }
  257. // }
  258. // }
  259. //}
  260. //catch (Exception ex) { MessageBoxCustom.Show(ex.Message); }
  261. }
  262. /// <summary>
  263. /// 写真
  264. /// </summary>
  265. /// <param name="sender"></param>
  266. /// <param name="e"></param>
  267. void chkXz_Click(object sender, EventArgs e)
  268. {
  269. if (this.chkPortraitVersion.Checked)
  270. {
  271. this.chkDressVersion.Checked = false;
  272. this.chkKidsVersion.Checked = false;
  273. this.chkFw.Checked = false;
  274. this.chkHQ.Checked = false;
  275. }
  276. this.cmbQueryText.Text = "";
  277. //this.PublicFunctionRows();
  278. this.ucPagerEx1.PageCurrent = 1;
  279. this.ucPagerEx1.Bind();
  280. }
  281. /// <summary>
  282. /// 儿童
  283. /// </summary>
  284. /// <param name="sender"></param>
  285. /// <param name="e"></param>
  286. void chkEt_Click(object sender, EventArgs e)
  287. {
  288. if (this.chkKidsVersion.Checked)
  289. {
  290. this.chkDressVersion.Checked = false;
  291. this.chkFw.Checked = false;
  292. this.chkPortraitVersion.Checked = false;
  293. this.chkHQ.Checked = false;
  294. }
  295. this.cmbQueryText.Text = "";
  296. //this.PublicFunctionRows();
  297. this.ucPagerEx1.PageCurrent = 1;
  298. this.ucPagerEx1.Bind();
  299. }
  300. /// <summary>
  301. /// 婚纱
  302. /// </summary>
  303. /// <param name="sender"></param>
  304. /// <param name="e"></param>
  305. void chkHs_Click(object sender, EventArgs e)
  306. {
  307. if (this.chkDressVersion.Checked)
  308. {
  309. this.chkKidsVersion.Checked = false;
  310. this.chkFw.Checked = false;
  311. this.chkPortraitVersion.Checked = false;
  312. this.chkHQ.Checked = false;
  313. }
  314. //this.PublicFunctionRows();
  315. this.ucPagerEx1.PageCurrent = 1;
  316. this.ucPagerEx1.Bind();
  317. }
  318. /// <summary>
  319. /// 服务
  320. /// </summary>
  321. /// <param name="sender"></param>
  322. /// <param name="e"></param>
  323. void chkFw_Click(object sender, EventArgs e)
  324. {
  325. if (this.chkFw.Checked)
  326. {
  327. this.chkDressVersion.Checked = false;
  328. this.chkKidsVersion.Checked = false;
  329. this.chkPortraitVersion.Checked = false;
  330. this.chkHQ.Checked = false;
  331. }
  332. this.cmbQueryText.Text = "";
  333. //this.PublicFunctionRows();
  334. this.ucPagerEx1.PageCurrent = 1;
  335. this.ucPagerEx1.Bind();
  336. }
  337. /// <summary>
  338. /// 婚庆
  339. /// </summary>
  340. /// <param name="sender"></param>
  341. /// <param name="e"></param>
  342. void chkHQ_Click(object sender, EventArgs e)
  343. {
  344. if (this.chkHQ.Checked)
  345. {
  346. this.chkDressVersion.Checked = false;
  347. this.chkKidsVersion.Checked = false;
  348. this.chkPortraitVersion.Checked = false;
  349. this.chkFw.Checked = false;
  350. }
  351. this.cmbQueryText.Text = "";
  352. //this.PublicFunctionRows();
  353. this.ucPagerEx1.PageCurrent = 1;
  354. this.ucPagerEx1.Bind();
  355. }
  356. /// <summary>
  357. /// 查询
  358. /// </summary>
  359. /// <param name="sender"></param>
  360. /// <param name="e"></param>
  361. void btnSlect_Click(object sender, EventArgs e)
  362. {
  363. this.DictData.Clear();
  364. //this.PublicFunctionRows();
  365. this.ucPagerEx1.PageCurrent = 1;
  366. this.ucPagerEx1.Bind();
  367. }
  368. /// <summary>
  369. /// 条件查询
  370. /// </summary>
  371. /// <param name="sender"></param>
  372. /// <param name="e"></param>
  373. void btnConditionQuery_Click(object sender, EventArgs e)
  374. {
  375. LYFZ.Software.MainBusiness.DoorCityProcess.SetSmallForm.ConditionQuerySamllForm frm = new DoorCityProcess.SetSmallForm.ConditionQuerySamllForm();
  376. frm.LoadType = "订单收款";
  377. frm.ShowDialog();
  378. if (frm.DictDataArray.Count > 0)
  379. {
  380. this.DictData.Clear();
  381. this.cmbQueryText.Text = "";
  382. this.DictData = frm.DictDataArray;
  383. //this.PublicFunctionRows();
  384. this.ucPagerEx1.PageCurrent = 1;
  385. this.ucPagerEx1.Bind();
  386. }
  387. }
  388. /// <summary>
  389. /// 关闭
  390. /// </summary>
  391. /// <param name="sender"></param>
  392. /// <param name="e"></param>
  393. void btnClose_Click(object sender, EventArgs e)
  394. { this.Close(); }
  395. /// <summary>
  396. /// 分店选择查询数据
  397. /// </summary>
  398. /// <param name="sender"></param>
  399. /// <param name="e"></param>
  400. void cmbtreevStoreName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  401. {
  402. this.PublicFunctionRights();
  403. //this.PublicFunctionRows();
  404. this.ucPagerEx1.PageCurrent = 1;
  405. this.ucPagerEx1.Bind();
  406. }
  407. /// <summary>
  408. /// 选择分店获取权限
  409. /// </summary>
  410. void PublicFunctionRights()
  411. {
  412. this.panelEx8.Visible = false;
  413. this.panelEx9.Visible = false;
  414. this.panelEx7.Visible = false;
  415. for (int i = 0; i < Versions.Count; i++)
  416. {
  417. LYFZ.Software.MainBusiness.EnumPermissions.BusinessType Version = Versions[i];
  418. if (Version.ToString() == EnumPermissions.BusinessType.写真版.ToString())
  419. { this.panelEx9.Visible = true; }
  420. if (Version.ToString() == EnumPermissions.BusinessType.婚纱版.ToString())
  421. { this.panelEx7.Visible = true; }
  422. if (Version.ToString() == EnumPermissions.BusinessType.儿童版.ToString())
  423. { this.panelEx8.Visible = true; }
  424. }
  425. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindGroupStoreName(this.cmbtreevStoreName, StrGroupKeyCode: "st015", StrKeyCode: "st016");
  426. if (this.cmbtreevStoreName.Nodes.Count <= 0)
  427. { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindGroupStoreName(this.cmbtreevStoreName, StrKeyCode: "st016"); }
  428. this.btnPrePayment.Enabled = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetGroupStoreRights(this.cmbtreevStoreName, "OrdersReceivablesCompetence", CustomAttributes.OperatingAuthority.OrdersReceivables);
  429. this.btnLatePayment.Enabled = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetGroupStoreRights(this.cmbtreevStoreName, "OrdersReceivablesCompetence", CustomAttributes.OperatingAuthority.OrdersLatePayment);
  430. if (!btnLatePayment.Enabled)
  431. { this.btnLatePayment.Enabled = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetGroupStoreRights(this.cmbtreevStoreName, "OrdersReceivablesCompetence", CustomAttributes.OperatingAuthority.OrdersLatePickGoods); }
  432. this.btnExport.Enabled = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetGroupStoreRights(this.cmbtreevStoreName, "OrdersReceivablesCompetence", CustomAttributes.OperatingAuthority.DataExport);
  433. }
  434. /// <summary>
  435. /// 欠款
  436. /// </summary>
  437. /// <param name="sender"></param>
  438. /// <param name="e"></param>
  439. void chkqk_Click(object sender, EventArgs e)
  440. {
  441. //PublicFunctionRows();
  442. this.ucPagerEx1.PageCurrent = 1;
  443. this.ucPagerEx1.Bind();
  444. }
  445. /// <summary>
  446. /// 取件
  447. /// </summary>
  448. /// <param name="sender"></param>
  449. /// <param name="e"></param>
  450. void chkQJ_Click(object sender, EventArgs e)
  451. {
  452. //PublicFunctionRows();
  453. this.ucPagerEx1.PageCurrent = 1;
  454. this.ucPagerEx1.Bind();
  455. }
  456. /// <summary>
  457. /// 导出
  458. /// </summary>
  459. /// <param name="sender"></param>
  460. /// <param name="e"></param>
  461. void btnExport_Click(object sender, EventArgs e)
  462. {
  463. //this.dgvData.ExportDataTable();
  464. frmExprortSelect frmExprort = new frmExprortSelect();
  465. if(frmExprort.ShowDialog()== DialogResult.OK)
  466. {
  467. DataTable NewTable=null;
  468. string strWhere ="";
  469. if (frmExprort.bcheckType==2)
  470. {
  471. strWhere = " and 1 = 1";
  472. }
  473. else if (frmExprort.bcheckType == 1)
  474. {
  475. strWhere = StrWhere();
  476. }
  477. SaveFileDialog saveFile = new SaveFileDialog();
  478. saveFile.Title = "导出数据报表文件";
  479. saveFile.Filter = "EXECL文件(*.xls) |*.xls |文本文件(*.txt) |*.txt |所有文件(*.*) |*.*";
  480. saveFile.FilterIndex = 1;
  481. DialogResult drst = saveFile.ShowDialog();
  482. if (drst == DialogResult.No || drst == DialogResult.Cancel || drst == DialogResult.No || drst == DialogResult.Abort)
  483. {
  484. return;
  485. }
  486. DataSet dtSet;
  487. string StrGuidName = LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0045.ToString().Trim();
  488. Dictionary<string, string> dictColumns = LYFZ.DAL.DAL_GridViewDisplayIndex.GetGridViewShowColumns(this.StrUserID, StrGuidName, this.dgvData.dgvCurrentColumnOriginalSet);
  489. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
  490. {
  491. dtSet = LYFZ.BLL.BLL_ErpOrderView.GetData_OrderPayment1(dictColumns, strWhere, this.StrSortField);
  492. NewTable = dtSet.Tables[0];
  493. });
  494. // List<string> ColumnNamesList = new List<string>();
  495. // ColumnNamesList.AddRange(dictColumns.Keys);
  496. LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod(delegate (object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
  497. {
  498. try
  499. {
  500. if (LYFZ.WinAPI.CustomPublicMethod.DataGridViewToExcel(saveFile.FileName.Trim(), NewTable, null, backgroundWorker))
  501. {
  502. MessageBoxCustom.Show("数据导出成功!");
  503. }
  504. else
  505. {
  506. MessageBoxCustom.Show("数据导出失败!");
  507. }
  508. }
  509. catch (Exception ex)
  510. {
  511. MessageBoxCustom.Show(String.Format("导出数据出错:{0}", ex.Message));
  512. }
  513. });
  514. /* List<DataTable> sheetList = new List<DataTable>();
  515. if (NewTable.Rows.Count > 60000)
  516. {
  517. int totalPage = (NewTable.Rows.Count / 60000) + ((NewTable.Rows.Count % 60000) > 0 ? 1 : 0);
  518. for (int i = 0; i < totalPage; i++)
  519. {
  520. DataTable dt = new DataTable();
  521. if (i == (totalPage - 1) && (NewTable.Rows.Count % 60000) > 0)
  522. {
  523. dt = NewTable.AsEnumerable().Skip(i * 60000).Take(NewTable.Rows.Count % 60000).CopyToDataTable();
  524. }
  525. else
  526. {
  527. dt = NewTable.AsEnumerable().Skip(i * 60000).Take(60000).CopyToDataTable();
  528. }
  529. sheetList.Add(dt);
  530. }
  531. }
  532. else
  533. {
  534. sheetList.Add(NewTable);
  535. }
  536. if (sheetList.Count > 0)
  537. {
  538. for (int i = 0; i < sheetList.Count; i++)
  539. {
  540. string ext = System.IO.Path.GetExtension(saveFile.FileName.Trim());
  541. string filePath = saveFile.FileName.Trim();
  542. string dirPath = System.IO.Path.GetDirectoryName(saveFile.FileName.Trim());
  543. string fileName = System.IO.Path.GetFileName(saveFile.FileName.Trim());
  544. if (sheetList.Count > 1)
  545. {
  546. filePath = dirPath+ "\\" + fileName.Replace("ext", "") + "(" + (i + 1) + ")" + ext;
  547. }
  548. LYFZ.Command.Command_ExportExcel.DataTable2Sheet(filePath, sheetList[i], "Sheet1", IsCoveredExistingFile: true);
  549. }
  550. MessageBoxCustom.Show("导出成功!");
  551. }
  552. else
  553. {
  554. MessageBoxCustom.Show("导出失败!");
  555. }
  556. */
  557. }
  558. }
  559. /// <summary>
  560. /// 窗体大小发生变化
  561. /// </summary>
  562. /// <param name="sender"></param>
  563. /// <param name="e"></param>
  564. void FrmFrmOrdersReceivables_Resize(object sender, EventArgs e)
  565. {
  566. switch (this.panelArrears.Location.Y)
  567. {
  568. case 4:
  569. this.flowLayoutPanel1.Height = 38;
  570. break;
  571. case 38:
  572. this.flowLayoutPanel1.Height = 70;
  573. break;
  574. }
  575. //if (!this.IsFirstRun)
  576. //{
  577. // int ControlsWidth = 0;
  578. // int ForCount = 0;
  579. // for (int i = 0; i < this.flowLayoutPanel1.Controls.Count; i++)
  580. // {
  581. // if (this.flowLayoutPanel1.Controls[i].Visible)
  582. // {
  583. // ForCount++;
  584. // ControlsWidth += this.flowLayoutPanel1.Controls[i].Width;
  585. // }
  586. // }
  587. // ControlsWidth += ForCount * 5;
  588. // int strWidth = this.Width;
  589. // if (strWidth > ControlsWidth)
  590. // {
  591. // this.flowLayoutPanel1.Height = 40;
  592. // }
  593. // else
  594. // {
  595. // this.flowLayoutPanel1.Height = 70;
  596. // }
  597. //}
  598. }
  599. /// <summary>
  600. /// 点击列标头排序
  601. /// </summary>
  602. /// <param name="sender"></param>
  603. /// <param name="e"></param>
  604. void dgv_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
  605. {
  606. if (e.Button == MouseButtons.Left)
  607. {
  608. string StrColumnName = GetOrderByName(this.dgvData.Columns[e.ColumnIndex].Name.Trim());
  609. if (StrColumnName == this.StrCurrentClickField || string.IsNullOrEmpty(this.StrCurrentClickField))
  610. {
  611. if (this.StrSortOrder == "ASC")
  612. { this.StrSortOrder = "DESC"; }
  613. else
  614. { this.StrSortOrder = "ASC"; }
  615. }
  616. else
  617. { this.StrSortOrder = "DESC"; }
  618. if (!string.IsNullOrEmpty(StrColumnName))
  619. {
  620. this.StrSortField = StrColumnName + " " + this.StrSortOrder;
  621. this.StrCurrentClickField = StrColumnName;
  622. }
  623. //this.PublicFunctionRows();
  624. this.ucPagerEx1.PageCurrent = 1;
  625. this.ucPagerEx1.Bind();
  626. }
  627. }
  628. string GetOrderByName(string StrColumnName)
  629. {
  630. switch (StrColumnName)
  631. {
  632. case "订单号": return "Ord_SinceOrderNumber";
  633. case "客户姓名": return "Cus_Name";
  634. case "客户性别": return "Cus_Sex_cs";
  635. case "客户电话": return "Cus_Telephone";
  636. case "订单类型": return "Ord_Type";
  637. case "接单人": return "Ord_OrderPersonName";
  638. case "套系名称": return "Ord_SeriesName";
  639. case "套系价格": return "Ord_SeriesPrice";
  640. case "加急": return "IsExpedited";
  641. case "加急日期": return "ExpeditedTime";
  642. case "拍摄名称": return "Ordpg_Sights";
  643. case "拍照状态": return "Ordpg_PhotographyStatus";
  644. case "初修师": return "Ordv_EarlyRepairName";
  645. case "初修日期": return "Ordv_EarlyRepairTime";
  646. case "初修状态": return "Ordv_EarlyRepairStatus";
  647. case "选片状态": return "Ordv_FilmSelectionStatus";
  648. case "精修状态": return "Ordv_RefinementStatus";
  649. case "精修日期": return "Ordv_RefinementTime";
  650. case "设计状态": return "Ordv_DesignerStatus";
  651. case "设计师": return "Ordv_DesignerName";
  652. case "设计日期": return "Ordv_DesignerTime";
  653. case "看版师": return "Ordv_LookDesignName";
  654. case "看版日期": return "Ordv_LookDesignTime";
  655. case "看版状态": return "Ordv_LookDesignStatus";
  656. case "看版要求": return "Ordv_LookDesignClaim";
  657. //case "取件状态": return "Ords_ProductPickupIntStatus";
  658. case "相片名称": return "Opps_PhotoName";
  659. case "数量": return "Opps_PhotoQuantity";
  660. case "面积": return "Opps_PhotoArea";
  661. case "发出状态": return "Opps_SendVendor";
  662. case "发出日期": return "Opps_SendTime";
  663. case "返工状态": return "Opps_ReworkStatus";
  664. case "返工日期": return "Opps_ReworkTime";
  665. case "完成状态": return "Opps_CompletedStatus";
  666. case "完成日期": return "Opps_CompletedTime";
  667. case "会员卡号": return "Mc_CradNumber";
  668. default: return "";
  669. }
  670. }
  671. /// <summary>
  672. /// 当前点击的字段
  673. /// </summary>
  674. string StrCurrentClickField = "";
  675. /// <summary>
  676. /// 排序字段
  677. /// </summary>
  678. string StrSortField = "Ord_CreateDateTime DESC";
  679. /// <summary>
  680. /// 排序顺序
  681. /// </summary>
  682. string StrSortOrder = "DESC";
  683. /// <summary>
  684. /// 获取数据
  685. /// </summary>
  686. void PublicFunctionRows()
  687. {
  688. this.dgvData.dgvCurrentColumnOriginalSet = "Ord_Number,订单号,客户姓名,客户电话,应付,前期,后期,已付,欠款,订单类型,套系类别,接单人,套系名称,套系价格,订单时间,取件状态,会员卡号,储值欠款,服务欠款";
  689. string StrGuidName = "";//LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0045.ToString().Trim();
  690. if ((LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.MemberCardShowHide))
  691. {
  692. this.dgvData.dgvFixedHideColumn = "Ord_Number,会员卡号";
  693. }
  694. else
  695. {
  696. this.dgvData.dgvFixedHideColumn = "Ord_Number";
  697. }
  698. this.dgvData.dgvGuidName = StrGuidName;
  699. this.dgvData.dgvUserEmployeeID = this.StrUserID;
  700. Dictionary<string, string> dictColumns = LYFZ.DAL.DAL_GridViewDisplayIndex.GetGridViewShowColumns(this.StrUserID, StrGuidName, this.dgvData.dgvCurrentColumnOriginalSet);
  701. this.dgvData.dictShowColumName = dictColumns;
  702. string StrQueryCondition = "";
  703. StrQueryCondition = StrWhere();
  704. //if (IsFirstRun && !string.IsNullOrEmpty(LYFZ.BLL.BLL_ErpOrder.CurrentSelectedOrderNumber))
  705. //{
  706. // string StrWhere = " And Ord_SinceOrderNumber = '" + LYFZ.BLL.BLL_ErpOrder.CurrentSelectedOrderNumber + "'";
  707. // this.cmbQueryText.Text = LYFZ.BLL.BLL_ErpOrder.CurrentSelectedOrderNumber;
  708. // StrQueryCondition = StrWhere + LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetGroupQueryOrderClickWhere(this.cmbtreevStoreName, "Ord_DividedShop");
  709. //}
  710. //else
  711. //{
  712. // StrQueryCondition = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetGroupQueryWhere(this.cmbtreevStoreName, "Ord_DividedShop");
  713. // if (this.cmbQueryText.Text.Trim().Length > 0)
  714. // { StrQueryCondition += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetQueryTextQueryCondition(this.cmbQueryText.Text.Trim()); }
  715. // else
  716. // {
  717. // if (this.chkQJ.Checked)
  718. // {
  719. // //StrQueryCondition += " And ((select Count(ID) from tb_ErpOrderDigitalStatus where Ords_OrdNumber = Ord_Number) * 2 = (select Sum(Ords_ProductPickupIntStatus) from tb_ErpOrderDigitalStatus where Ords_OrdNumber = Ord_Number))";
  720. // StrQueryCondition += " And asOrderPickupAndServiceStatus.Ords_ProductPickupStatus = 2 ";
  721. // }
  722. // else
  723. // {
  724. // //StrQueryCondition += " And ((select Count(ID) from tb_ErpOrderDigitalStatus where Ords_OrdNumber = Ord_Number) * 2 != (select Sum(Ords_ProductPickupIntStatus) from tb_ErpOrderDigitalStatus where Ords_OrdNumber = Ord_Number))";
  725. // StrQueryCondition += " And asOrderPickupAndServiceStatus.Ords_ProductPickupStatus != 2 ";
  726. // }
  727. // if (this.chkArrears.Checked)
  728. // { StrQueryCondition += " And (套系金额 + isnull(加挑金额, 0) - isnull(收款金额, 0)) > 0"; }
  729. // if (this.chkDressVersion.Checked)
  730. // { StrQueryCondition += " And Ord_Type = '" + Convert.ToInt32(LYFZ.EnumPublic.OrderType.婚纱订单).ToString() + "'"; }
  731. // else if (this.chkKidsVersion.Checked)
  732. // { StrQueryCondition += " And Ord_Type = '" + Convert.ToInt32(LYFZ.EnumPublic.OrderType.儿童订单).ToString() + "'"; }
  733. // else if (this.chkPortraitVersion.Checked)
  734. // { StrQueryCondition += " And Ord_Type = '" + Convert.ToInt32(LYFZ.EnumPublic.OrderType.写真订单).ToString() + "'"; }
  735. // else if (this.chkFw.Checked)
  736. // { StrQueryCondition += " And Ord_Type = '" + Convert.ToInt32(LYFZ.EnumPublic.OrderType.服务订单).ToString() + "'"; }
  737. // else if (this.chkHQ.Checked)
  738. // { StrQueryCondition += " And Ord_Type = '" + Convert.ToInt32(LYFZ.EnumPublic.OrderType.婚庆订单).ToString() + "'"; }
  739. // if (this.DictData.ContainsKey("OrdersPerson") && this.DictData["OrdersPerson"].ToString().Trim().Length > 0)
  740. // { StrQueryCondition += " And Ord_OrderPersonName like '%" + this.DictData["OrdersPerson"].ToString().Trim() + "%'"; }
  741. // if (this.DictData.ContainsKey("CustomerSource") && this.DictData["CustomerSource"].ToString().Trim().Length > 0)
  742. // { StrQueryCondition += " And Ord_CustomerSource like '%" + this.DictData["CustomerSource"].ToString().Trim() + "%'"; }
  743. // #region 订单查询时间;
  744. // if ( this.DictData.ContainsKey("QueryDateTimeStart") && this.DictData.ContainsKey("QueryDateTimeEnd") )
  745. // {
  746. // StrQueryCondition += " And (Ord_CreateDatetime >= '" + this.DictData["QueryDateTimeStart"].ToString() + "' and Ord_CreateDatetime <= '" + this.DictData["QueryDateTimeEnd"].ToString() + "')";
  747. // }
  748. // #endregion
  749. // }
  750. //}
  751. int intTopCount = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPageSize();
  752. Hashtable htData = LYFZ.ComponentLibrary.DataGridOrderView.GetData_OrderPayment(this.dgvData, dictColumns, StrQueryCondition, intTopCount,
  753. this.StrSortField, ucPagerEx1.PageCurrent);
  754. this.dataGridViewStatisticsCount1.LocationX = this.dgvData.RowHeadersWidth;
  755. this.dataGridViewStatisticsCount1.CurrenQuantity = Convert.ToInt32(htData["CurrentCount"].ToString());
  756. this.dataGridViewStatisticsCount1.TotalQuantity = Convert.ToInt32(htData["TotalCount"].ToString());
  757. BindPageData(ucPagerEx1.PageCurrent, Convert.ToInt32(htData["CurrentCount"]), Convert.ToInt32(htData["TotalCount"]));
  758. }
  759. string StrWhere()
  760. {
  761. string StrQueryCondition = "";
  762. if (IsFirstRun && !string.IsNullOrEmpty(LYFZ.BLL.BLL_ErpOrder.CurrentSelectedOrderNumber))
  763. {
  764. string StrWhere = " And Ord_SinceOrderNumber = '" + LYFZ.BLL.BLL_ErpOrder.CurrentSelectedOrderNumber + "'";
  765. this.cmbQueryText.Text = LYFZ.BLL.BLL_ErpOrder.CurrentSelectedOrderNumber;
  766. StrQueryCondition = StrWhere + LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetGroupQueryOrderClickWhere(this.cmbtreevStoreName, "Ord_DividedShop");
  767. }
  768. else
  769. {
  770. StrQueryCondition = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetGroupQueryWhere(this.cmbtreevStoreName, "Ord_DividedShop");
  771. if (this.cmbQueryText.Text.Trim().Length > 0)
  772. { StrQueryCondition += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetQueryTextQueryCondition(this.cmbQueryText.Text.Trim()); }
  773. else
  774. {
  775. if (this.chkQJ.Checked)
  776. {
  777. //StrQueryCondition += " And ((select Count(ID) from tb_ErpOrderDigitalStatus where Ords_OrdNumber = Ord_Number) * 2 = (select Sum(Ords_ProductPickupIntStatus) from tb_ErpOrderDigitalStatus where Ords_OrdNumber = Ord_Number))";
  778. StrQueryCondition += " And asOrderPickupAndServiceStatus.Ords_ProductPickupStatus = 2 ";
  779. }
  780. else
  781. {
  782. //StrQueryCondition += " And ((select Count(ID) from tb_ErpOrderDigitalStatus where Ords_OrdNumber = Ord_Number) * 2 != (select Sum(Ords_ProductPickupIntStatus) from tb_ErpOrderDigitalStatus where Ords_OrdNumber = Ord_Number))";
  783. StrQueryCondition += " And asOrderPickupAndServiceStatus.Ords_ProductPickupStatus != 2 ";
  784. }
  785. if (this.chkArrears.Checked)
  786. { StrQueryCondition += " And (套系金额 + isnull(加挑金额, 0) - isnull(收款金额, 0)) > 0"; }
  787. if (this.chkDressVersion.Checked)
  788. { StrQueryCondition += " And Ord_Type = '" + Convert.ToInt32(LYFZ.EnumPublic.OrderType.婚纱订单).ToString() + "'"; }
  789. else if (this.chkKidsVersion.Checked)
  790. { StrQueryCondition += " And Ord_Type = '" + Convert.ToInt32(LYFZ.EnumPublic.OrderType.儿童订单).ToString() + "'"; }
  791. else if (this.chkPortraitVersion.Checked)
  792. { StrQueryCondition += " And Ord_Type = '" + Convert.ToInt32(LYFZ.EnumPublic.OrderType.写真订单).ToString() + "'"; }
  793. else if (this.chkFw.Checked)
  794. { StrQueryCondition += " And Ord_Type = '" + Convert.ToInt32(LYFZ.EnumPublic.OrderType.服务订单).ToString() + "'"; }
  795. else if (this.chkHQ.Checked)
  796. { StrQueryCondition += " And Ord_Type = '" + Convert.ToInt32(LYFZ.EnumPublic.OrderType.婚庆订单).ToString() + "'"; }
  797. if (this.DictData.ContainsKey("OrdersPerson") && this.DictData["OrdersPerson"].ToString().Trim().Length > 0)
  798. { StrQueryCondition += " And Ord_OrderPersonName like '%" + this.DictData["OrdersPerson"].ToString().Trim() + "%'"; }
  799. if (this.DictData.ContainsKey("CustomerSource") && this.DictData["CustomerSource"].ToString().Trim().Length > 0)
  800. { StrQueryCondition += " And Ord_CustomerSource like '%" + this.DictData["CustomerSource"].ToString().Trim() + "%'"; }
  801. #region 订单查询时间;
  802. if (this.DictData.ContainsKey("QueryDateTimeStart") && this.DictData.ContainsKey("QueryDateTimeEnd"))
  803. {
  804. StrQueryCondition += " And (Ordv_CreateDatetime between '" + this.DictData["QueryDateTimeStart"].ToString() + "' and '" + this.DictData["QueryDateTimeEnd"].ToString() + "')";
  805. }
  806. #endregion
  807. }
  808. }
  809. return StrQueryCondition;
  810. }
  811. }
  812. }