private DataRow[] Parse(bool throwEvent = true) { // throwEvent - выбрасывать event или нет, если 1 совпадение // возврат - число совпадений string txt = text.Text.Trim(); DataRow[] drs = docTypeParser.ParseQuery(txt); int count = 0; ID = 0; if ((drs != null) && (drs.Length > 0)) { count = drs.Length; if (count == 1) { DataRow dr = drs[0]; var gotID = (int)dr[Environment.DocTypeData.IDField]; SearchType = (byte)dr[Environment.DocTypeData.SearchTypeField]; if (throwEvent) { ThrowEvent(gotID, (string)CultureObj(dr)); } else { ID = gotID; } } } UpdateButtonSelect(count); return(drs); }
private void FillTypes() { types.Items.Clear(); string txt = filter.Text.Trim(); if (txt == "" || !checkBoxType.Checked) { if (dsTypes != null && dsTypes.Tables.Count > 0) { DataTable dt = dsTypes.Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { AddRow(dt.Rows[i], types); } } } else { DataRow[] drs = docTypeParser.ParseQuery(txt); if (drs != null && drs.Length > 0) { foreach (DataRow t in drs) { AddRow(t, types); } } } }
private void OnLoad(object sender, EventArgs e) { if (DesignerDetector.IsComponentInDesignMode(this)) { return; } // loading doc types if (Environment.DocTypeData != null) { if (Environment.DocTypes != null) { docTypeParser = new DocTypeParser(Environment.DocTypeData, Environment.DocTypes); if (ID > 0) { bool parsed = false; text.Text = Environment.DocTypeData.GetDocType(ID, Environment.CurCultureInfo.TwoLetterISOLanguageName); DataRow[] drs = docTypeParser.ParseQuery(text.Text); if (drs != null) { foreach (DataRow t in drs.Where(t => t[Environment.DocTypeData.IDField].Equals(ID))) { SearchType = (byte)t[Environment.DocTypeData.SearchTypeField]; Text = t[Environment.CurCultureInfo.TwoLetterISOLanguageName.Equals("ru") ? Environment.DocTypeData.NameField : Environment.DocTypeData.TypeDocField].ToString(); parsed = true; break; } } if (!parsed) { ID = 0; text.Text = ""; } } } else { throw new Exception("DocTypeBlock: " + Environment.StringResources.GetString("DocTypeBlock_OnLoad_Error1")); } } else { if (!DesignerDetector.IsComponentInDesignMode(this)) { throw new Exception("DocTypeBlock: " + Environment.StringResources.GetString("DocTypeBlock_OnLoad_Error2") + " (Data)."); } } }
private void FillTypes() { types.Items.Clear(); string txt = filter.Text.Trim(); if (string.IsNullOrEmpty(txt)) { if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { AddRow(dt.Rows[i], types); } } } else { DataRow[] drs = docTypeParser.ParseQuery(txt); if (drs != null && drs.Length > 0) { foreach (DataRow t in drs) { AddRow(t, types); } } } if (TypeID != 0) { for (int i = 0; i < types.Items.Count; i++) { var item = (ListItem)types.Items[i]; if (item.ID == TypeID) { TypeID = 0; item.Selected = true; item.EnsureVisible(); break; } } } }