protected override void AjaxProcess() { string noticeJson = null; DataTable dt = new DataTable(); if (!string.IsNullOrEmpty(Request.Form["Empno"])) { string empno = Request.Form["Empno"]; EmployeeShiftModel model = new EmployeeShiftModel(); dt = bll.GetEmployeeInfo(empno); if (dt.Rows.Count != 0) { model.LocalName = dt.Rows[0]["LocalName"].ToString(); model.Syc = dt.Rows[0]["Syc"].ToString(); model.DepName = dt.Rows[0]["DEPNAME"].ToString(); if (Request.Form["Flag"].ToString() == "add") { DataTable dt_shift = bll.GetShift(dt.Rows[0]["DEPcode"].ToString()); ddlShiftNo.DataSource = dt_shift; this.ddlShiftNo.DataTextField = "shiftdetail"; this.ddlShiftNo.DataValueField = "shiftno"; this.ddlShiftNo.DataBind(); this.ddlShiftNo.Items.Insert(0, new ListItem("", "")); } } if (model != null) { noticeJson = JsSerializer.Serialize(model); } Response.Clear(); Response.Write(noticeJson); Response.End(); } }
protected void txtEmployeeNo_TextChanged(object sender, EventArgs e) { DataTable dt = new DataTable(); if (!string.IsNullOrEmpty(this.txtEmployeeNo.Text)) { string empno = this.txtEmployeeNo.Text.ToString(); HiddenEmployeeNo.Value = empno; EmployeeShiftModel model = new EmployeeShiftModel(); dt = bll.GetEmployeeInfo(empno); if (dt.Rows.Count != 0) { this.txtChineseName.Text = dt.Rows[0]["LocalName"].ToString(); this.txtSYC.Text = dt.Rows[0]["Syc"].ToString(); this.txtSYB.Text = dt.Rows[0]["DEPNAME"].ToString(); if (hidOperate.Value == "add") { DataTable dt_shift = bll.GetShift(dt.Rows[0]["DEPcode"].ToString()); ddlShiftNo.DataSource = dt_shift; this.ddlShiftNo.DataTextField = "shiftdetail"; this.ddlShiftNo.DataValueField = "shiftno"; this.ddlShiftNo.DataBind(); this.ddlShiftNo.Items.Insert(0, new ListItem("", "")); txtEmployeeNo.Attributes.Remove("disabled"); ddlShiftNo.Attributes.Remove("disabled"); txtStartDate.Attributes.Remove("readonly"); txtEndDate.Attributes.Remove("readonly"); this.txtStartDate.CssClass = "input_textBox_haveborder"; this.txtEndDate.CssClass = "input_textBox_haveborder"; btnQuery.Attributes.Add("disabled", "true"); btnAdd.Attributes.Add("disabled", "true"); btnModify.Attributes.Add("disabled", "true"); btnDelete.Attributes.Add("disabled", "true"); btnSave.Attributes.Remove("disabled"); btnCancel.Attributes.Remove("disabled"); } } } }
/// <summary> /// 刪除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDelete_Click(object sender, EventArgs e) { logmodel.ProcessFlag = "delete"; EmployeeShiftModel model = new EmployeeShiftModel(); model.ID = HiddenID.Value; if (model.ID != "") { bool flag = bll.DeleteEmployeeShiftByKey(model.ID, logmodel); if (flag) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "isnumber", "alert('" + Message.DeleteSuccess + "');", true); DataBind(); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "isnumber", "alert('" + Message.DeleteFailed + "');", true); } } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "isnumber", "alert('" + Message.AtLastOneChoose + "');", true); } }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { EmployeeShiftModel model = new EmployeeShiftModel(); if (txtEmployeeNo.Text.ToString() != "") { model.WorkNo = txtEmployeeNo.Text.ToString(); } else { model.WorkNo = HiddenEmployeeNo.Value; } model.Shift = ddlShiftNo.SelectedValue; model.UpdateUser = CurrentUserInfo.Personcode; model.ID = HiddenID.Value; try { model.StartDate = Convert.ToDateTime(this.txtStartDate.Text).ToString("yyyy/MM/dd"); model.EndDate = Convert.ToDateTime(this.txtEndDate.Text).ToString("yyyy/MM/dd"); } catch (Exception) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "isnumber", "alert('" + Message.ErrDateFormat + "');", true); txtChineseName.Text = HiddenChineseName.Value; txtSYC.Text = HiddenSYC.Value; txtSYB.Text = HiddenSYB.Value; return; } DataTable dt = bll.GetEmployeeShifInfo(model.WorkNo); for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["ID"].ToString() != HiddenID.Value) { if (!(Convert.ToDateTime(this.txtStartDate.Text) > Convert.ToDateTime(dt.Rows[i]["enddate"].ToString()) || Convert.ToDateTime(this.txtEndDate.Text) < Convert.ToDateTime(dt.Rows[i]["startdate"].ToString()))) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "isnumber", "alert('" + Message.ShiftNotOnly + "');", true); return; } } } bool succeed; if (hidOperate.Value == "modify") { logmodel.ProcessFlag = "update"; succeed = bll.UpdateEmployeeShiftByKey(model, logmodel); if (succeed) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "isnumber", "alert('" + Message.UpdateSuccess + "');", true); DataBind(); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "isnumber", "alert('" + Message.UpdateFailed + "');", true); } } if (hidOperate.Value == "add") { logmodel.ProcessFlag = "insert"; succeed = bll.AddEmployeeShift(model, logmodel); if (succeed) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "isnumber", "alert('" + Message.AddSuccess + "');", true); DataBind(); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "isnumber", "alert('" + Message.AddFailed + "');", true); } } }
/// <summary> /// 綁定數據 /// </summary> private void DataBind() { EmployeeShiftModel model = new EmployeeShiftModel(); UltraWebGridShiftQuery.DataSource = bll.GetShiftInfo(model, pager.CurrentPageIndex, pager.PageSize, out totalCount, "", txtShiftDate.Text.Trim(), "", "", base.SqlDep); dt_global = bll.GetShiftInfo(model, "", txtShiftDate.Text.Trim(), "", "", base.SqlDep); UltraWebGridShiftQuery.DataBind(); pager.TextAfterPageIndexBox = "/" + pager.PageCount.ToString(); }