public void fillRefList(string schtitle, string schfldidtext, string schflddesctext, string query, bool withRefCode, bool FrameMode) { _frmmode = FrameMode; dbtimeout = (int)Session["dbTimeOut"]; ConnString = (string)Session["ConnStringLogin"]; using (conn = new DbConnection(ConnString)) { MyPage.fillRefListINA(DDL.Items, query, null, dbtimeout, withRefCode, conn); } if (DDL.Items.Count <= _maxItems) { _ddlmode = true; d1.Visible = false; d2.Visible = false; CODE.EnableViewState = false; DESC.EnableViewState = false; } else { _ddlmode = false; DDL.Items.Clear(); DDL.EnableViewState = false; DDL.Visible = false; if (_frmmode) { d1.Visible = true; d2.Visible = false; CODE.EnableViewState = false; DESC.EnableViewState = false; if (schtitle != null && schtitle.Trim() != "") { _frsrc += "&fT=" + schtitle.Replace(" ", "_"); } if (schfldidtext != null && schfldidtext.Trim() != "") { _frsrc += "&idTx=" + schfldidtext; } if (schflddesctext != null && schflddesctext.Trim() != "") { _frsrc += "&deTx=" + schflddesctext; } _frsrc += "&qry=" + HttpUtility.UrlEncode(query.Replace("'", "|:|")); } else { d1.Visible = false; d2.Visible = true; CODE.EnableViewState = true; DESC.EnableViewState = true; _query = query; string qrystr = "CtrlID=" + CODE.ClientID + "&CtrlDesc=" + DESC.ClientID; if (schfldidtext != null && schfldidtext.Trim() != "") { qrystr += "&idTx=" + schfldidtext; } if (schflddesctext != null && schflddesctext.Trim() != "") { qrystr += "&deTx=" + schflddesctext; } if (schtitle == null) { schtitle = ""; } qrystr += "&qry=" + HttpUtility.UrlEncode(query.Replace("'", "|:|")); SearchBtnAttribute(qrystr, schtitle.Replace(" ", "_")); } } Enabled = _Enabled; if (_Width != 0) { Width = _Width; } if (_TabIndex != 0) { TabIndex = _TabIndex; } if (_CssClass != null) { CssClass = _CssClass; } }
public void fillRefList(string schtitle, string schfldidtext, string schflddesctext, string tblname, string fldid, string flddesc, string cond, string orderby, bool withRefCode, bool FrameMode) { _frmmode = FrameMode; dbtimeout = (int)Session["dbTimeOut"]; ConnString = (string)ConfigurationSettings.AppSettings["connString"].ToString(); string query = "select " + fldid + ", " + flddesc + " from " + tblname; if (cond != null && cond.Trim() != "") { query += " where " + cond; } if (orderby != null && orderby.Trim() != "") { query += " order by " + orderby; } using (conn = new DbConnection(ConnString)) { MyPage.fillRefListINA(DDL.Items, query, null, dbtimeout, withRefCode, conn); } if (DDL.Items.Count <= _maxItems) { _ddlmode = true; d1.Visible = false; d2.Visible = false; CODE.EnableViewState = false; DESC.EnableViewState = false; } else { _ddlmode = false; DDL.Items.Clear(); DDL.EnableViewState = false; DDL.Visible = false; if (_frmmode) { d1.Visible = true; d2.Visible = false; CODE.EnableViewState = false; DESC.EnableViewState = false; if (schtitle != null && schtitle.Trim() != "") { _frsrc += "&fT=" + schtitle.Replace(" ", "_"); } if (schfldidtext != null && schfldidtext.Trim() != "") { _frsrc += "&idTx=" + schfldidtext; } if (schflddesctext != null && schflddesctext.Trim() != "") { _frsrc += "&deTx=" + schflddesctext; } _frsrc += "&tbl=" + tblname; _frsrc += "&fid=" + fldid; _frsrc += "&fdesc=" + flddesc; if (cond != null && cond.Trim() != "") { _frsrc += "&cond=" + HttpUtility.UrlEncode(cond.Replace("'", "|:|")); } if (orderby != null && orderby.Trim() != "") { _frsrc += "&sort=" + HttpUtility.UrlEncode(orderby); } } else { d1.Visible = false; d2.Visible = true; CODE.EnableViewState = true; DESC.EnableViewState = true; _tblname = tblname; _fldid = fldid; _flddesc = flddesc; _cond = cond; _orderby = orderby; string qrystr = "CtrlID=" + CODE.ClientID + "&CtrlDesc=" + DESC.ClientID; if (schfldidtext != null && schfldidtext.Trim() != "") { qrystr += "&idTx=" + schfldidtext; } if (schflddesctext != null && schflddesctext.Trim() != "") { qrystr += "&deTx=" + schflddesctext; } if (schtitle == null) { schtitle = ""; } qrystr += "&tbl=" + tblname; qrystr += "&fid=" + fldid; qrystr += "&fdesc=" + flddesc; if (cond != null && cond.Trim() != "") { qrystr += "&cond=" + HttpUtility.UrlEncode(cond.Replace("'", "|:|")); } if (orderby != null && orderby.Trim() != "") { qrystr += "&sort=" + HttpUtility.UrlEncode(orderby); } SearchBtnAttribute(qrystr, schtitle.Replace(" ", "_")); } } Enabled = _Enabled; if (_Width != 0) { Width = _Width; } if (_TabIndex != 0) { TabIndex = _TabIndex; } if (_CssClass != null) { CssClass = _CssClass; } }
protected void CODE_TextChanged(object sender, System.EventArgs e) { if (CODE.Text.Trim() == "") { CODE.Text = ""; DESC.Text = ""; if (AutoPostBack && _oldvalue != CODE.Text) { _oldvalue = CODE.Text; OnSelectedIndexChanged(e); } return; } dbtimeout = (int)Session["dbTimeOut"]; ConnString = (string)ConfigurationSettings.AppSettings["connString"].ToString(); //WebControl ctrl; using (conn = new DbConnection(ConnString)) { if (_query == null || _query.Trim() == "") { string qry = "select " + _fldid + ", " + _flddesc + " from " + _tblname; if (_cond != null && _cond.Trim() != "") { qry += " where (" + _cond + ") and " + _fldid + " = '" + CODE.Text + "'"; } else { qry += " where " + _fldid + " = '" + CODE.Text + "'"; } conn.ExecReader(qry, null, dbtimeout); if (conn.hasRow()) { DESC.Text = conn.GetFieldValue(1); //ctrl = CommonForm.ModuleSupport.NextCtrl(this.Parent.Page, CODE); //if (ctrl != null) // MyPage.SetFocus(this.Parent.Page, ctrl); } else { CODE.Text = ""; DESC.Text = ""; MyPage.popMessage(this.Parent.Page, "Kode tidak ditemukan"); MyPage.SetFocus(this.Parent.Page, CODE); } } else { ListItemCollection items = new ListItemCollection(); MyPage.fillRefListINA(items, _query, null, dbtimeout, false, conn); try { int i = 0; for (i = 0; i < items.Count; i++) { if (items[i].Value.ToLower() == CODE.Text.ToLower()) //found { CODE.Text = items[i].Value; DESC.Text = items[i].Text; break; } } //ctrl = CommonForm.ModuleSupport.NextCtrl(this.Parent.Page, CODE); //if (ctrl != null) // MyPage.SetFocus(this.Parent.Page, ctrl); if (i == items.Count) // not found { CODE.Text = ""; DESC.Text = ""; MyPage.popMessage(this.Parent.Page, "Kode tidak ditemukan"); MyPage.SetFocus(this.Parent.Page, CODE); } } catch { CODE.Text = ""; DESC.Text = ""; MyPage.popMessage(this.Parent.Page, "Kode tidak ditemukan"); MyPage.SetFocus(this.Parent.Page, CODE); } } } if (AutoPostBack && _oldvalue != CODE.Text) { _oldvalue = CODE.Text; OnSelectedIndexChanged(e); } }