123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Data;
- using System.Data.SqlClient;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.TimeAndAttendance
- {
- public class frmtimeRecording : LYFZ.Software.UI.TimeAndAttendance.frmtimeRecording
- {
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
- LYFZ.Model.Model_Loginsign loginsignmodel = new Model.Model_Loginsign();
- LYFZ.BLL.BLL_Loginsign loginsign = new BLL.BLL_Loginsign();
- public frmtimeRecording()
- {
- this.Load += frmtimeRecording_Load;
- this.dtDateTime.ClickChengedValue += dtDateTime_ClickChengedValue;
- this.dtDateTime.KeyDown += dtDateTime_KeyDown;
- this.btnQuery.Click += btnQuery_Click;
- this.btnDelete.Click += btnDelete_Click;
- this.btnClose.Click += btnClose_Click;
- }
- /// <summary>
- /// 是否保存
- /// </summary>
- public bool IsSaveed = false;
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void frmtimeRecording_Load(object sender, EventArgs e)
- {
- this.dtDateTime.StrDateValue = SDateTime.Now.ToString();
- this.GetSignSingle(StrDateTime: this.dtDateTime.StrDateValue.Trim());
- }
- /// <summary>
- /// 选择日期选择事件
- /// </summary>
- /// <param name="SelectValue"></param>
- void dtDateTime_ClickChengedValue(string SelectValue)
- {
- this.GetSignSingle(StrDateTime: SelectValue);
- }
- /// <summary>
- /// 日期的回车事件
- /// </summary>
- void dtDateTime_KeyDown()
- {
- this.btnQuery_Click(this,null);
- }
- /// <summary>
- /// 获取签单条件
- /// </summary>
- /// <param name="StrDateTime"></param>
- /// <param name="StrUserName"></param>
- void GetSignSingle(string StrDateTime = "", string StrUserName = "")
- {
- string StrWhere = "";
- if (!string.IsNullOrEmpty(StrDateTime))
- { StrWhere = "Date like '" + StrDateTime + "%'"; }
- if (!string.IsNullOrEmpty(StrUserName))
- {
- if (!string.IsNullOrEmpty(StrWhere))
- { StrWhere += " And "; }
- StrWhere += "(User_Name like '" + StrUserName + "%' or dbo.fn_ChineseToSpell(User_Name) like '" + StrUserName + "%')";
- }
- int intTopCount = 0;
- if (!string.IsNullOrEmpty(StrWhere))
- { intTopCount = -1; }
- 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];
- this.dgvData.DataSource(dt, strHideField: "id");
- }
- /// <summary>
- /// 查询条件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnQuery_Click(object sender, EventArgs e)
- {
- this.GetSignSingle(StrDateTime: this.dtDateTime.StrDateValue.Trim(), StrUserName: this.txtUserName.Text.Trim());
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnDelete_Click(object sender, EventArgs e)
- {
- if (this.dgvData.SelectedRows.Count > 0)
- {
- if (MessageBoxCustom.Show("您确定要删除吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- if (loginsign.Delete(Convert.ToInt32(this.dgvData.SelectedRows[0].Cells["ID"].Value)))
- {
- this.IsSaveed = true;
- MessageBoxCustom.Show("删除成功!");
- this.btnQuery_Click(this, null);
- }
- else
- { MessageBoxCustom.Show("删除失败!"); }
- }
- }
- else
- { MessageBoxCustom.Show("请选择你要删除的签单数据!"); }
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnClose_Click(object sender, EventArgs e)
- { this.Close(); }
- }
- }
|