frmWageStatisticsQuery.cs 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107
  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.BLL;
  10. using System.Collections;
  11. namespace LYFZ.Software.MainBusiness.FinancialManagement
  12. {
  13. public partial class frmWageStatisticsQuery : LYFZ.Software.UI.FinancialManagement.frmWageStatisticsQuery
  14. {
  15. public frmWageStatisticsQuery()
  16. {
  17. this.btntest.Click += btntest_Click;
  18. this.Shown += frmWageStatisticsQuery_Shown;
  19. // this.cmbEmployeeName.ComboBoxTree_NodeMouseClick+=cmbEmployeeName_ComboBoxTree_NodeMouseClick;
  20. this.Load += frmWageStatisticsQuery_Load;
  21. this.btnClosed.Click += bntClosed_Click;
  22. this.btnQuery.Click += btnQuery_Click;
  23. this.btnExport.Click += btnExport_Click;
  24. this.txtTimeStart.ValueChanged += txtTimeStart_ValueChanged;
  25. this.txtTimeEnd.ValueChanged += txtTimeEnd_ValueChanged;
  26. this.dgvStatisticsList.EraseCell = true;
  27. this.btnProgramSetting.Click += btnProgramSetting_Click;
  28. this.dgvStatisticsList.CellDoubleClick += dgvStatisticsList_CellDoubleClick;
  29. this.btnDataStatisticsQuery.Click += btnDataStatisticsQuery_Click;
  30. this.cbxStoreList.SelectedIndexChanged += cbxStoreList_SelectedIndexChanged;
  31. this.btnViews.Click += btnViews_Click;
  32. }
  33. /// <summary>
  34. /// 查看详细
  35. /// </summary>
  36. /// <param name="sender"></param>
  37. /// <param name="e"></param>
  38. void btnViews_Click(object sender, EventArgs e)
  39. {
  40. frmWageStatisticsViewList frmWSViewList = new frmWageStatisticsViewList();
  41. frmWSViewList.StartDateTime = this.StartDateTime;
  42. frmWSViewList.EndDateTime = this.EndDateTime;
  43. frmWSViewList.UserWageStatisticsPerformanceCommissionList.AddRange(this.UserWageStatisticsPerformanceCommissionList.ToArray());
  44. frmWSViewList.Show();
  45. }
  46. /// <summary>
  47. /// 导出
  48. /// </summary>
  49. /// <param name="sender"></param>
  50. /// <param name="e"></param>
  51. void btnExport_Click(object sender, EventArgs e)
  52. {
  53. this.dgvStatisticsList.ExportDataTable();
  54. }
  55. void cbxStoreList_SelectedIndexChanged(object sender, EventArgs e)
  56. {
  57. RefreshDataStatisticsQuery();
  58. }
  59. /// <summary>
  60. /// 工资统计处理类
  61. /// </summary>
  62. WageStatisticsProcess WSP_WageStatisticsProcess = new WageStatisticsProcess();
  63. /// <summary>
  64. /// 订单信息总订单数统计处理类
  65. /// </summary>
  66. WageStatisticsOrderInfo WSO_WageStatisticsOrderInfo = new WageStatisticsOrderInfo();
  67. /// <summary>
  68. /// 订单信息当前阶段订单数统计处理类
  69. /// </summary>
  70. WageStatisticsOrderInfo WSO_WageStatisticsCurrentOrderInfo = new WageStatisticsOrderInfo();
  71. string WageStatisticsInfo = "";
  72. /// <summary>
  73. /// 加载工资统计基础数据
  74. /// </summary>
  75. void LoadBasisWageStatisticsDataTable(BackgroundWorker backgroundWorker)
  76. {
  77. WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.WageStatisticsOrderTable);
  78. WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.RelatedOrderCount);
  79. WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.CurrentRelatedOrderCount);
  80. WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.WageStatisticsOrderReceiptRecordTable);
  81. WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.WageStatisticsSatisfactionScoreTable);
  82. WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.DressRentalRecordsTable);
  83. WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.OtherConsumptionRecordTable);
  84. WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.PieceCommissionRecordTable);
  85. WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.MemberCardRechargeRecordTable);
  86. WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.MemberCardPaymentRecordTable);
  87. WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.AttractionsLevelStatisticsTable);
  88. WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.AttractionsPersonnelStatisticsTable);
  89. System.GC.Collect();
  90. LYFZ.BLL.BLL_ErpWageCommissionSet.UpdateCommissionSet();
  91. LYFZ.BLL.BLL_ErpCommissionPercentage.LoadCommissionPercentageTable();
  92. backgroundWorker.ReportProgress(0, "正获取订单信息...");
  93. this.WSP_WageStatisticsProcess.WageStatisticsOrderTable = WageStatisticsProcess.GetPROCE_WageStatisticsOrder(this.StartDateTime, this.EndDateTime, this.CurrentQueryStoreList);
  94. backgroundWorker.ReportProgress(0, "正统计本次相关订单数...");
  95. this.WSP_WageStatisticsProcess.RelatedOrderCount = WageStatisticsProcess.GetRelatedOrderCount(this.StartDateTime, this.EndDateTime, this.CurrentQueryStoreList);
  96. backgroundWorker.ReportProgress(0, "正统计本次新订单数...");
  97. this.WSP_WageStatisticsProcess.CurrentRelatedOrderCount = WageStatisticsProcess.GetCurrentRelatedOrderCount(this.StartDateTime, this.EndDateTime, this.CurrentQueryStoreList);
  98. backgroundWorker.ReportProgress(0, "正获取订单收款记录...");
  99. this.WSP_WageStatisticsProcess.WageStatisticsOrderReceiptRecordTable = WageStatisticsProcess.GetPROCE_WageStatisticsOrderReceiptRecord(this.StartDateTime, this.EndDateTime, this.CurrentQueryStoreList);
  100. if (this.chkSatisfaction.Checked)
  101. {
  102. backgroundWorker.ReportProgress(0, "正获取订单满意度分值...");
  103. this.WSP_WageStatisticsProcess.WageStatisticsSatisfactionScoreTable = WageStatisticsProcess.GetPROCE_WageStatisticsSatisfactionScore(this.StartDateTime, this.EndDateTime);
  104. }
  105. backgroundWorker.ReportProgress(0, "正获取礼服租售记录...");
  106. this.WSP_WageStatisticsProcess.DressRentalRecordsTable = WageStatisticsProcess.GetDressRentalRecords(this.StartDateTime, this.EndDateTime, this.CurrentQueryStoreList);
  107. backgroundWorker.ReportProgress(0, "正获取其它销费记录...");
  108. this.WSP_WageStatisticsProcess.OtherConsumptionRecordTable = WageStatisticsProcess.GetOtherConsumptionRecords(this.StartDateTime, this.EndDateTime, this.CurrentQueryStoreList);
  109. backgroundWorker.ReportProgress(0, "正获取计件提成记录...");
  110. this.WSP_WageStatisticsProcess.PieceCommissionRecordTable = WageStatisticsProcess.GetPieceCommissionRecords(this.StartDateTime, this.EndDateTime, this.CurrentQueryStoreList);
  111. backgroundWorker.ReportProgress(0, "正获取计件提成订单记录...");
  112. this.WSP_WageStatisticsProcess.PieceCommissionRecordOrderList = WageStatisticsProcess.GetPieceCommissionRecordOrderList(this.StartDateTime, this.EndDateTime, this.CurrentQueryStoreList);
  113. backgroundWorker.ReportProgress(0, "正获取会员卡充值记录...");
  114. this.WSP_WageStatisticsProcess.MemberCardRechargeRecordTable = WageStatisticsProcess.GetMemberCardRechargeRecord(this.StartDateTime, this.EndDateTime, this.CurrentQueryStoreList);
  115. backgroundWorker.ReportProgress(0, "正获取会员服务卡收款...");
  116. this.WSP_WageStatisticsProcess.MemberCardPaymentRecordTable = WageStatisticsProcess.GetMemberCardPaymentRecord(this.StartDateTime, this.EndDateTime, this.CurrentQueryStoreList);
  117. backgroundWorker.ReportProgress(0, "正获取景点和阶段人员信息...");
  118. this.WSP_WageStatisticsProcess.AttractionsLevelStatisticsTable = WageStatisticsProcess.GetAttractionsLevelStatistics(this.StartDateTime, this.EndDateTime);
  119. backgroundWorker.ReportProgress(0, "正获取景点和阶段等级信息...");
  120. this.WSP_WageStatisticsProcess.AttractionsPersonnelStatisticsTable = WageStatisticsProcess.GetAttractionsPersonnelStatistics(this.StartDateTime, this.EndDateTime);
  121. }
  122. /// <summary>
  123. /// 要统计的基础数据是否已统计加载
  124. /// </summary>
  125. bool isDataStatisticsQuery = false;
  126. string DataStatisticsQueryTimestamp = "";
  127. string GetDataStatisticsQueryTimestamp()
  128. {
  129. return this.StartDateTime.ToString("yyyy-MM-dd") + this.EndDateTime.AddDays(1).ToString("yyyy-MM-dd") + this.CurrentQueryStoreList.QueryType.ToString() + WageStatisticsProcess.GetQueryStoreList(this.CurrentQueryStoreList);
  130. }
  131. /// <summary>
  132. /// 刷新基础数据加载状态 标记是否需要重新加载基础数据
  133. /// </summary>
  134. void RefreshDataStatisticsQuery()
  135. {
  136. GetCurrentQueryStoreList();
  137. GetTimePeriod();
  138. string newDataStatisticsQueryTimestamp = GetDataStatisticsQueryTimestamp();
  139. if (string.IsNullOrEmpty(DataStatisticsQueryTimestamp))
  140. {
  141. isDataStatisticsQuery = false;
  142. }
  143. else {
  144. if (DataStatisticsQueryTimestamp.Trim().ToLower() != newDataStatisticsQueryTimestamp.Trim().ToLower())
  145. {
  146. isDataStatisticsQuery = false;
  147. }
  148. else {
  149. isDataStatisticsQuery = true;
  150. }
  151. }
  152. this.lbDataStatisticsQueryInfo.ForeColor = Color.Teal;
  153. if (!isDataStatisticsQuery)
  154. {
  155. this.lbDataStatisticsQueryInfo.ForeColor = Color.Red;
  156. if (this.WSP_WageStatisticsProcess.DressRentalRecordsTable == null)
  157. {
  158. this.lbDataStatisticsQueryInfo.Text = "未统计数据";
  159. }
  160. else
  161. {
  162. if (IsStoreNode(this.cmbEmployeeName.TreeView.Nodes))
  163. {
  164. this.lbDataStatisticsQueryInfo.Text = "统计时间和门店已改变,需要重新进行“数据统计查询”才能准确计算业绩和提成";
  165. }
  166. else
  167. {
  168. this.lbDataStatisticsQueryInfo.Text = "统计时间已改变,需要重新进行“数据统计查询”才能准确计算业绩和提成";
  169. }
  170. }
  171. }
  172. else {
  173. this.lbDataStatisticsQueryInfo.Text = WageStatisticsInfo;
  174. }
  175. }
  176. /// <summary>
  177. /// 统计查询工资基出数据
  178. /// </summary>
  179. /// <param name="sender"></param>
  180. /// <param name="e"></param>
  181. void btnDataStatisticsQuery_Click(object sender, EventArgs e)
  182. {
  183. GetEmployeeBasicQueryUserList();
  184. GetCurrentQueryStoreList();
  185. GetTimePeriod();
  186. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
  187. {
  188. try
  189. {
  190. backgroundWorker.ReportProgress(0, "正获取项目类别...");
  191. frmEditStatisticsProgram.LoadAllSystemCategory();
  192. backgroundWorker.ReportProgress(0, "正获取基本工资...");
  193. LoadWagesSetDataTable();
  194. backgroundWorker.ReportProgress(0, "正获取奖罚金额...");
  195. LoadRewardPunishment(StartDateTime, EndDateTime);
  196. LoadBasisWageStatisticsDataTable(backgroundWorker);
  197. if (WSO_WageStatisticsOrderInfo != null)
  198. {
  199. WSO_WageStatisticsOrderInfo = null;
  200. }
  201. if (WSO_WageStatisticsCurrentOrderInfo != null)
  202. {
  203. WSO_WageStatisticsCurrentOrderInfo = null;
  204. }
  205. backgroundWorker.ReportProgress(0, "正在统计订单...");
  206. WSO_WageStatisticsOrderInfo = new WageStatisticsOrderInfo(WSP_WageStatisticsProcess.RelatedOrderCount);//统计相关总订单数信息
  207. WSO_WageStatisticsCurrentOrderInfo = new WageStatisticsOrderInfo(WSP_WageStatisticsProcess.CurrentRelatedOrderCount);//统计相关总订单数信息
  208. DataStatisticsQueryTimestamp = GetDataStatisticsQueryTimestamp();
  209. }
  210. catch(Exception ex) {
  211. MessageBoxCustom.Show(ex.Message);
  212. }
  213. });
  214. WageStatisticsInfo = WSO_WageStatisticsOrderInfo.ToString() + "\r\n" + WSO_WageStatisticsCurrentOrderInfo.ToString("在统计时间内的订单数");
  215. RefreshDataStatisticsQuery();
  216. }
  217. void dgvStatisticsList_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  218. {
  219. if (e.RowIndex >= 0 && e.ColumnIndex == 2)
  220. {
  221. if (this.dgvStatisticsList.Rows[e.RowIndex].Tag != null)
  222. {
  223. frmWageQueryConfig frmWQC = new frmWageQueryConfig();
  224. frmWQC.CurrentUser_EmployeeID = this.dgvStatisticsList.Rows[e.RowIndex].Tag.ToString();
  225. frmWQC.ShowDialog();
  226. }
  227. }
  228. }
  229. void btnProgramSetting_Click(object sender, EventArgs e)
  230. {
  231. frmWageQueryConfig frmWQC = new frmWageQueryConfig();
  232. frmWQC.ShowDialog();
  233. }
  234. #region 窗体首次加载和显示事件
  235. void frmWageStatisticsQuery_Load(object sender, EventArgs e)
  236. {
  237. this.dgvStatisticsList.Columns[0].Visible = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.IsGroupEdition;
  238. HideORShowStoresList(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.IsGroupEdition);
  239. }
  240. void frmWageStatisticsQuery_Shown(object sender, EventArgs e)
  241. {
  242. // 部门人员绑定
  243. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_DepartmentAndEmployee(this.cmbEmployeeName, IsFirstNodeNull: true, IsFirstNodeName: "全部", IsShowResign: false, IsShowAdmin: true, tb_User: LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable);
  244. // 查看
  245. this.cmbEmployeeName.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StatisticalInquiryAllWagesCompetence, CustomAttributes.OperatingAuthority.ViewAll);
  246. this.cmbEmployeeName.TagFindText(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID);
  247. this.btnExport.Enabled=LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StatisticalInquiryAllWagesCompetence, CustomAttributes.OperatingAuthority.DataExport);
  248. this.btnProgramSetting.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StatisticalInquiryAllWagesCompetence, CustomAttributes.OperatingAuthority.WageProgramSetting);
  249. //绑定门店
  250. BindStoreList(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.IsGroupEdition);
  251. BindTimePeriod();
  252. GetEmployeeBasicQueryUserList();
  253. GetCurrentQueryStoreList();
  254. GetTimePeriod();
  255. BindWageStatisticsQuery(true);
  256. }
  257. static DataTable _WagesSetDataTable = null;
  258. /// <summary>
  259. /// 员工基本工资集合
  260. /// </summary>
  261. public static DataTable WagesSetDataTable
  262. {
  263. get {
  264. if (_WagesSetDataTable == null)
  265. {
  266. LoadWagesSetDataTable();
  267. }
  268. return frmWageStatisticsQuery._WagesSetDataTable; }
  269. }
  270. public static LYFZ.BLL.BLL_ErpWagesSet wagesSetBll = new BLL_ErpWagesSet();
  271. /// <summary>
  272. /// 加载员工基本工资集合
  273. /// </summary>
  274. public static void LoadWagesSetDataTable()
  275. {
  276. if (_WagesSetDataTable != null)
  277. {
  278. _WagesSetDataTable.Rows.Clear();
  279. _WagesSetDataTable.Dispose();
  280. _WagesSetDataTable = null;
  281. }
  282. _WagesSetDataTable = wagesSetBll.GetAllList().Tables[0];
  283. }
  284. /// <summary>
  285. /// 获取指定用户的基本工资
  286. /// </summary>
  287. /// <param name="uid"></param>
  288. /// <returns></returns>
  289. public static decimal GetBasicWage(string uid)
  290. {
  291. foreach (DataRow row in WagesSetDataTable.Rows)
  292. {
  293. if (row["Ws_StaffCode"].ToString().Trim().ToLower() == uid.ToLower().Trim() && row["Ws_BasicWage"]!=null)
  294. {
  295. return Convert.ToDecimal(row["Ws_BasicWage"]);
  296. }
  297. }
  298. return 0;
  299. }
  300. /// <summary>
  301. /// 获取指定用户的工资统计方案列表
  302. /// </summary>
  303. /// <param name="uid"></param>
  304. /// <returns></returns>
  305. public static string GetCommissionScheme(string uid)
  306. {
  307. try
  308. {
  309. foreach (DataRow row in WagesSetDataTable.Rows)
  310. {
  311. if (row["Ws_StaffCode"].ToString().Trim().ToLower() == uid.ToLower().Trim())
  312. {
  313. return row["Ws_EarlyCommissionScheme"].ToString();
  314. }
  315. }
  316. }
  317. catch {
  318. }
  319. return "";
  320. }
  321. //创建一个委托,是为访问DataGridVie控件服务的。
  322. // public delegate void UpdateControl();
  323. /// <summary>
  324. /// 用户工资计算结果集合
  325. /// </summary>
  326. List<UserWageStatisticsPerformanceCommission> UserWageStatisticsPerformanceCommissionList = new List<UserWageStatisticsPerformanceCommission>();
  327. /// <summary>
  328. /// 绑定工资查询结果
  329. /// </summary>
  330. void BindWageStatisticsQuery(bool isLoadData)
  331. {
  332. if (CurrentQueryUserList == null)
  333. {
  334. MessageBoxCustom.Show("请选择员工");
  335. return;
  336. }
  337. // LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable;
  338. if (isLoadData)
  339. {
  340. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  341. {
  342. backgroundWorker.ReportProgress(0, "正在初始化查询,请稍等...");
  343. frmEditStatisticsProgram.LoadAllSystemCategory();
  344. LoadWagesSetDataTable();
  345. if (frmWageQueryConfig.WQCTable.Rows.Count <= 0)
  346. {
  347. MessageBoxCustom.Show("系统检查到你还没有设置任何工资统计方案,建义您先设置后再查询工资。");
  348. }
  349. });
  350. }
  351. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  352. {
  353. backgroundWorker.ReportProgress(0, "正在查询数据,请稍等...");
  354. LoadRewardPunishment(StartDateTime, EndDateTime);
  355. });
  356. this.dgvStatisticsList.Rows.Clear();
  357. this.UserWageStatisticsPerformanceCommissionList.Clear();
  358. #region 计算统计工资,业绩提成
  359. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  360. {
  361. backgroundWorker.ReportProgress(0, "正在计算工资,请稍等...");
  362. try
  363. {
  364. WageStatisticsProcess.LoadCommissionPercentageSetInfo();
  365. }
  366. catch (Exception ex){
  367. MessageBoxCustom.Show("业绩划分提成比例设置不正确,请重新设置后重试。\r\n"+ex.Message);
  368. return;
  369. }
  370. try
  371. {
  372. foreach (DataRow row in LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows)
  373. {
  374. string User_EmployeeID = row["User_EmployeeID"].ToString();
  375. if (CurrentQueryUserList.CheckRange(row["User_DividedShop"].ToString(), row["User_Department"].ToString(), User_EmployeeID) && row["User_Status"].ToString() != "离职")
  376. {
  377. UserWageStatisticsPerformanceCommission uwspc = new UserWageStatisticsPerformanceCommission();
  378. uwspc.User_DividedShop = row["User_DividedShop"].ToString();
  379. uwspc.User_DividedShopName = GetStoreSPIDToSPName(uwspc.User_DividedShop);
  380. uwspc.User_Department = Convert.ToInt32(row["User_Department"].ToString());
  381. uwspc.Dt_Name = row["Dt_Name"].ToString();
  382. uwspc.User_EmployeeID = User_EmployeeID;
  383. uwspc.User_Name = row["User_Name"].ToString();
  384. backgroundWorker.ReportProgress(0, "计算[" + uwspc.User_Name.Trim() + "]的业绩请稍等...");
  385. string[] CommissionSchemeList = GetCommissionScheme(User_EmployeeID).Split(',');
  386. for (int i = 0; i < CommissionSchemeList.Length; i++)
  387. {
  388. if (!string.IsNullOrEmpty(CommissionSchemeList[i]))
  389. {
  390. LYFZ.Model.Model_WageQueryConfig wqcModel = frmWageQueryConfig.FindWageQueryConfig(CommissionSchemeList[i]);
  391. if (wqcModel != null)
  392. {
  393. PerformanceCommissionInfo pcInfo = WSP_WageStatisticsProcess.GetPerformanceCommissionInfo(wqcModel, User_EmployeeID);
  394. uwspc.PerformanceCommissionList.Add(pcInfo);
  395. }
  396. }
  397. }
  398. UserWageStatisticsPerformanceCommissionList.Add(uwspc);
  399. }
  400. }
  401. }
  402. catch (Exception ex){
  403. MessageBoxCustom.Show("计算统计工资时出错:"+ex.Message);
  404. }
  405. });
  406. #endregion
  407. DataGridViewRow dgRow = null;
  408. foreach (UserWageStatisticsPerformanceCommission userWSPC in UserWageStatisticsPerformanceCommissionList)
  409. {
  410. dgRow = new DataGridViewRow();
  411. dgRow.CreateCells(this.dgvStatisticsList);
  412. dgRow.Cells[0].Style = GetDataGridViewCellStyle(System.Drawing.Color.LightCyan, DataGridViewContentAlignment.MiddleLeft);
  413. dgRow.Cells[1].Style = dgRow.Cells[0].Style;
  414. dgRow.Cells[1].Style = dgRow.Cells[0].Style;
  415. dgRow.Cells[2].Style = dgRow.Cells[0].Style;
  416. dgRow.Cells[3].Style = dgRow.Cells[0].Style;
  417. dgRow.Cells[4].Style = dgRow.Cells[0].Style;
  418. dgRow.Cells[5].Style = dgRow.Cells[0].Style;
  419. dgRow.Cells[6].Style = dgRow.Cells[0].Style;
  420. dgRow.Cells[7].Style = dgRow.Cells[0].Style;
  421. dgRow.Cells[8].Style = dgRow.Cells[0].Style;
  422. dgRow.Cells[9].Style = dgRow.Cells[0].Style;
  423. dgRow.Cells[10].Style = dgRow.Cells[0].Style;
  424. dgRow.Cells[11].Style = dgRow.Cells[0].Style;
  425. dgRow.Cells[0].Value = userWSPC.User_DividedShopName;
  426. dgRow.Cells[1].Value = userWSPC.Dt_Name;
  427. dgRow.Cells[2].Value = userWSPC.User_Name;
  428. userWSPC.BasicWage = GetBasicWage(userWSPC.User_EmployeeID);//基本工资
  429. dgRow.Cells[3].Value = userWSPC.BasicWage;
  430. dgRow.Tag = userWSPC.User_EmployeeID;
  431. userWSPC.Bonus = GetRewardPunish(userWSPC.User_EmployeeID, true);//奖金
  432. dgRow.Cells[4].Value = userWSPC.Bonus;
  433. userWSPC.FineMoney = -GetRewardPunish(userWSPC.User_EmployeeID, false);//罚金
  434. dgRow.Cells[5].Value = userWSPC.FineMoney;//罚金
  435. dgRow.Cells[7].Value = "合计";
  436. dgRow.Cells[8].Value = "";
  437. userWSPC.SumComputePerformanceCommission();
  438. dgRow.Cells[9].Value = userWSPC.SumPerformance;//总业绩
  439. dgRow.Cells[10].Value = userWSPC.SumCommission;//总提成金额
  440. dgRow.Cells[11].Value = "";
  441. //总工资=基本工资+奖金+(-罚金)+总提成金额
  442. dgRow.Cells[6].Value = Convert.ToDecimal(dgRow.Cells[3].Value) + Convert.ToDecimal(dgRow.Cells[4].Value) + Convert.ToDecimal(dgRow.Cells[5].Value) + Convert.ToDecimal(dgRow.Cells[10].Value);
  443. this.dgvStatisticsList.Rows.Add(dgRow);
  444. for (int i = 0; i < userWSPC.PerformanceCommissionList.Count; i++)
  445. {
  446. if (i == userWSPC.PerformanceCommissionList.Count - 1)
  447. {
  448. this.dgvStatisticsList.Rows.Add(GetSubDataGridViewRow(userWSPC.PerformanceCommissionList[i], true));
  449. }
  450. else
  451. {
  452. this.dgvStatisticsList.Rows.Add(GetSubDataGridViewRow(userWSPC.PerformanceCommissionList[i]));
  453. }
  454. }
  455. }
  456. this.dgvStatisticsList.ClearSelection();
  457. }
  458. /// <summary>
  459. ///
  460. /// </summary>
  461. /// <param name="wqcRow">统计查询方案</param>
  462. /// <param name="uEmployeeID"></param>
  463. /// <param name="isEndRow"></param>
  464. /// <returns></returns>
  465. DataGridViewRow GetSubDataGridViewRow(PerformanceCommissionInfo pcInfo, bool isEndRow = false)
  466. {
  467. LYFZ.Model.WageStatisticsQueryItem wItem = (LYFZ.Model.WageStatisticsQueryItem)Convert.ToInt32(pcInfo.WageQueryProgram.WQC_StatisticalItems);
  468. DataGridViewRow dgRow = new DataGridViewRow();
  469. dgRow.CreateCells(this.dgvStatisticsList);
  470. dgRow.Cells[0].Style = GetDataGridViewCellStyle(System.Drawing.Color.White, DataGridViewContentAlignment.MiddleLeft);
  471. dgRow.Cells[1].Style = dgRow.Cells[0].Style;
  472. dgRow.Cells[1].Style = dgRow.Cells[0].Style;
  473. dgRow.Cells[2].Style = dgRow.Cells[0].Style;
  474. dgRow.Cells[3].Style = dgRow.Cells[0].Style;
  475. dgRow.Cells[4].Style = dgRow.Cells[0].Style;
  476. dgRow.Cells[5].Style = dgRow.Cells[0].Style;
  477. dgRow.Cells[6].Style = dgRow.Cells[0].Style;
  478. dgRow.Cells[7].Style = dgRow.Cells[0].Style;
  479. dgRow.Cells[8].Style = dgRow.Cells[0].Style;
  480. dgRow.Cells[9].Style = dgRow.Cells[0].Style;
  481. dgRow.Cells[10].Style = dgRow.Cells[0].Style;
  482. dgRow.Cells[11].Style = dgRow.Cells[0].Style;
  483. dgRow.Tag = pcInfo;
  484. dgRow.Cells[7].Value = wItem.ToString();
  485. if (isEndRow)
  486. {
  487. dgRow.Cells[0].Tag = this.dgvStatisticsList.EraseCellDrawLineHEnd;
  488. dgRow.Cells[1].Tag = this.dgvStatisticsList.EraseCellDrawLineHEnd;
  489. dgRow.Cells[2].Tag = this.dgvStatisticsList.EraseCellDrawLineHEnd;
  490. dgRow.Cells[3].Tag = this.dgvStatisticsList.EraseCellDrawLineHEnd;
  491. dgRow.Cells[4].Tag = this.dgvStatisticsList.EraseCellDrawLineHEnd;
  492. dgRow.Cells[5].Tag = this.dgvStatisticsList.EraseCellDrawLineHEnd;
  493. dgRow.Cells[6].Tag = this.dgvStatisticsList.EraseCellDrawLineVHEnd;
  494. }
  495. else
  496. {
  497. dgRow.Cells[0].Tag = this.dgvStatisticsList.EraseCellDrawLine;
  498. dgRow.Cells[1].Tag = this.dgvStatisticsList.EraseCellDrawLine;
  499. dgRow.Cells[2].Tag = this.dgvStatisticsList.EraseCellDrawLine;
  500. dgRow.Cells[3].Tag = this.dgvStatisticsList.EraseCellDrawLine;
  501. dgRow.Cells[4].Tag = this.dgvStatisticsList.EraseCellDrawLine;
  502. dgRow.Cells[5].Tag = this.dgvStatisticsList.EraseCellDrawLine;
  503. dgRow.Cells[6].Tag = this.dgvStatisticsList.EraseCellDrawLineVEnd;
  504. }
  505. dgRow.Cells[8].Value = pcInfo.WageQueryProgram.WQC_QueryName;
  506. dgRow.Cells[9].Value = pcInfo.Performance;
  507. dgRow.Cells[10].Value = pcInfo.Commission;
  508. dgRow.Cells[11].Value = pcInfo.CommissionMsg;
  509. return dgRow;
  510. }
  511. string GetStoreSPIDToSPName(string sid)
  512. {
  513. foreach (ItemValue item in this.cbxStoreList.Items)
  514. {
  515. if (item.Value.ToString().ToLower() == sid.ToLower())
  516. {
  517. return item.Text.Trim();
  518. }
  519. }
  520. return "未知";
  521. }
  522. System.Windows.Forms.DataGridViewCellStyle GetDataGridViewCellStyle(System.Drawing.Color bgcolor, System.Windows.Forms.DataGridViewContentAlignment alignment = DataGridViewContentAlignment.MiddleCenter)
  523. {
  524. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
  525. dataGridViewCellStyle2.Alignment = alignment;
  526. dataGridViewCellStyle2.BackColor = bgcolor;//System.Drawing.Color.FromArgb(((int)(((byte)(43)))), ((int)(((byte)(108)))), ((int)(((byte)(150)))));
  527. dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 10.5f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
  528. dataGridViewCellStyle2.ForeColor = System.Drawing.Color.Black;
  529. dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
  530. dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
  531. return dataGridViewCellStyle2;
  532. }
  533. #endregion
  534. /// <summary>
  535. /// 开始时间
  536. /// </summary>
  537. DateTime StartDateTime;
  538. /// <summary>
  539. /// 结束时间
  540. /// </summary>
  541. DateTime EndDateTime;
  542. /// <summary>
  543. /// 当前要查询的门店信息集合
  544. /// </summary>
  545. QueryStoreList CurrentQueryStoreList=null;
  546. /// <summary>
  547. /// 当前查询用户集合
  548. /// </summary>
  549. BasicQueryUserList CurrentQueryUserList = null;
  550. void btnQuery_Click(object sender, EventArgs e)
  551. {
  552. GetEmployeeBasicQueryUserList();
  553. GetCurrentQueryStoreList();
  554. GetTimePeriod();
  555. #if !DEBUG
  556. if (!isDataStatisticsQuery)
  557. {
  558. MessageBoxCustom.Show("检查到您还没有进行“数据统计查询”,将只能统计到基本工资奖罚金额。");
  559. }
  560. #endif
  561. BindWageStatisticsQuery(false);
  562. }
  563. void btntest_Click(object sender, EventArgs e)
  564. {
  565. if (MessageBoxCustom.Show("旧版工资管理已过时,将不在升级和维护。\r\n您确定要续续打开吗?", msgBoxButton: MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
  566. {
  567. FrmPayroll fpll = new FrmPayroll();
  568. fpll.Show();
  569. }
  570. }
  571. #region 开始统计工资
  572. #region 奖罚记录表
  573. /// <summary>
  574. /// 员工奖罚
  575. /// </summary>
  576. DataTable _RewardPunishment = null;
  577. LYFZ.BLL.BLL_ErpRewardPunishment rphBll = new BLL_ErpRewardPunishment();
  578. string tempQueryTimestamp = "";
  579. /// <summary>
  580. /// 奖
  581. /// </summary>
  582. Hashtable SumRewardTable = new Hashtable();
  583. /// <summary>
  584. /// 罚
  585. /// </summary>
  586. Hashtable SumPunishTable = new Hashtable();
  587. /// <summary>
  588. /// 加载员工奖罚
  589. /// </summary>
  590. /// <param name="starDate"></param>
  591. /// <param name="endDate"></param>
  592. void LoadRewardPunishment(DateTime starDate, DateTime endDate)
  593. {
  594. string newTempQueryTimestamp = starDate.ToString("yyyy-MM-dd") + starDate.AddDays(1).ToString("yyyy-MM-dd");
  595. if (_RewardPunishment != null)
  596. {
  597. if (!string.IsNullOrEmpty(tempQueryTimestamp) && newTempQueryTimestamp == tempQueryTimestamp)
  598. {
  599. return;
  600. }
  601. _RewardPunishment.Rows.Clear();
  602. _RewardPunishment.Dispose();
  603. _RewardPunishment = null;
  604. }
  605. _RewardPunishment = rphBll.GetList(" Rp_Status='薪资执行' and (Rp_RPDatetime>='" + starDate.ToString("yyyy-MM-dd") + "' and Rp_RPDatetime<'" + endDate.AddDays(1).ToString("yyyy-MM-dd") + "')", " Rp_Type,rp_money desc").Tables[0];
  606. SumRewardPunish();
  607. tempQueryTimestamp = newTempQueryTimestamp;
  608. }
  609. /// <summary>
  610. /// 计算奖罚
  611. /// </summary>
  612. void SumRewardPunish()
  613. {
  614. SumRewardTable.Clear();
  615. SumPunishTable.Clear();
  616. foreach (DataRow row in _RewardPunishment.Rows)
  617. {
  618. string Rp_RelevantPeople = row["Rp_RelevantPeople"].ToString();
  619. decimal Rp_Money = Convert.ToDecimal(row["Rp_Money"].ToString());
  620. switch (row["Rp_Type"].ToString())
  621. {
  622. case "奖励":
  623. if (SumRewardTable.ContainsKey(Rp_RelevantPeople))
  624. {
  625. SumRewardTable[Rp_RelevantPeople] = Convert.ToDecimal(SumRewardTable[Rp_RelevantPeople]) + Rp_Money;
  626. }
  627. else {
  628. SumRewardTable.Add(Rp_RelevantPeople, Rp_Money);
  629. }
  630. break;
  631. case "惩罚":
  632. if (SumPunishTable.ContainsKey(Rp_RelevantPeople))
  633. {
  634. SumPunishTable[Rp_RelevantPeople] = Convert.ToDecimal(SumPunishTable[Rp_RelevantPeople]) + Rp_Money;
  635. }
  636. else
  637. {
  638. SumPunishTable.Add(Rp_RelevantPeople, Rp_Money);
  639. }
  640. break;
  641. }
  642. }
  643. }
  644. /// <summary>
  645. /// 获取指定人员的奖罚金额
  646. /// </summary>
  647. /// <param name="uid">指定人员的ID</param>
  648. /// <param name="isRewardPunish">true 为奖 false 罚</param>
  649. /// <returns></returns>
  650. decimal GetRewardPunish(string uid, bool isRewardPunish)
  651. {
  652. if (isRewardPunish)
  653. {
  654. if (SumRewardTable.ContainsKey(uid))
  655. {
  656. return Convert.ToDecimal(SumRewardTable[uid]);
  657. }
  658. }
  659. else {
  660. if (SumPunishTable.ContainsKey(uid))
  661. {
  662. return Convert.ToDecimal(SumPunishTable[uid]);
  663. }
  664. }
  665. return 0;
  666. }
  667. #endregion
  668. #region 订单前期 统计门市前期业绩
  669. #endregion
  670. #endregion
  671. #region 初始查询条件绑定
  672. /// <summary>
  673. /// 获取时间段
  674. /// </summary>
  675. void GetTimePeriod()
  676. {
  677. this.StartDateTime = this.txtTimeStart.Value;
  678. this.EndDateTime = this.txtTimeEnd.Value;
  679. WSP_WageStatisticsProcess.StartDateTime = this.StartDateTime;
  680. WSP_WageStatisticsProcess.EndDateTime = this.EndDateTime;
  681. }
  682. void txtTimeStart_ValueChanged(object sender, EventArgs e)
  683. {
  684. this.txtTimeEnd.Value = this.txtTimeStart.Value.AddMonths(1).AddDays(-1);
  685. RefreshDataStatisticsQuery();
  686. }
  687. void txtTimeEnd_ValueChanged(object sender, EventArgs e)
  688. {
  689. RefreshDataStatisticsQuery();
  690. }
  691. /// <summary>
  692. /// 获取当前要查询的门店信息集合
  693. /// </summary>
  694. void GetCurrentQueryStoreList()
  695. {
  696. if (CurrentQueryStoreList == null)
  697. {
  698. CurrentQueryStoreList = new QueryStoreList();
  699. }
  700. else
  701. {
  702. CurrentQueryStoreList.QueryStoreInfoList.Clear();
  703. }
  704. ItemValue cItem = (ItemValue)this.cbxStoreList.SelectedItem;
  705. if (cItem.Value.ToString() == "0")
  706. {
  707. CurrentQueryStoreList.QueryType = 0;
  708. }
  709. else if (cItem.Value.ToString() == "1")
  710. {
  711. CurrentQueryStoreList.QueryType = 1;
  712. foreach (ItemValue item in this.cbxStoreList.Items)
  713. {
  714. if (item.Tag != null)
  715. {
  716. QueryStoreInfo qStoreInfo = GetQueryStoreInfo(item);
  717. if (qStoreInfo != null)
  718. {
  719. CurrentQueryStoreList.QueryStoreInfoList.Add(qStoreInfo);
  720. }
  721. }
  722. }
  723. }
  724. else
  725. {
  726. CurrentQueryStoreList.QueryType = 1;
  727. QueryStoreInfo qStoreInfo = GetQueryStoreInfo(cItem);
  728. if (qStoreInfo != null)
  729. {
  730. CurrentQueryStoreList.QueryStoreInfoList.Add(qStoreInfo);
  731. }
  732. }
  733. }
  734. QueryStoreInfo GetQueryStoreInfo(ItemValue item)
  735. {
  736. if (item.Tag != null)
  737. {
  738. QueryStoreInfo qStoreInfo = new QueryStoreInfo();
  739. qStoreInfo.DividedShop = item.Value.ToString();
  740. qStoreInfo.DividedShop_Name = item.Text.Trim();
  741. qStoreInfo.JMGDomain = ((DataRow)item.Tag)["Company_JMGDomain"].ToString();
  742. return qStoreInfo;
  743. }
  744. return null;
  745. }
  746. /// <summary>
  747. /// 获取当前选择的用户集合
  748. /// </summary>
  749. /// <returns></returns>
  750. void GetEmployeeBasicQueryUserList()
  751. {
  752. if (CurrentQueryUserList == null)
  753. {
  754. CurrentQueryUserList = new BasicQueryUserList();
  755. }
  756. else {
  757. CurrentQueryUserList.BasicUsers.Clear();
  758. }
  759. if (this.cmbEmployeeName.Tag != null&& this.cmbEmployeeName.TreeView.SelectedNode!=null)
  760. {
  761. string dataValue = this.cmbEmployeeName.Tag.ToString();
  762. string dataType = this.cmbEmployeeName.StrGetName.Trim();
  763. if (dataType.Length > 0)
  764. {
  765. switch (dataType.ToLower())
  766. {
  767. case "storename":
  768. CurrentQueryUserList.SelectTypeValue = dataValue;
  769. CurrentQueryUserList.SelectUserType = 1;
  770. break;
  771. case "department":
  772. if (IsStoreNode(this.cmbEmployeeName.TreeView.Nodes))
  773. {
  774. CurrentQueryUserList.SelectTypeValue = this.cmbEmployeeName.TreeView.SelectedNode.Parent.Tag.ToString() + "," + dataValue;
  775. }
  776. else {
  777. CurrentQueryUserList.SelectTypeValue = dataValue;
  778. }
  779. CurrentQueryUserList.SelectUserType = 2;
  780. break;
  781. case "user":
  782. CurrentQueryUserList.SelectTypeValue = dataValue;
  783. CurrentQueryUserList.SelectUserType = 3;
  784. break;
  785. default:
  786. CurrentQueryUserList.SelectTypeValue = "";
  787. CurrentQueryUserList.SelectUserType = 0;
  788. break;
  789. }
  790. }
  791. else {
  792. CurrentQueryUserList.SelectUserType = 0;
  793. }
  794. switch (CurrentQueryUserList.SelectUserType)
  795. {
  796. /* case 0:
  797. CurrentQueryUserList.BasicUsers = GetBasicQueryUserList(this.cmbEmployeeName.TreeView.Nodes, IsStoreNode(this.cmbEmployeeName.TreeView.Nodes));
  798. break;*/
  799. case 1:
  800. case 2:
  801. CurrentQueryUserList.BasicUsers = GetBasicQueryUserList(this.cmbEmployeeName.TreeView.SelectedNode.Nodes, IsStoreNode(this.cmbEmployeeName.TreeView.Nodes));
  802. break;
  803. case 3:
  804. CurrentQueryUserList.BasicUsers = GetBasicQueryUserList(this.cmbEmployeeName.TreeView.SelectedNode, IsStoreNode(this.cmbEmployeeName.TreeView.Nodes));
  805. break;
  806. }
  807. }
  808. else {
  809. MessageBoxCustom.Show("请选择要查询的员工!");
  810. }
  811. }
  812. /// <summary>
  813. /// 判断是否存在门店节点
  814. /// </summary>
  815. /// <param name="nodes"></param>
  816. /// <returns></returns>
  817. bool IsStoreNode(TreeNodeCollection nodes)
  818. {
  819. bool ret = false;
  820. foreach (TreeNode node in nodes)
  821. {
  822. string dataType = node.Name.Trim().ToLower();
  823. if (dataType == "storename")
  824. {
  825. ret = true;
  826. break;
  827. }
  828. }
  829. return ret;
  830. }
  831. /// <summary>
  832. ///
  833. /// </summary>
  834. /// <param name="nodes"></param>
  835. /// <param name="isStore">是否有门店节点</param>
  836. /// <returns></returns>
  837. List<BasicQueryUser> GetBasicQueryUserList(object nodes, bool isStore = false)
  838. {
  839. List<BasicQueryUser> retList = new List<BasicQueryUser>();
  840. string DividedShop = "";
  841. string DividedShopName = "";
  842. int DepartmentID = 0;
  843. string DepartmentName = "";
  844. TreeNodeCollection tNodes = null;
  845. if (nodes.GetType() == typeof(TreeNode))
  846. {
  847. TreeNode userNode = (TreeNode)nodes;
  848. if (userNode.Parent != null)
  849. {
  850. if (isStore)
  851. {
  852. DividedShop = userNode.Parent.Parent.Tag.ToString();
  853. DividedShopName = userNode.Parent.Parent.Text.Trim();
  854. }
  855. if (userNode.Parent.Tag != null)
  856. {
  857. DepartmentID = Convert.ToInt32(userNode.Parent.Tag.ToString());
  858. DepartmentName = userNode.Parent.Text.Trim();
  859. BasicQueryUser cuser = new BasicQueryUser();
  860. cuser.DividedShop = DividedShop;
  861. cuser.DividedShopName = DividedShopName;
  862. cuser.DepartmentID = DepartmentID;
  863. cuser.DepartmentName = DepartmentName;
  864. cuser.UserID = userNode.Tag.ToString().Trim();
  865. cuser.UserName = userNode.Text.Trim();
  866. retList.Add(cuser);
  867. }
  868. }
  869. }
  870. else
  871. {
  872. tNodes = (TreeNodeCollection)nodes;
  873. }
  874. if (tNodes != null)
  875. {
  876. foreach (TreeNode node in tNodes)
  877. {
  878. if (node.Tag != null && node.Tag.ToString().Length > 0)
  879. {
  880. string dataType = node.Name.Trim().ToLower();
  881. switch (dataType.ToLower())
  882. {
  883. case "department":
  884. if (isStore)
  885. {
  886. DividedShop = node.Parent.Tag.ToString();
  887. DividedShopName = node.Parent.Text.Trim();
  888. }
  889. DepartmentID = Convert.ToInt32(node.Tag.ToString());
  890. DepartmentName = node.Text.Trim();
  891. foreach (TreeNode cnode in node.Nodes)
  892. {
  893. if (cnode.Tag != null && cnode.Tag.ToString().Trim().Length > 0)
  894. {
  895. BasicQueryUser user = new BasicQueryUser();
  896. user.DividedShop = DividedShop;
  897. user.DividedShopName = DividedShopName;
  898. user.DepartmentID = DepartmentID;
  899. user.DepartmentName = DepartmentName;
  900. user.UserID = cnode.Tag.ToString().Trim();
  901. user.UserName = cnode.Text.Trim();
  902. retList.Add(user);
  903. }
  904. }
  905. break;
  906. case "user":
  907. if (isStore)
  908. {
  909. DividedShop = node.Parent.Parent.Tag.ToString();
  910. DividedShopName = node.Parent.Parent.Text.Trim();
  911. }
  912. DepartmentID = Convert.ToInt32(node.Parent.Tag.ToString());
  913. DepartmentName = node.Parent.Text.Trim();
  914. BasicQueryUser cuser = new BasicQueryUser();
  915. cuser.DividedShop = DividedShop;
  916. cuser.DividedShopName = DividedShopName;
  917. cuser.DepartmentID = DepartmentID;
  918. cuser.DepartmentName = DepartmentName;
  919. cuser.UserID = node.Tag.ToString().Trim();
  920. cuser.UserName = node.Text.Trim();
  921. retList.Add(cuser);
  922. break;
  923. }
  924. }
  925. }
  926. }
  927. return retList;
  928. }
  929. void bntClosed_Click(object sender, EventArgs e)
  930. {
  931. this.Close();
  932. }
  933. /// <summary>
  934. /// 根是是否集团版显示隐藏门店列表
  935. /// </summary>
  936. /// <param name="isGroupEdition"></param>
  937. void HideORShowStoresList(bool isGroupEdition)
  938. {
  939. if (isGroupEdition)
  940. {
  941. this.cbxStoreList.Show();
  942. this.labelEx3.Show();
  943. }
  944. else {
  945. this.cbxStoreList.Hide();
  946. this.labelEx3.Hide();
  947. }
  948. }
  949. /// <summary>
  950. /// 绑定时间段
  951. /// </summary>
  952. void BindTimePeriod()
  953. {
  954. this.txtTimeStart.Value = new DateTime(SDateTime.Now.Year, SDateTime.Now.Month, 1);
  955. this.txtTimeEnd.Value = this.txtTimeStart.Value.AddMonths(1).AddDays(-1);
  956. }
  957. /// <summary>
  958. /// 邦定门店
  959. /// </summary>
  960. void BindStoreList(bool isGroupEdition)
  961. {
  962. DataRowCollection rows = null;
  963. int allValue = 0;
  964. int allStoreCount = 1;
  965. if (isGroupEdition)
  966. {
  967. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  968. {
  969. rows = LYFZ.DAL.DAL_ErpCompanyInfo.GetCompanyBasicInfoList(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.SoftwareInfo.SDomainName.Trim());
  970. allStoreCount = LYFZ.DAL.DAL_ErpCompanyInfo.GetCompanyBasicInfoListCount();
  971. });
  972. if (rows == null)
  973. {
  974. MessageBoxCustom.Show("获取门店信息失败!");
  975. return;
  976. }
  977. else
  978. {
  979. if (allStoreCount > 1 && allStoreCount == rows.Count)
  980. {
  981. allValue = 0;
  982. }
  983. else
  984. {
  985. allValue = 1;
  986. }
  987. if (rows.Count > 1)
  988. {
  989. ItemValue itemAll = new ItemValue(allValue, "全部");
  990. this.cbxStoreList.Items.Add(itemAll);
  991. this.cbxStoreList.SelectedIndex = 0;
  992. }
  993. //是否找到当前店
  994. bool isCurrentStore = false;
  995. foreach (DataRow row in rows)
  996. {
  997. ItemValue itemStore = new ItemValue(row["Company_DividedShop"].ToString(), row["Company_Name"].ToString());
  998. itemStore.Tag = row;
  999. this.cbxStoreList.Items.Add(itemStore);
  1000. if (row["Company_JMGDomain"].ToString().Trim().ToLower() == LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.SoftwareInfo.SDomainName.Trim().ToLower())
  1001. {
  1002. isCurrentStore = true;
  1003. if (allValue == 1)
  1004. {
  1005. this.cbxStoreList.SelectedItem = itemStore;
  1006. }
  1007. }
  1008. }
  1009. if (!isCurrentStore)
  1010. {
  1011. MessageBoxCustom.Show("没有找到当前门店信息");
  1012. this.cbxStoreList.Items.Clear();
  1013. return;
  1014. }
  1015. }
  1016. }
  1017. else {
  1018. ItemValue itemAll = new ItemValue(allValue, "全部");
  1019. this.cbxStoreList.Items.Add(itemAll);
  1020. this.cbxStoreList.SelectedIndex = 0;
  1021. }
  1022. }
  1023. #endregion
  1024. }
  1025. }