}//databind /// <summary> /// 繫結資料 MST /// </summary> private void databind_Mst() { //try //{ ErrorMsgLabel.Text = ""; IFMModel.BCO.MaintainSysRequest BCO = new IFMModel.BCO.MaintainSysRequest(ConnectionDB); ParameterList.Clear(); ParameterList.Add(this.hiddenID.Value); DataTable Dt = BCO.QueryReqMainByID(ParameterList); if (Dt.Rows.Count > 0) { dt_Main = Dt; //結案 Toolbar不可有編輯 if (dt_Main.Rows[0]["REQ_STATUS"].ToString() == "75") { GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Edit, false, string.Empty, this.Btn_Edit, WUI_GMToolbarV.ClickAction.ButtonClick); } } else { ArrayList AL = (ArrayList)Session["IFM03_SortKey" + Request.QueryString["IFM032_PageTimeStamp"]]; string strRemove = "id=" + Request["ID"].ToString(); AL.Remove(strRemove); Session["IFM03_SortKey" + Request.QueryString["IFM032_PageTimeStamp"]] = AL; throw new Exception("查無此筆資料或已被其他使用者刪除,請點選上一筆/下一筆鈕或回查詢頁重新查詢!"); } }//databind_Mst
}//databind_Mst /// <summary> /// 繫結資料 DTL /// </summary> private void databind_Dtl() { #region try { ErrorMsgLabel.Text = ""; IFMModel.BCO.MaintainSysRequest BCO = new IFMModel.BCO.MaintainSysRequest(ConnectionDB); ParameterList.Clear(); ParameterList.Add(this.hiddenID.Value); DataTable Dt = BCO.QueryReqDetlByID(ParameterList); #region 將明細資料放至DetailDt中 Session["IFM032_DTL_" + PageTimeStamp.Value] = Dt; #endregion #region 使用dt_Detl存放資料 dt_Detl = Dt; #endregion this.setGV(-1, Dt, false); } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion }//databind_Dtl
private void GetMis() { IFMModel.BCO.MaintainSysRequest BCO = new IFMModel.BCO.MaintainSysRequest(ConnectionDB); DataTable Dt = BCO.GetMis(); ddl_Emp_ID.DataSource = Dt; ddl_Emp_ID.DataTextField = "emp_name"; ddl_Emp_ID.DataValueField = "emp_id"; ddl_Emp_ID.DataBind(); }
}//UC_RecPre private void Loaddata(string NewCode) { IFMModel.BCO.MaintainSysRequest BCO = new IFMModel.BCO.MaintainSysRequest(ConnectionDB); ParameterList.Clear(); ParameterList.Add(NewCode); DataTable Dt = BCO.QueryReqMainByID(ParameterList); if (Dt != null) { if (Dt.Rows.Count == 0) { ArrayList AL = (ArrayList)Session["IFM03_SortKey" + Request.QueryString["IFM032_PageTimeStamp"]]; string strRemove = "id=" + NewCode; AL.Remove(strRemove); Session["IFM03_SortKey" + Request.QueryString["IFM032_PageTimeStamp"]] = AL; throw new Exception("此筆資料已被其他使用者刪除,請點選上一筆/下一筆鈕或回查詢頁重新查詢!"); } } }
protected void gv_Detail_RowEditing(object sender, GridViewEditEventArgs e) { try { if (this.txt_PageStatus.Text == "EDIT" || this.txt_PageStatus.Text == "EDIT" || this.txt_PageStatus.Text == "INSERT" || this.txt_PageStatus.Text == "INSERT" ) { this.setGV(e.NewEditIndex, (DataTable)Session["IFM032_DTL_" + PageTimeStamp.Value], true); //bind開發階段下拉清單 DataTable dt = (DataTable)Session["IFM032_DTL_" + PageTimeStamp.Value]; if (dt != null && dt.Rows.Count > 0) { int j = gv_Detail.EditIndex; DropDownList phase = ((DropDownList)gv_Detail.Rows[j].Cells[0].Controls[1].FindControl("PHASE_NAME")); phase.SelectedValue = dt.Rows[j]["PHASE_CODE"].ToString(); } //bind 開發人員(=MIS窗口) if (dt != null && dt.Rows.Count > 0) { IFMModel.BCO.MaintainSysRequest BCO = new IFMModel.BCO.MaintainSysRequest(ConnectionDB); DataTable Dt = BCO.GetMis(); int j = gv_Detail.EditIndex; DropDownList ddl_Emp = ((DropDownList)gv_Detail.Rows[j].Cells[1].Controls[1].FindControl("ddl_Emp")); ddl_Emp.DataSource = Dt; ddl_Emp.DataTextField = "emp_name"; ddl_Emp.DataValueField = "emp_id"; ddl_Emp.DataBind(); ddl_Emp.SelectedValue = dt.Rows[j]["EMP_ID"].ToString(); } } else { ShowErrorMessage("請先將狀態切換為[編輯]模式,謝謝!"); } } catch (Exception ex) { this.ErrorMsgLabel.Text = ex.ToString(); } finally { SetPageStatus();//設定模式預設值 } }
private void GetSubsystem() { IFMModel.BCO.MaintainSysRequest BCO = new IFMModel.BCO.MaintainSysRequest(ConnectionDB); DataTable Dt = BCO.GetSystem(); dll_Sys_ID.DataSource = Dt; dll_Sys_ID.DataTextField = "description"; dll_Sys_ID.DataValueField = "code"; dll_Sys_ID.DataBind(); }
protected void Btn_Print_Click(object sender, EventArgs e) { try { ErrorMsgLabel.Text = ""; #region 取得資料 IFMModel.BCO.MaintainSysRequest BCO = new IFMModel.BCO.MaintainSysRequest(ConnectionDB); ParameterList.Clear(); ParameterList.Add(this.hiddenID.Value); DataTable Dt = BCO.PrintRequest(ParameterList); #endregion if (Dt == null || (Dt != null && Dt.Rows.Count <= 0)) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "IFM031.aspx", "alert(' 查無資料 ');", true); } else { string s_FileName = ""; //設定輸出檔名 string s_rptFilePath = ""; //設定報表路徑 s_rptFilePath = Server.MapPath("./REPORT/IFM031/IFM031R.rpt"); s_FileName = HttpUtility.UrlEncode("資訊服務需求單.PDF", System.Text.Encoding.UTF8);//資訊服務需求單 LoadCrystalReport(s_FileName, s_rptFilePath, Dt, "PDF"); } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } }
/// GridView 在產生事件時引發 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gv_Detail_RowCommand(object sender, GridViewCommandEventArgs e) { switch (e.CommandName) { case "New": try { if (this.gv_Detail.EditIndex != -1) { ShowErrorMessage("請將編輯的資料列做更新,再按[存檔]"); } else { DataTable Dt = (DataTable)Session["IFM032_DTL_" + PageTimeStamp.Value]; DataRow dRow; if (Dt == null || Dt.Rows.Count == 0)//沒有明細資料 { IFMModel.BCO.MaintainSysRequest BCO = new IFMModel.BCO.MaintainSysRequest(ConnectionDB); Dt = BCO.QuerySchema(); dRow = Dt.NewRow(); dRow["PHASE_NAME"] = ""; dRow["EMP_NAME"] = ""; dRow["START_DATE"] = ""; dRow["END_DATE"] = ""; dRow["PHASE_HOUR"] = 0; } else { dRow = Dt.NewRow(); } Dt.Rows.Add(dRow); Session["IFM032_DTL_" + PageTimeStamp.Value] = Dt; this.setGV(Dt.Rows.Count - 1, Dt, true); } //bind 開發人員(=MIS窗口) DataTable Dt2 = (DataTable)Session["IFM032_DTL_" + PageTimeStamp.Value]; if (Dt2 != null && Dt2.Rows.Count > 0) { IFMModel.BCO.MaintainSysRequest BCO = new IFMModel.BCO.MaintainSysRequest(ConnectionDB); DataTable Dt3 = BCO.GetMis(); int j = Dt2.Rows.Count - 1; DropDownList ddl_Emp = ((DropDownList)gv_Detail.Rows[j].Cells[1].Controls[1].FindControl("ddl_Emp")); ddl_Emp.DataSource = Dt3; ddl_Emp.DataTextField = "emp_name"; ddl_Emp.DataValueField = "emp_id"; ddl_Emp.DataBind(); } } catch (Exception ex) { this.ErrorMsgLabel.Text = ex.ToString(); } finally { } //finally { SetPageStatus(); } break; case "del": if (this.txt_PageStatus.Text == "EDIT" || this.txt_PageStatus.Text == "EDIT") { DataTable Dt = (DataTable)Session["IFM032_DTL_" + PageTimeStamp.Value]; int j = Convert.ToInt32(e.CommandArgument); string phasecode = ((Label)gv_Detail.Rows[j].Cells[5].Controls[1].FindControl("labphcode")).Text; for (int i = 0; i < Dt.Rows.Count; i++) { if (Convert.ToString(Dt.Rows[i].RowState) != Convert.ToString("Deleted")) { if (phasecode == Dt.Rows[i]["PHASE_CODE"].ToString()) { Dt.Rows[i].Delete(); break; } } } Session["IFM032_DTL_" + PageTimeStamp.Value] = Dt; //this.setGV(0, Dt, false); this.setGV(-1, Dt, true);//設-1 讓gv_Detail回編輯 string nowmode = this.hid_PageStatus.Value; if (nowmode == "EDIT") { #region 切換到檢視模式 this.hid_PageStatus.Value = "EDIT"; this.txt_PageStatus.Text = "EDIT"; #endregion } } else { ShowErrorMessage("請先將狀態切換為[編輯]模式!"); } break; } }
protected void Btn_Insert_Click(object sender, EventArgs e) { try { if (this.gv_Detail.EditIndex != -1) { ShowErrorMessage("請先將目前編輯的資料列[儲存] [取消]或[刪除],再按[新增]"); this.TabContainer1.ActiveTabIndex = 1; } else { this.TabContainer1.ActiveTabIndex = 1; DataTable Dt = (DataTable)Session["IFM032_DTL_" + PageTimeStamp.Value]; DataRow dRow; if (Dt == null || Dt.Rows.Count == 0)//沒有明細資料 { IFMModel.BCO.MaintainSysRequest BCO = new IFMModel.BCO.MaintainSysRequest(ConnectionDB); Dt = BCO.QuerySchema(); dRow = Dt.NewRow(); dRow["PHASE_NAME"] = ""; dRow["EMP_NAME"] = ""; dRow["START_DATE"] = ""; dRow["END_DATE"] = ""; dRow["PHASE_HOUR"] = 0; } else { dRow = Dt.NewRow(); } Dt.Rows.Add(dRow); Session["IFM032_DTL_" + PageTimeStamp.Value] = Dt; this.setGV(Dt.Rows.Count - 1, Dt, true); } //bind 開發人員(=MIS窗口) DataTable Dt2 = (DataTable)Session["IFM032_DTL_" + PageTimeStamp.Value]; if (Dt2 != null && Dt2.Rows.Count > 0) { IFMModel.BCO.MaintainSysRequest BCO = new IFMModel.BCO.MaintainSysRequest(ConnectionDB); DataTable Dt3 = BCO.GetMis(); int j = Dt2.Rows.Count - 1; DropDownList ddl_Emp = ((DropDownList)gv_Detail.Rows[j].Cells[1].Controls[1].FindControl("ddl_Emp")); ddl_Emp.DataSource = Dt3; ddl_Emp.DataTextField = "emp_name"; ddl_Emp.DataValueField = "emp_id"; ddl_Emp.DataBind(); } } catch (Exception ex) { this.ErrorMsgLabel.Text = ex.ToString(); } finally { SetPageStatus();//新增初始值 } }
protected void Btn_Close_Click(object sender, EventArgs e) { try { IFMModel.BCO.MaintainSysRequest BCO = new IFMModel.BCO.MaintainSysRequest(ConnectionDB); #region 取得更新前舊值 #region 使用dt_Main轉回DataTable DataTable MasterOldDt = null; if (dt_Main.Rows.Count > 0) { MasterOldDt = dt_Main; if (dt_Main.Rows.Count == 0) { throw new Exception("抓取不到舊值,更新失敗!"); } } #endregion #endregion BCO.Close(this.getMasterParameterList(), MasterOldDt.Rows[0], null); #region 存檔後資料重新讀取 databind(); //SetDefaultValue(); //重新判斷按鈕 #endregion #region 存檔後狀態設定 this.hid_PageStatus.Value = "VIEW"; this.txt_PageStatus.Text = "VIEW"; #endregion SetPageStatus(); ///檢視初始值 } catch (Exception ex) { this.ErrorMsgLabel.Text = ex.ToString(); } finally { } }
protected void Btn_Delete_Click(object sender, EventArgs e) { if (this.hid_PageStatus.Value == "VIEW") { ErrorMsgLabel.Text = ""; #region 取得更新前舊值 #region 使用dt_Main轉回DataTable DataTable dtMasterOLD = dt_Main; if (dt_Detl.Rows.Count > 0) { DataTable dtDetailOLD = dt_Detl; if (dtDetailOLD.Rows.Count == 0) { throw new Exception("抓取不到舊值,更新失敗!"); } } #endregion #endregion #region 處理刪除作業 try { IFMModel.BCO.MaintainSysRequest BCO = new IFMModel.BCO.MaintainSysRequest(ConnectionDB); BCO.DeleteReq(this.getMasterParameterList(), dtMasterOLD.Rows[0], null); ScriptManager.RegisterStartupScript(up_Detl, this.GetType(), "ClientScript", "alert('刪除完成');location.replace('IFM031.aspx?Code=IFM03');", true); } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion } }
protected void Btn_Save_Click(object sender, EventArgs e) { try { IFMModel.BCO.MaintainSysRequest BCO = new IFMModel.BCO.MaintainSysRequest(ConnectionDB); if (this.gv_Detail.EditIndex != -1) { ShowErrorMessage("請先將目前編輯的資料列[儲存] [取消]或[刪除],再按[存檔]"); } else { DataTable DetailNewDt = (DataTable)Session["IFM032_DTL_" + PageTimeStamp.Value]; if (DetailNewDt == null) { //ShowErrorMessage("無明細資料,請確認"); //return; } else { #region 重新檢查新增的資料列中,是否有id,req_no,phase_code空白的,如果有則刪除不處理 for (int i = this.gv_Detail.Rows.Count - 1; i >= 0; i--) { string vID = ((Label)gv_Detail.Rows[i].Cells[4].Controls[1].FindControl("labid")).Text; string phase_code = ((Label)gv_Detail.Rows[i].Cells[5].Controls[1].FindControl("labphcode")).Text; if (vID.Trim() == "" && phase_code.Trim() == "") { DetailNewDt.Rows[i].Delete(); } } #endregion Session["IFM23_DTL_" + PageTimeStamp.Value] = DetailNewDt; } switch (this.hid_PageStatus.Value) { case "INSERT": if (CheckInsert() == true) { //取需求單號 if (New_Reqno == "") { IFMModel.BCO.MaintainSysRequest Reqno = new IFMModel.BCO.MaintainSysRequest(ConnectionDB); New_Reqno = Reqno.GetReqNo(); } this.TextBoxReqNo.Text = New_Reqno; #region 存檔新增資料 //資料新增 int vPID = BCO.CreateMasterAndDetail( this.getMasterParameterList(), DetailNewDt, null); #endregion this.hiddenID.Value = Convert.ToString(vPID); break; } else { return; } case "EDIT": #region 取得更新前舊值 #region 使用dt_Main轉回DataTable DataTable MasterOldDt = null; if (dt_Main.Rows.Count > 0) { DataTable Dt; Dt = dt_Main; MasterOldDt = dt_Main; if (Dt.Rows.Count == 0) { throw new Exception("抓取不到舊值,更新失敗!"); } } DataTable DetailOldDt = null; if (dt_Detl.Rows.Count > 0) { DetailOldDt = dt_Detl; } #endregion #endregion if (CheckInsert() == true) { ArrayList UpdateArray = new ArrayList(); //"需求確認"=30 修改時若有工時明細 更新成"處理中"=50 if (DetailNewDt.Rows.Count > 0 && MasterOldDt.Rows[0]["REQ_STATUS"].ToString() == "30") { //Update REQ_STATUS=50; UpdateArray = this.getMasterParameterList(); UpdateArray.Add("50"); //Update Req_Main BCO.UpdateMasterAndDetail(UpdateArray, MasterOldDt.Rows[0], DetailNewDt, DetailOldDt, null); } else { UpdateArray = this.getMasterParameterList(); UpdateArray.Add(MasterOldDt.Rows[0]["REQ_STATUS"]); //Update Req_Main BCO.UpdateMasterAndDetail(UpdateArray,//this.getMasterParameterList(), MasterOldDt.Rows[0], DetailNewDt, DetailOldDt, null); } break; } else { return; } } #region 存檔後資料重新讀取 databind(); #endregion #region 存檔後狀態設定 this.hid_PageStatus.Value = "VIEW"; this.txt_PageStatus.Text = "VIEW"; #endregion } } catch (Exception ex) { //this.ErrorMsgLabel.Text = ex.ToString(); throw new Exception(ex.Message); } finally { SetPageStatus();//檢視初始值 //SetDefaultValue(); } }
/// <summary> /// 查詢資料庫取得資料 /// </summary> private void databind() { //抓取本頁初次登記的時間 string SessionIDName = "IFM031_" + PageTimeStamp.Value; IFMModel.BCO.MaintainSysRequest BCO = new IFMModel.BCO.MaintainSysRequest(ConntionDB); ParameterList.Clear(); ParameterList.Add(TextBoxReqNo.Text.Trim()); ParameterList.Add(SLP_Sign_Date.Text.Trim()); ParameterList.Add(SLP_Want_Date.Text.Trim()); ParameterList.Add(SLP_RoleCode.Text.Trim()); ParameterList.Add(SLP_User_ID.Text.Trim()); ParameterList.Add(DDL_Sys_ID.SelectedValue.Trim()); ParameterList.Add(SLP_Req_Type.Text.Trim()); ParameterList.Add(SLP_Req_Level.Text.Trim()); ParameterList.Add(DDL_Emp_ID.SelectedValue.Trim()); ParameterList.Add(SLP_Req_Status.Text.Trim()); ParameterList.Add(SLP_Process_Date.Text.Trim()); ParameterList.Add(SLP_Close_Date.Text.Trim()); ParameterList.Add(SLP_CreateDate.StartDate.Trim()); ParameterList.Add(SLP_CreateDate.EndDate.Trim()); ParameterList.Add(SLP_CreateUID.Text.Trim()); ParameterList.Add(SLP_UpdateDate.StartDate.Trim()); ParameterList.Add(SLP_UpdateDate.EndDate.Trim()); ParameterList.Add(SLP_UpdateUID.Text.Trim()); ParameterList.Add(TextBoxRowCountLimit.Text.Trim()); DataTable Dt = BCO.QueryRow(ParameterList, CheckBoxLikeSearch.Checked); Session[SessionIDName] = Dt; GridView1.DataSource = Dt; //設定分頁大小 if (TextBoxPagesize.Text == "0") { GridView1.PageSize = 1; } else { GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text); } GridView1.PageIndex = 0; GridView1.DataBind(); #region 將Key值存到Session中 ArrayList arl_Key = new ArrayList(); foreach (DataRow drRow in Dt.Rows) { arl_Key.Add("id=" + drRow["ID"].ToString()); } Session["IFM03_SortKey" + this.PageTimeStamp.Value] = arl_Key; #endregion #region 檢查回傳資料 if (Dt.Rows.Count == 0) { this.ErrorMsgLabel.Text = "查無資料"; } #endregion }
private void GetMis() { IFMModel.BCO.MaintainSysRequest BCO = new IFMModel.BCO.MaintainSysRequest(ConntionDB); DataTable Dt = BCO.GetMis(); DDL_Emp_ID.DataSource = Dt; DataRow dRow = Dt.NewRow(); dRow["emp_name"] = "全部"; dRow["emp_id"] = ""; Dt.Rows.InsertAt(dRow, 0); DDL_Emp_ID.DataTextField = "emp_name"; DDL_Emp_ID.DataValueField = "emp_id"; DDL_Emp_ID.DataBind(); }
private void GetSubsystem() { IFMModel.BCO.MaintainSysRequest BCO = new IFMModel.BCO.MaintainSysRequest(ConntionDB); DataTable Dt = BCO.GetSystem(); DDL_Sys_ID.DataSource = Dt; DataRow dRow = Dt.NewRow(); dRow["description"] = "全部"; dRow["code"] = ""; Dt.Rows.InsertAt(dRow,0); DDL_Sys_ID.DataTextField = "description"; DDL_Sys_ID.DataValueField = "code"; DDL_Sys_ID.DataBind(); }