protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { GridViewRow gvRow = null; HiddenField hddloan_id = null; switch (e.CommandName) { case "Pass": case "Restore": gvRow = GridView1.Rows[Helper.CInt(e.CommandArgument) - 1]; hddloan_id = (HiddenField)gvRow.FindControl("hddloan_id"); break; default: break; } cefLoan objefLoan = new cefLoan(); switch (e.CommandName) { case "Pass": try { if (objefLoan.SP_LOAN_HEAD_PASS(Helper.CInt(hddloan_id.Value))) { BindGridView(0); } } catch (Exception ex) { lblError.Text = ex.Message.ToString(); } finally { objefLoan.Dispose(); } break; case "Restore": try { if (objefLoan.SP_LOAN_HEAD_RESTORE(Helper.CInt(hddloan_id.Value))) { BindGridView(0); } } catch (Exception ex) { lblError.Text = ex.Message.ToString(); } finally { objefLoan.Dispose(); } break; default: break; } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { var hddloan_id = (HiddenField)GridView1.Rows[e.RowIndex].FindControl("hddloan_id"); var objEfLoan = new cefLoan(); try { //if (objEfLoan.SP_LOAN_APPROVE_ALL_DEL(Helper.CInt(hddloan_id.Value)) && // objEfLoan.SP_LOAN_DETAIL_ALL_DEL(Helper.CInt(hddloan_id.Value)) && if (objEfLoan.SP_LOAN_HEAD_DEL(Helper.CInt(hddloan_id.Value))) { BindGridView(0); } } catch (Exception ex) { lblError.Text = ex.Message; } finally { objEfLoan.Dispose(); } }
private void BindGridView() { var objEfLoan = new cefLoan(); var dt = new DataTable(); string strMessage = string.Empty; string strCriteria = string.Empty; string strloan_doc = string.Empty; string strloan_reason = string.Empty; string strperson_code = string.Empty; string strperson_name = string.Empty; string strScript = string.Empty; strloan_doc = txtloan_doc.Text.Replace("'", "''").Trim(); strloan_reason = txtloan_reason.Text.Replace("'", "''").Trim(); strperson_code = txtperson_code.Text.Replace("'", "''").Trim(); strperson_name = txtperson_name.Text.Replace("'", "''").Trim(); if (!strloan_doc.Equals("")) { strCriteria += " And (loan_doc like '%" + strloan_doc + "%') "; } if (!strloan_reason.Equals("")) { strCriteria += " And (loan_reason like '%" + strloan_reason + "%') "; } if (!strperson_code.Equals("")) { strCriteria = strCriteria + " And (person_code= '" + strperson_code + "') "; } if (!strperson_name.Equals("")) { strCriteria = strCriteria + " And (person_thai_name like '%" + strperson_name + "%' " + " OR person_thai_surname like '%" + strperson_name + "%' " + " OR '" + strperson_name + "' like ('%'+person_thai_name+'%'+person_thai_surname+'%')) "; } if (ViewState["loan_doc_list"].ToString().Length > 0) { strCriteria = strCriteria + " And loan_doc not in (" + ViewState["loan_doc_list"] + ") "; } try { dt = objEfLoan.SP_LOAN_HEAD_SEL(strCriteria); //if (dt.Rows.Count == 1) //{ // string strloan_id = dt.Rows[0]["loan_id"].ToString(); // strloan_doc = dt.Rows[0]["loan_doc"].ToString(); // strloan_reason = dt.Rows[0]["loan_reason"].ToString(); // string strloan_date = cCommon.CheckDate(dt.Rows[0]["loan_date"].ToString()); // string strloan_req = Helper.CDbl(dt.Rows[0]["loan_req"].ToString()).ToString("N2"); // if (!ViewState["show"].ToString().Equals("1")) // { // strScript = "window.parent.frames['iframeShow" + (int.Parse(ViewState["show"].ToString()) - 1) + "'].document.getElementById('" + ViewState["ctrl1"] + "').value='" + strloan_id + "';\n " + // "window.parent.frames['iframeShow" + (int.Parse(ViewState["show"].ToString()) - 1) + "'].document.getElementById('" + ViewState["ctrl2"] + "').value='" + strloan_doc + "';\n" + // "window.parent.frames['iframeShow" + (int.Parse(ViewState["show"].ToString()) - 1) + "'].document.getElementById('" + ViewState["ctrl3"] + "').value='" + strloan_reason + "';\n" + // "window.parent.frames['iframeShow" + (int.Parse(ViewState["show"].ToString()) - 1) + "'].document.getElementById('" + ViewState["ctrl4"] + "').value='" + strloan_date + "';\n" + // "window.parent.frames['iframeShow" + (int.Parse(ViewState["show"].ToString()) - 1) + "'].document.getElementById('" + ViewState["ctrl5"] + "').value='" + strloan_req + "';\n" + // "ClosePopUp('" + ViewState["show"] + "');"; // if (ViewState["from"].ToString() == "open_control") // { // strScript += "window.parent.frames['iframeShow" + (int.Parse(ViewState["show"].ToString()) - 1) + "'].__doPostBack('ctl00$ContentPlaceHolder1$lbkGetOpen','');"; // } // } // else // { // strScript = "window.parent.document.getElementById('" + ViewState["ctrl1"] + "').value='" + strloan_id + "';\n " + // "window.parent.document.getElementById('" + ViewState["ctrl2"] + "').value='" + strloan_doc + "';\n" + // "window.parent.document.getElementById('" + ViewState["ctrl3"] + "').value='" + strloan_reason + "';\n" + // "window.parent.document.getElementById('" + ViewState["ctrl4"] + "').value='" + strloan_date + "';\n" + // "window.parent.document.getElementById('" + ViewState["ctrl5"] + "').value='" + strloan_req + "';\n" + // "ClosePopUp('" + ViewState["show"] + "');"; // } // ScriptManager.RegisterStartupScript(Page, Page.GetType(), "close", strScript, true); //} //else //{ // dt.DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"]; // GridView1.DataSource = dt; // GridView1.DataBind(); //} dt.DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"]; GridView1.DataSource = dt; GridView1.DataBind(); } catch (Exception ex) { lblError.Text = ex.Message; } finally { objEfLoan.Dispose(); } }
private void BindGridView(int nPageNo) { //InitcboYear(); cefLoan objEfLoan = new cefLoan(); DataTable dt = new DataTable(); string strCriteria = string.Empty; string strloan_doc = string.Empty; string strbudget_plan_year = string.Empty; string strloan_reason = string.Empty; string strbudget_code = string.Empty; string strunit_code = string.Empty; string strdirector_code = string.Empty; string strbudget_type = string.Empty; string strLoan_status = string.Empty; string strperson_code = string.Empty; string strperson_name = string.Empty; string strScript = string.Empty; #region Criteria strloan_doc = txtloan_doc.Text; strbudget_plan_year = cboYear.SelectedValue; strdirector_code = cboDirector.SelectedValue; strunit_code = cboUnit.SelectedValue; strloan_reason = txtloan_reason.Text.Trim(); strbudget_type = cboBudget_type.SelectedValue; strLoan_status = cboLoanStatus.SelectedValue; strperson_name = txtperson_name.Text.Trim(); strperson_code = txtperson_code.Text.Trim(); var strbegin_date = txtfrom_date.Text.Length > 0 ? cCommon.SeekDate(txtfrom_date.Text) : ""; var strend_date = txtto_date.Text.Length > 0 ? cCommon.SeekDate(txtto_date.Text) : ""; if (!strbudget_plan_year.Equals("")) { strCriteria = strCriteria + " And (loan_year = '" + strbudget_plan_year + "') "; } if (!strbudget_type.Equals("")) { strCriteria = strCriteria + " And (budget_type = '" + strbudget_type + "') "; } if (!strloan_doc.Equals("")) { strCriteria = strCriteria + " And (loan_doc like '%" + strloan_doc + "%') "; } if (!strbudget_code.Equals("")) { strCriteria = strCriteria + " And (budget_code ='" + strbudget_code + "') "; } if (!strdirector_code.Equals("")) { strCriteria = strCriteria + " And (director_code ='" + strdirector_code + "') "; } if (!strunit_code.Equals("")) { strCriteria = strCriteria + " And (unit_code ='" + strunit_code + "') "; } if (!strloan_reason.Equals("")) { strCriteria = strCriteria + " And (loan_reason like '%" + strloan_reason + "%') "; } if (!strLoan_status.Equals("")) { strCriteria = strCriteria + " And (loan_status = '" + strLoan_status + "') "; } if (!strperson_code.Equals("")) { strCriteria = strCriteria + " And (person_code like '%" + strperson_code + "%') "; } if (!strperson_name.Equals("")) { strCriteria = strCriteria + " And (person_thai_name like '%" + strperson_name + "%' " + " OR person_thai_surname like '%" + strperson_name + "%' " + " OR '" + strperson_name + "' like ('%'+person_thai_name+'%'+person_thai_surname+'%')) "; } if (!strbegin_date.Equals("")) { strCriteria += " And (loan_date >= '" + strbegin_date + "') "; } if (!strend_date.Equals("")) { strCriteria += " And (loan_date <= '" + strend_date + "') "; } if (base.UserGroupCode == "User" || base.UserGroupCode == "Supervisor") { strCriteria += " and person_code IN ('" + base.PersonCode + "','" + base.ApproveFor + "')"; } #endregion //strCriteria = strCriteria + " and budget_type ='" + this.BudgetType + "' "; try { dt = objEfLoan.SP_LOAN_HEAD_SEL(strCriteria); try { GridView1.PageIndex = nPageNo; txthTotalRecord.Value = dt.Rows.Count.ToString(); dt.DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"]; GridView1.DataSource = dt; GridView1.DataBind(); } catch { GridView1.PageIndex = 0; txthTotalRecord.Value = dt.Rows.Count.ToString(); dt.DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"]; GridView1.DataSource = dt; GridView1.DataBind(); } } catch (Exception ex) { lblError.Text = ex.Message; } finally { objEfLoan.Dispose(); if (GridView1.Rows.Count > 0) { GridView1.TopPagerRow.Visible = true; } } }