private void DataBind(DataTable dt) { txtDepName.Attributes.Add("readonly", "true"); txtWorkNo.Attributes.Add("readonly", "true"); txtLocalName.Attributes.Add("readonly", "true"); ddlManager.Attributes.Add("disabled", "true"); txtNotes.Attributes.Add("readonly", "true"); txtDeputy.Attributes.Add("readonly", "true"); txtDeputyName.Attributes.Add("readonly", "true"); txtDeputyNotes.Attributes.Add("readonly", "true"); chkIsDirectlyUnder.Attributes.Add("disabled", "true"); chkIsBGAudit.Attributes.Add("disabled", "true"); btnSave.Attributes.Add("disabled", "true"); btnCancel.Attributes.Add("disabled", "true"); btnCondition.Attributes.Clear(); btnQuery.Attributes.Clear(); btnAdd.Attributes.Clear(); btnDelete.Attributes.Clear(); btnModify.Attributes.Clear(); PanelData.Attributes.Add("class", "inner_table"); PanelImport.Attributes.Add("class", "img_hidden"); btnImport.Text = Message.btnImport; OrgmanagerBll bll = new OrgmanagerBll(); this.ddlManager.SelectedValue = ""; this.UltraWebGridManagerInfo.DataSource = dt; this.UltraWebGridManagerInfo.DataBind(); pager.TextAfterPageIndexBox = "/" + pager.PageCount.ToString(); }
protected override void AjaxProcess() { string noticeJson = null; DataTable dt = new DataTable(); if (!string.IsNullOrEmpty(Request.Form["Empno"])) { OrgmanagerBll bll = new OrgmanagerBll(); string empno = Request.Form["Empno"]; OrgmanagerModel model = new OrgmanagerModel(); dt = bll.GetInfo(empno); if (dt.Rows.Count != 0) { model.LocalName = dt.Rows[0]["LocalName"].ToString(); model.Manager = dt.Rows[0]["managercode"].ToString(); model.Notes = dt.Rows[0]["notes"].ToString(); } if (model != null) { noticeJson = JsSerializer.Serialize(model); } Response.Clear(); Response.Write(noticeJson); Response.End(); } if (!string.IsNullOrEmpty(Request.Form["Deputy"])) { OrgmanagerBll bll = new OrgmanagerBll(); string empno = Request.Form["Deputy"]; OrgmanagerModel model = new OrgmanagerModel(); dt = bll.GetInfo(empno); if (dt.Rows.Count != 0) { model.DeputyName = dt.Rows[0]["LocalName"].ToString(); model.DeputyNotes = dt.Rows[0]["notes"].ToString(); } if (model != null) { noticeJson = JsSerializer.Serialize(model); } Response.Clear(); Response.Write(noticeJson); Response.End(); } if (!string.IsNullOrEmpty(Request.Form["WorkNo"])) { OrgmanagerModel model = new OrgmanagerModel(); OrgmanagerBll bll = new OrgmanagerBll(); DataTable dt1 = new DataTable(); if (!string.IsNullOrEmpty(Request.Form["WorkNo"])) { model.WorkNo = Request.Form["WorkNo"]; model.DepCode = Request.Form["DepCode"]; dt1 = bll.GetOrgmanager(model); if (dt1 != null) { noticeJson = dt1.Rows.Count.ToString(); } Response.Clear(); Response.Write(noticeJson); Response.End(); } } }
protected void pager_PageChanged(object sender, EventArgs e) { OrgmanagerModel model = PageHelper.GetModel<OrgmanagerModel>(pnlContent.Controls); OrgmanagerBll bll = new OrgmanagerBll(); DataTable dt = bll.GetOrgmanager(model, pager.CurrentPageIndex, pager.PageSize, out totalCount, base.SqlDep); pager.RecordCount = totalCount; DataBind(dt); }
/// <summary> /// 綁定數據 /// </summary> private void DataBind() { ImportFlag.Value = "1"; txtDepName.Attributes.Add("readonly", "true"); txtWorkNo.Attributes.Add("readonly", "true"); txtLocalName.Attributes.Add("readonly", "true"); ddlManager.Attributes.Add("disabled", "true"); txtNotes.Attributes.Add("readonly", "true"); txtDeputy.Attributes.Add("readonly", "true"); txtDeputyName.Attributes.Add("readonly", "true"); txtDeputyNotes.Attributes.Add("readonly", "true"); chkIsDirectlyUnder.Attributes.Add("disabled", "true"); chkIsBGAudit.Attributes.Add("disabled", "true"); btnSave.Attributes.Add("disabled", "true"); btnCancel.Attributes.Add("disabled", "true"); btnCondition.Attributes.Clear(); btnQuery.Attributes.Clear(); btnAdd.Attributes.Clear(); btnDelete.Attributes.Clear(); btnModify.Attributes.Clear(); PanelData.Attributes.Add("class", "inner_table"); PanelImport.Attributes.Add("class", "img_hidden"); btnImport.Text = Message.btnImport; OrgmanagerModel model = new OrgmanagerModel(); OrgmanagerBll bll = new OrgmanagerBll(); ddlManager.DataSource = bll.GetManager(); ddlManager.DataValueField = "MANAGERCODE"; ddlManager.DataTextField = "MANAGERNAME"; ddlManager.DataBind(); this.ddlManager.Items.Insert(0, new ListItem("", "")); this.ddlManager.SelectedValue = ""; DataTable dt = bll.GetOrgmanager(model, pager.CurrentPageIndex, pager.PageSize, out totalCount, base.SqlDep); pager.RecordCount = totalCount; this.UltraWebGridManagerInfo.DataSource = dt; this.UltraWebGridManagerInfo.DataBind(); pager.TextAfterPageIndexBox = "/" + pager.PageCount.ToString(); }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { StatusReset(); OrgmanagerModel model = PageHelper.GetModel<OrgmanagerModel>(pnlContent.Controls); model.ManagerName = ddlManager.SelectedItem.ToString(); OrgmanagerBll bll = new OrgmanagerBll(); int flag; DataTable dt = bll.GetOrgmanager(model, pager.CurrentPageIndex, pager.PageSize, out totalCount, base.SqlDep); if (dt.Rows.Count == 0) { if (hidOperate.Value == "modify") { logmodel.ProcessFlag = "update"; flag = bll.UpdateOrgmanagerByKey(model,HiddenDepCode.Value,HiddenWorkNo.Value, logmodel); if (flag == 1) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "isnumber", "alert('" + Message.UpdateSuccess + "');", true); DataBind(); } else if (flag == 2) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "isnumber", "alert('" + Message.OnlyOneDirectlyunder + "');", true); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "isnumber", "alert('" + Message.UpdateFailed + "');", true); } } if (hidOperate.Value == "add") { logmodel.ProcessFlag = "insert"; flag = bll.AddOrgmanager(model, logmodel); if (flag == 1) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "isnumber", "alert('" + Message.AddSuccess + "');", true); DataBind(); } else if (flag == 2) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "isnumber", "alert('" + Message.OnlyOneDirectlyunder + "');", true); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "isnumber", "alert('" + Message.AddFailed + "');", true); } } } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "isnumber", "alert('" + Message.NotOnlyOne + "');", true); } }
protected void btnQuery_Click(object sender, EventArgs e) { pager.CurrentPageIndex = 1; OrgmanagerModel model = PageHelper.GetModel<OrgmanagerModel>(pnlContent.Controls); OrgmanagerBll bll = new OrgmanagerBll(); DataTable dt = bll.GetOrgmanager(model, pager.CurrentPageIndex, pager.PageSize, out totalCount, base.SqlDep); pager.RecordCount = totalCount; DataBind(dt); hidOperate.Value = ""; }
protected void btnImportSave_Click(object sender, EventArgs e) { OrgmanagerBll bll = new OrgmanagerBll(); int succesnum = 0; int errornum = 0; int flag = ImportModuleExcel(); if (flag == 1) { logmodel.ProcessFlag = "insert"; DataTable dt = bll.ImpoertExcel(CurrentUserInfo.Personcode, out succesnum, out errornum, logmodel); lblupload.Text = "上傳成功筆數:" + succesnum + ",上傳失敗筆數:" + errornum; dt_global = changeError(dt); this.UltraWebGridImport.DataSource = dt_global; this.UltraWebGridImport.DataBind(); } else if (flag == 0) { lblupload.Text = "數據保存失敗!"; } else { lblupload.Text = "Excel數據格式錯誤"; } PanelData.Attributes.Add("class", "img_hidden"); PanelImport.Attributes.Add("class", "inner_table"); btnCondition.Attributes.Add("disabled", "true"); btnQuery.Attributes.Add("disabled", "true"); btnAdd.Attributes.Add("disabled", "true"); btnDelete.Attributes.Add("disabled", "true"); btnModify.Attributes.Add("disabled", "true"); btnCancel.Attributes.Add("disabled", "true"); btnSave.Attributes.Add("disabled", "true"); btnImport.Text = Message.btnBack; }
protected void btnExport_Click(object sender, EventArgs e) { btnImport.Text = Message.btnBack; if (dt_global.Rows.Count != 0) { OrgmanagerModel model = PageHelper.GetModel<OrgmanagerModel>(pnlContent.Controls); OrgmanagerBll bll = new OrgmanagerBll(); List<OrgmanagerModel> list = bll.GetList(dt_global); string[] header = { ControlText.gvHeadErrorMsg, ControlText.gvHeadDepName, ControlText.gvHeadDepCode, ControlText.gvHeadWorkNo, ControlText.gvHeadNotes, ControlText.gvHeadIsDirectlyUnder, ControlText.gvHeadIsBGAudit, ControlText.gvHeadDeputy, ControlText.gvHeadProxyNotes }; string[] properties = { "ErrorMsg", "DepName", "DepCode", "WorkNo", "Notes", "IsDirectlyUnder", "IsBGAudit", "Deputy", "DeputyNotes" }; string filePath = MapPath("~/ExportFileTemp/") + DateTime.Now.Ticks + ".xls"; NPOIHelper.ExportExcel(list, header, properties, 5000, filePath); PageHelper.ReturnHTTPStream(filePath, true); } else { lblupload.Text = "導出數據不存在"; } }
/// <summary> /// 刪除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDelete_Click(object sender, EventArgs e) { logmodel.ProcessFlag = "delete"; OrgmanagerModel model = PageHelper.GetModel<OrgmanagerModel>(pnlContent.Controls); OrgmanagerBll bll = new OrgmanagerBll(); int intDeleteOk = 0; int intDeleteError = 0; TemplatedColumn tcol = (TemplatedColumn)this.UltraWebGridManagerInfo.Bands[0].Columns[0]; for (int i = 0; i < this.UltraWebGridManagerInfo.Rows.Count; i++) { CellItem GridItem = (CellItem)tcol.CellItems[i]; CheckBox chkIsHaveRight = (CheckBox)GridItem.FindControl("CheckBoxCell"); if (chkIsHaveRight.Checked) { int num = bll.DeleteOrgmanagerByKey(this.UltraWebGridManagerInfo.Rows[i].Cells.FromKey("WorkNo").Text.Trim(), this.UltraWebGridManagerInfo.Rows[i].Cells.FromKey("DepCode").Text.Trim(), logmodel); if (num > 0) { intDeleteOk++; } else { intDeleteError++; } } } if ((intDeleteOk + intDeleteError) > 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "isnumber", "alert('" + Message.DeleteSuccess + ":" + intDeleteOk + ";" + Message.DeleteFailed + ":" + intDeleteError + "');", true); DataBind(); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "isnumber", "alert('" + Message.AtLastOneChoose + "');", true); return; } }