private void setData() { cefOpen opjEfOpen = new cefOpen(); cefLoan opjEfLoan = new cefLoan(); DataTable dt = new DataTable(); try { if (ViewState["mode"].ToString() == "view") { imgSaveOnly.Visible = false; txtapprove_note.ReadOnly = true; txtapprove_note.CssClass = "textboxdis"; cboApprove_status.Enabled = false; cboApprove_status.CssClass = "textboxdis"; } if (ViewState["type"].ToString() == "open") { lblopen.Text = "รายการขออนุมัติเบิก :"; lblperson_open_tile.Text = "ผู้ขออนุมัติเบิก :"; _strCriteria = " and open_detail_approve_id= " + ViewState["open_detail_approve_id"].ToString(); dt = opjEfOpen.SP_OPEN_DETAIL_APPROVE_SEL(_strCriteria); if (dt.Rows.Count > 0) { #region get Data lblopen_title.Text = Helper.CStr(dt.Rows[0]["open_title"]); lblapprove_person.Text = Helper.CStr(dt.Rows[0]["title_name"]) + Helper.CStr(dt.Rows[0]["person_thai_name"]) + " " + Helper.CStr(dt.Rows[0]["person_thai_surname"]); lblperson_open_name.Text = Helper.CStr(dt.Rows[0]["req_title_name"]) + Helper.CStr(dt.Rows[0]["req_person_thai_name"]) + " " + Helper.CStr(dt.Rows[0]["req_person_thai_surname"]); ViewState["open_head_id"] = dt.Rows[0]["open_head_id"].ToString(); if (cboApprove_status.Items.FindByValue(dt.Rows[0]["approve_status"].ToString()) != null) { cboApprove_status.SelectedIndex = -1; cboApprove_status.Items.FindByValue(dt.Rows[0]["approve_status"].ToString()).Selected = true; } txtapprove_note.Text = dt.Rows[0]["approve_note"].ToString(); #endregion } } else { lblopen.Text = "รายละเอียดสัญญายืมเงิน :"; lblperson_open_tile.Text = "ผู้ขอยืมเงิน :"; _strCriteria = " and loan_detail_approve_id= " + ViewState["open_detail_approve_id"]; dt = opjEfLoan.SP_LOAN_DETAIL_APPROVE_SEL(_strCriteria); if (dt.Rows.Count > 0) { #region get Data lblopen_title.Text = Helper.CStr(dt.Rows[0]["loan_reason"]); lblapprove_person.Text = Helper.CStr(dt.Rows[0]["title_name"]) + Helper.CStr(dt.Rows[0]["person_thai_name"]) + " " + Helper.CStr(dt.Rows[0]["person_thai_surname"]); lblperson_open_name.Text = Helper.CStr(dt.Rows[0]["req_title_name"]) + Helper.CStr(dt.Rows[0]["req_person_thai_name"]) + " " + Helper.CStr(dt.Rows[0]["req_person_thai_surname"]); ViewState["open_head_id"] = dt.Rows[0]["loan_id"].ToString(); if (cboApprove_status.Items.FindByValue(dt.Rows[0]["approve_status"].ToString()) != null) { cboApprove_status.SelectedIndex = -1; cboApprove_status.Items.FindByValue(dt.Rows[0]["approve_status"].ToString()).Selected = true; } txtapprove_note.Text = dt.Rows[0]["approve_note"].ToString(); #endregion } } } catch (Exception ex) { lblError.Text = ex.Message.ToString(); } }
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType.Equals(DataControlRowType.Header)) { for (int iCol = 0; iCol < e.Row.Cells.Count; iCol++) { e.Row.Cells[iCol].Attributes.Add("class", "table_h"); e.Row.Cells[iCol].Wrap = false; } } else if (e.Row.RowType.Equals(DataControlRowType.DataRow) || e.Row.RowState.Equals(DataControlRowState.Alternate)) { #region Set datagrid row color string strEvenColor, strOddColor, strMouseOverColor; strEvenColor = ((DataSet)Application["xmlconfig"]).Tables["colorDataGridRow"].Rows[0]["Even"].ToString(); strOddColor = ((DataSet)Application["xmlconfig"]).Tables["colorDataGridRow"].Rows[0]["Odd"].ToString(); strMouseOverColor = ((DataSet)Application["xmlconfig"]).Tables["colorDataGridRow"].Rows[0]["MouseOver"].ToString(); e.Row.Style.Add("valign", "top"); e.Row.Style.Add("cursor", "hand"); e.Row.Attributes.Add("onMouseOver", "this.style.backgroundColor='" + strMouseOverColor + "'"); if (e.Row.RowState.Equals(DataControlRowState.Alternate)) { e.Row.Attributes.Add("bgcolor", strOddColor); e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor='" + strOddColor + "'"); } else { e.Row.Attributes.Add("bgcolor", strEvenColor); e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor='" + strEvenColor + "'"); } #endregion Label lblNo = (Label)e.Row.FindControl("lblNo"); Label lblloan_doc = (Label)e.Row.FindControl("lblloan_doc"); int nNo = (GridView1.PageSize * GridView1.PageIndex) + e.Row.RowIndex + 1; lblNo.Text = nNo.ToString(); DataRowView dv = (DataRowView)e.Row.DataItem; HiddenField hddloan_id = (HiddenField)e.Row.FindControl("hddloan_id"); Label lblLoan_status = (Label)e.Row.FindControl("lblLoan_status"); Repeater Repeater1 = (Repeater)e.Row.FindControl("Repeater1"); if (Helper.CStr(dv["loan_status"]) == "P") { lblLoan_status.Text = "รออนุมัติ"; } else if (Helper.CStr(dv["loan_status"]) == "A") { lblLoan_status.Text = "อนุมัติ"; } else if (Helper.CStr(dv["loan_status"]) == "N") { lblLoan_status.Text = "ไม่อนุมัติ"; } else if (Helper.CStr(dv["loan_status"]) == "X") { lblLoan_status.Text = "อนุมัติบางส่วน"; } else if (Helper.CStr(dv["loan_status"]) == "W") { lblLoan_status.Text = "รายการยังไม่สมบูรณ์"; } else if (Helper.CStr(dv["loan_status"]) == "C") { lblLoan_status.Text = "ยกเลิกรายการ"; } else if (Helper.CStr(dv["loan_status"]) == "S") { lblLoan_status.Text = "ชำระคืนบางส่วน"; } else if (Helper.CStr(dv["loan_status"]) == "F") { lblLoan_status.Text = "ชำระคืนหมดแล้ว"; } var dt = objEfLoan.SP_LOAN_DETAIL_APPROVE_SEL(" and loan_id=" + Helper.CLong(dv["loan_id"]) + " order by approve_level"); Repeater1.DataSource = dt; Repeater1.DataBind(); #region set Image Edit & Delete ImageButton imgView = (ImageButton)e.Row.FindControl("imgView"); imgView.Attributes.Add("onclick", "OpenPopUp('950px','550px','95%','แสดงรายละเอียด" + base.PageDes + "','loan_control.aspx?budget_type=" + dv["budget_type"].ToString() + "&mode=view&loan_id=" + hddloan_id.Value + "&page=" + GridView1.PageIndex.ToString() + "&canEdit=Y','1');return false;"); imgView.ImageUrl = ((DataSet)Application["xmlconfig"]).Tables["imgView"].Rows[0]["img"].ToString(); imgView.Attributes.Add("title", ((DataSet)Application["xmlconfig"]).Tables["imgView"].Rows[0]["title"].ToString()); imgView.Visible = base.IsUserView; ImageButton imgEdit = (ImageButton)e.Row.FindControl("imgEdit"); imgEdit.Attributes.Add("onclick", "OpenPopUp('950px','550px','95%','แก้ไข" + base.PageDes + "','loan_control.aspx?budget_type=" + dv["budget_type"].ToString() + "&mode=edit&loan_id=" + hddloan_id.Value + "&page=" + GridView1.PageIndex.ToString() + "&canEdit=Y','1');return false;"); imgEdit.ImageUrl = ((DataSet)Application["xmlconfig"]).Tables["imgEdit"].Rows[0]["img"].ToString(); imgEdit.Attributes.Add("title", ((DataSet)Application["xmlconfig"]).Tables["imgEdit"].Rows[0]["title"].ToString()); imgEdit.Visible = base.IsUserEdit; if (base.UserGroupCode != "Admin") { imgEdit.Visible = imgEdit.Visible && Helper.CStr(dv["loan_status"]) == "W" || base.IsUserApprove; } ImageButton imgDelete = (ImageButton)e.Row.FindControl("imgDelete"); imgDelete.ImageUrl = ((DataSet)Application["xmlconfig"]).Tables["imgDelete"].Rows[0]["img"].ToString(); imgDelete.Attributes.Add("title", ((DataSet)Application["xmlconfig"]).Tables["imgDelete"].Rows[0]["title"].ToString()); imgDelete.Attributes.Add("onclick", "return confirm(\"คุณต้องการลบสัญญาการยืมเงิน : " + lblloan_doc.Text + " ?\");"); imgDelete.Visible = base.IsUserDelete && Helper.CStr(dv["loan_status"]) != "C";; if (base.UserGroupCode != "Admin") { imgDelete.Visible = imgDelete.Visible && Helper.CStr(dv["loan_status"]) == "W" && (Helper.CStr(dv["person_code"]) == base.PersonCode || Helper.CStr(dv["person_code"]) == base.ApproveFor); } ImageButton imgPrint = (ImageButton)e.Row.FindControl("imgPrint"); imgPrint.ImageUrl = "../../images/controls/print.png"; imgPrint.Attributes.Add("title", "พิมพ์"); imgPrint.Attributes.Add("onclick", "OpenPopUp('550px','280px','92%','เลือกรายงานที่ต้องการพิมพ์','loan_print.aspx?loan_id=" + hddloan_id.Value + "','1');return false;"); //imgPrint.Visible = Helper.CStr(dv["loan_status"]) != "W" && Helper.CStr(dv["loan_status"]) != "C"; imgPrint.Visible = true; if (base.UserGroupCode != "Admin" && base.UserGroupCode != "Loan") { imgPrint.Visible = imgPrint.Visible && (Helper.CStr(dv["person_code"]) == base.PersonCode || Helper.CStr(dv["person_code"]) == base.ApproveFor); } #endregion if (!imgDelete.Visible && Helper.CStr(dv["loan_status"]) == "C") { ImageButton imgRestore = (ImageButton)e.Row.FindControl("imgRestore"); imgRestore.ImageUrl = "../../images/back_2.png"; imgRestore.Attributes.Add("title", "คืนรายการ"); imgRestore.Attributes.Add("onclick", "return confirm(\"คุณต้องการคืนรายการขอยืมเงิน : " + lblloan_doc.Text + " หรือไม่? เมื่อทำการคืนรายการท่านจะสามารถแก้ไขข้อมูลใดๆ ได้\");"); imgRestore.Visible = base.IsUserDelete; if (base.UserGroupCode != "Admin") { imgRestore.Visible = false; } } if (Helper.CStr(dv["loan_status"]) == "W") { ImageButton imgPass = (ImageButton)e.Row.FindControl("imgPass"); imgPass.ImageUrl = "../../images/move.png"; imgPass.Attributes.Add("title", "ผ่านรายการ"); imgPass.Attributes.Add("onclick", "return confirm(\"คุณต้องการผ่านรายการขอยืมเงิน : " + lblloan_doc.Text + " หรือไม่? เมื่อทำการผ่านรายการท่านจะไม่สามารถแก้ไขข้อมูลใดๆ ได้\");"); imgPass.Visible = Helper.CStr(dv["loan_status"]) == "W"; if (base.UserGroupCode != "Admin") { imgPass.Visible = (base.PersonCode == Helper.CStr(dv["person_code"]) || base.ApproveFor == Helper.CStr(dv["person_code"])); } } if ((Helper.CStr(dv["loan_status"]) == "A" || Helper.CStr(dv["loan_status"]) == "S" || Helper.CStr(dv["loan_status"]) == "F") && (base.UserGroupCode != "Loan" && base.UserGroupCode != "Admin")) //if (base.UserGroupCode != "Loan" && base.UserGroupCode != "Admin") { imgEdit.Visible = false; } //if (Helper.CStr(dv["loan_status"]) == "A") //{ // imgEdit.Visible = false; //} Repeater RepeaterOpen = (Repeater)e.Row.FindControl("RepeaterOpen"); dt = objEfOpen.SP_OPEN_LOAN_SEL(" and loan_id=" + Helper.CInt(dv["loan_id"])); RepeaterOpen.DataSource = dt; RepeaterOpen.DataBind(); objEfOpen.Dispose(); } }