frmtimeRecording.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Data;
  6. using System.Data.SqlClient;
  7. using System.Windows.Forms;
  8. namespace LYFZ.Software.MainBusiness.TimeAndAttendance
  9. {
  10. public class frmtimeRecording : LYFZ.Software.UI.TimeAndAttendance.frmtimeRecording
  11. {
  12. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  13. LYFZ.Model.Model_Loginsign loginsignmodel = new Model.Model_Loginsign();
  14. LYFZ.BLL.BLL_Loginsign loginsign = new BLL.BLL_Loginsign();
  15. public frmtimeRecording()
  16. {
  17. this.Load += frmtimeRecording_Load;
  18. this.dtDateTime.ClickChengedValue += dtDateTime_ClickChengedValue;
  19. this.dtDateTime.KeyDown += dtDateTime_KeyDown;
  20. this.btnQuery.Click += btnQuery_Click;
  21. this.btnDelete.Click += btnDelete_Click;
  22. this.btnClose.Click += btnClose_Click;
  23. }
  24. /// <summary>
  25. /// 是否保存
  26. /// </summary>
  27. public bool IsSaveed = false;
  28. /// <summary>
  29. /// 窗体加载事件
  30. /// </summary>
  31. /// <param name="sender"></param>
  32. /// <param name="e"></param>
  33. void frmtimeRecording_Load(object sender, EventArgs e)
  34. {
  35. this.dtDateTime.StrDateValue = SDateTime.Now.ToString();
  36. this.GetSignSingle(StrDateTime: this.dtDateTime.StrDateValue.Trim());
  37. }
  38. /// <summary>
  39. /// 选择日期选择事件
  40. /// </summary>
  41. /// <param name="SelectValue"></param>
  42. void dtDateTime_ClickChengedValue(string SelectValue)
  43. {
  44. this.GetSignSingle(StrDateTime: SelectValue);
  45. }
  46. /// <summary>
  47. /// 日期的回车事件
  48. /// </summary>
  49. void dtDateTime_KeyDown()
  50. {
  51. this.btnQuery_Click(this,null);
  52. }
  53. /// <summary>
  54. /// 获取签单条件
  55. /// </summary>
  56. /// <param name="StrDateTime"></param>
  57. /// <param name="StrUserName"></param>
  58. void GetSignSingle(string StrDateTime = "", string StrUserName = "")
  59. {
  60. string StrWhere = "";
  61. if (!string.IsNullOrEmpty(StrDateTime))
  62. { StrWhere = "Date like '" + StrDateTime + "%'"; }
  63. if (!string.IsNullOrEmpty(StrUserName))
  64. {
  65. if (!string.IsNullOrEmpty(StrWhere))
  66. { StrWhere += " And "; }
  67. StrWhere += "(User_Name like '" + StrUserName + "%' or dbo.fn_ChineseToSpell(User_Name) like '" + StrUserName + "%')";
  68. }
  69. int intTopCount = 0;
  70. if (!string.IsNullOrEmpty(StrWhere))
  71. { intTopCount = -1; }
  72. DataTable dt = orbll.GetView_Custom("loginsign Left Join tb_ErpUser On User_Id = User_EmployeeID", StrWhere: StrWhere, ShowColumnName: "loginsign.id,User_Name AS 姓名,date AS 签单日期,type AS 签单班次,cleck AS 经手人", filedOrder: "Date DESC", TopCount: intTopCount).Tables[0];
  73. this.dgvData.DataSource(dt, strHideField: "id");
  74. }
  75. /// <summary>
  76. /// 查询条件
  77. /// </summary>
  78. /// <param name="sender"></param>
  79. /// <param name="e"></param>
  80. void btnQuery_Click(object sender, EventArgs e)
  81. {
  82. this.GetSignSingle(StrDateTime: this.dtDateTime.StrDateValue.Trim(), StrUserName: this.txtUserName.Text.Trim());
  83. }
  84. /// <summary>
  85. /// 删除
  86. /// </summary>
  87. /// <param name="sender"></param>
  88. /// <param name="e"></param>
  89. void btnDelete_Click(object sender, EventArgs e)
  90. {
  91. if (this.dgvData.SelectedRows.Count > 0)
  92. {
  93. if (MessageBoxCustom.Show("您确定要删除吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  94. {
  95. if (loginsign.Delete(Convert.ToInt32(this.dgvData.SelectedRows[0].Cells["ID"].Value)))
  96. {
  97. this.IsSaveed = true;
  98. MessageBoxCustom.Show("删除成功!");
  99. this.btnQuery_Click(this, null);
  100. }
  101. else
  102. { MessageBoxCustom.Show("删除失败!"); }
  103. }
  104. }
  105. else
  106. { MessageBoxCustom.Show("请选择你要删除的签单数据!"); }
  107. }
  108. /// <summary>
  109. /// 关闭
  110. /// </summary>
  111. /// <param name="sender"></param>
  112. /// <param name="e"></param>
  113. void btnClose_Click(object sender, EventArgs e)
  114. { this.Close(); }
  115. }
  116. }