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; } /// /// 是否保存 /// public bool IsSaveed = false; /// /// 窗体加载事件 /// /// /// void frmtimeRecording_Load(object sender, EventArgs e) { this.dtDateTime.StrDateValue = SDateTime.Now.ToString(); this.GetSignSingle(StrDateTime: this.dtDateTime.StrDateValue.Trim()); } /// /// 选择日期选择事件 /// /// void dtDateTime_ClickChengedValue(string SelectValue) { this.GetSignSingle(StrDateTime: SelectValue); } /// /// 日期的回车事件 /// void dtDateTime_KeyDown() { this.btnQuery_Click(this,null); } /// /// 获取签单条件 /// /// /// 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"); } /// /// 查询条件 /// /// /// void btnQuery_Click(object sender, EventArgs e) { this.GetSignSingle(StrDateTime: this.dtDateTime.StrDateValue.Trim(), StrUserName: this.txtUserName.Text.Trim()); } /// /// 删除 /// /// /// 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("请选择你要删除的签单数据!"); } } /// /// 关闭 /// /// /// void btnClose_Click(object sender, EventArgs e) { this.Close(); } } }