protected void txtBusquedaFormulario_OnDataSourceSelect(object sender, SearchBoxDataSourceSelectEventArgs e) { try { ObjectDataSource source = (ObjectDataSource)e.DataSource; RadSearchBox searchBox = (RadSearchBox)sender; if (e.SelectedContextItem.Key != IdAreaSeleccionada.ToString()) { source.SelectParameters["idUsuarioSolicita"].DefaultValue = Session["IdUsuarioSolicita"].ToString(); source.SelectParameters["idUsuarioLevanta"].DefaultValue = ((Usuario)Session["UserData"]).Id.ToString(); source.SelectParameters["idArea"].DefaultValue = e.SelectedContextItem.Key; source.SelectParameters["keys"].DefaultValue = e.FilterString; source.DataBind(); } } catch (Exception ex) { if (_lstError == null) { _lstError = new List <string>(); } _lstError.Add(ex.Message); Alerta = _lstError; } }
protected void radSearchUser_Search(object sender, SearchBoxEventArgs e) { RadSearchBox searchBox = (RadSearchBox)sender; string userId = string.Empty; string likeCondition; Guid userid = new Guid(); if (e.DataItem != null) { userId = ((Dictionary <string, object>)e.DataItem)["UserId"].ToString(); userid = Guid.Parse(userId); if (!string.IsNullOrEmpty(userId)) { likeCondition = string.Format("'{0}{1}%'", searchBox.Filter == SearchBoxFilter.Contains ? "%" : "", ((Dictionary <string, object>)e.DataItem)["UserId"].ToString()); RadGrid2.DataSource = GetUserbyUserId(userid); RadGrid2.DataBind(); } } else { RadGrid2.DataSource = GetUsers(); RadGrid2.DataBind(); } }
protected void radSearchEmployee_Search(object sender, SearchBoxEventArgs e) { RadSearchBox searchBox = (RadSearchBox)sender; string employeeId = string.Empty; string likeCondition; Guid empId = new Guid(); if (e.DataItem != null) { employeeId = ((Dictionary <string, object>)e.DataItem)["EmployeeId"].ToString(); empId = Guid.Parse(employeeId); if (!string.IsNullOrEmpty(employeeId)) { likeCondition = string.Format("'{0}{1}%'", searchBox.Filter == SearchBoxFilter.Contains ? "%" : "", ((Dictionary <string, object>)e.DataItem)["EmployeeId"].ToString()); //gridEmployeeDataSource.SelectCommand = "SELECT [EmployeeId], [FirstName] , [MiddleName], [LastName], [BirthDate], [ContactNo], [Email], [CreatedDate]" + " FROM[Employee] WHERE RecordStatus = 1 AND [" + searchBox.DataValueField + "] LIKE " + likeCondition; //RadGrid2.DataBind(); RadGrid2.DataSource = GetEmployeebyEmployeeId(empId); //RadGrid2.DataSource = "SELECT [EmployeeId], [FirstName] , [MiddleName], [LastName], [BirthDate], [ContactNo], [Email], [CreatedDate]" + " FROM [Employee] WHERE RecordStatus = 1 and FirstName = [" + searchBox.Text + "] OR LastName = [" + searchBox.Text + "] or BirthDate = [" + searchBox.Text + "] "; RadGrid2.DataBind(); // string search = radSearchEmployee.Text; } } else { RadGrid2.DataSource = GetEmployee(); RadGrid2.DataBind(); } }
protected void radSearchawbIssuance_Search(object sender, SearchBoxEventArgs e) { RadSearchBox searchBox = (RadSearchBox)sender; string id = string.Empty; string likeCondition; Guid awbId = new Guid(); Guid bcoId = new Guid(); if (e.DataItem != null) { // id = ((Dictionary<string, object>)e.DataItem)["AwbIssuanceId"].ToString(); var dataItem = ((Dictionary <string, object>)e.DataItem); var awbIssuanceId = dataItem["AwbIssuanceId"].ToString(); var bco = dataItem["BCOid"].ToString(); awbId = Guid.Parse(awbIssuanceId); bcoId = Guid.Parse(bco); if (!string.IsNullOrEmpty(id)) { likeCondition = string.Format("'{0}{1}%'", searchBox.Filter == SearchBoxFilter.Contains ? "%" : "", ((Dictionary <string, object>)e.DataItem)["AwbIssuanceId"].ToString()); RadGrid2.DataSource = GetAwbIssuanceById(bcoId, awbId); RadGrid2.DataBind(); } } else { RadGrid2.DataSource = GetAWBIssuance(); RadGrid2.DataBind(); } }
protected void radCompany_Search(object sender, SearchBoxEventArgs e) { RadSearchBox searchBox = (RadSearchBox)sender; string companyId = string.Empty; string likeCondition; Guid compId = new Guid(); if (e.DataItem != null) { companyId = ((Dictionary <string, object>)e.DataItem)["CompanyId"].ToString(); compId = Guid.Parse(companyId); if (!string.IsNullOrEmpty(companyId)) { likeCondition = string.Format("'{0}{1}%'", searchBox.Filter == SearchBoxFilter.Contains ? "%" : "", ((Dictionary <string, object>)e.DataItem)["CompanyId"].ToString()); RadGrid2.DataSource = GetCompanyById(compId); RadGrid2.DataBind(); } } else { RadGrid2.DataSource = GetCompany(); RadGrid2.DataBind(); } }
//} void BindDataSource(RadSearchBox searchBox) { var companyID = SessionManager.UserContext.WorkingLocation.Company.COMPANY_ID; var personDataList = SQMModelMgr.SelectPlantPersonDataList(companyID, PlantID); searchBox.DataSource = personDataList; searchBox.DataValueField = "PersonID"; searchBox.DataTextField = "PersonName"; searchBox.DataBind(); searchBox.EnableAutoComplete = true; searchBox.Enabled = Access; }
protected void radSearchawbIssuance_DataSourceSelect(object sender, SearchBoxDataSourceSelectEventArgs e) { SqlDataSource source = (SqlDataSource)e.DataSource; RadSearchBox searchBox = (RadSearchBox)sender; // string likeCondition = string.Format("'{0}' + @filterString + '%'", searchBox.Filter == SearchBoxFilter.Contains ? "%" : ""); string likeCondition = "Arjay De Torres Tabangay"; string countCondition = e.ShowAllResults ? " " : " TOP " + searchBox.MaxResultCount + 1; string condition = ""; if (e.SelectedContextItem != null) { condition = string.Format("{0}", e.SelectedContextItem.Key); } //source.SelectCommand = string.Format("SELECT {0} * FROM [AwbIssuance] WHERE {1}", countCondition, likeCondition); source.SelectCommand = string.Format("SELECT {0} * FROM (SELECT awb.*, bco.BranchCorpOfficeName, ru.RevenueUnitName, emp.FirstName + ' ' + emp.MiddleName + ' ' + emp.LastName AS Name from AwbIssuance awb LEFT join BranchCorpOffice bco on awb.BCOid = bco.BranchCorpOfficeId LEFT join RevenueUnit ru on awb.RevenueUnitId = ru.RevenueUnitId LEFT join Employee emp on awb.IssuedToId = emp.EmployeeId where awb.RecordStatus = 1 and [bco.BranchCorpOfficeId] = '{1}'') AS inner_table WHERE Name LIKE {2}", countCondition, condition, likeCondition); source.SelectParameters.Add("filterString", e.FilterString.Replace("%", "[%]").Replace("_", "[_]")); }
protected void radSearchUser_Search(object sender, SearchBoxEventArgs e) { RadSearchBox searchBox = (RadSearchBox)sender; string SOAnumber = string.Empty; if (e.DataItem != null) { SOAnumber = e.Text; RadGrid2.DataSource = DataSource.AsEnumerable().Where(x => x.Field <String>("StatementOfAccountNo").Contains(SOAnumber)); RadGrid2.DataBind(); } else { RadGrid2.DataSource = DataSource; RadGrid2.DataBind(); } }
// Set the controls by the value of the parameters private void SetControlObjectByValue(Control aControl, string aValue) { string _type = aControl.GetType().Name; if (_type == "RadTextBox") { RadTextBox _box = (RadTextBox)aControl; _box.Text = aValue; } else if (_type == "RadDropDownList") { RadDropDownList _list = (RadDropDownList)aControl; DropDownListItem _item = _list.FindItemByValue(aValue); int _selectedIndex = 0; if (_item != null) { _selectedIndex = _item.Index; } _list.SelectedIndex = _selectedIndex; } else if (_type == "RadNumericTextBox") { RadNumericTextBox _numeric = (RadNumericTextBox)aControl; _numeric.Value = Convert.ToDouble(aValue); } else if (_type == "RadSearchBox") { RadSearchBox _search = (RadSearchBox)aControl; if (aValue.Contains('^')) { string[] _splitForContext = aValue.Split('^'); _search.Text = _splitForContext[0].Trim(); int _selectedCtx = Convert.ToInt32(_splitForContext[1].Trim()); if (_selectedCtx != -1) { _search.SearchContext.Items[_selectedCtx].Selected = true; } } else { _search.Text = aValue; } } else if (_type == "RadComboBox") { RadComboBox _combo = (RadComboBox)aControl; if (_combo.CheckBoxes) { for (int i = 0; i < _combo.Items.Count; i++) { _combo.Items[i].Checked = aValue[i] == '1'; } } else { RadComboBoxItem _item = _combo.FindItemByValue(aValue); if (_item != null) { _item.Selected = true; } else { _combo.Text = aValue; } } } else if (_type == "RadButton") { RadButton _button = (RadButton)aControl; // TODO: Set all checks here if (_button.ToggleType == ButtonToggleType.CustomToggle) { _button.SelectedToggleStateIndex = Convert.ToInt32(aValue); } // For everything else else { _button.Checked = aValue == "1"; } } else if (_type == "RadDatePicker") { RadDatePicker _date = (RadDatePicker)aControl; _date.SelectedDate = DateTime.Parse(aValue); } else if (_type == "RadTabStrip") { RadTabStrip _tabstrip = (RadTabStrip)aControl; int _index = Convert.ToInt32(aValue); _tabstrip.SelectedIndex = _index; _tabstrip.MultiPage.SelectedIndex = _index; } }
// Gets the value used by the control private string GetControlValue(Control aControl) { string _value = null; //Find the control type string _type = aControl.GetType().Name; if (_type == "RadTextBox") { RadTextBox _box = (RadTextBox)aControl; if (!String.IsNullOrEmpty(_box.Text)) { _value = _box.Text; } } else if (_type == "RadDropDownList") { RadDropDownList _list = (RadDropDownList)aControl; if (_list.SelectedIndex != 0) { _value = _list.SelectedValue; } } else if (_type == "RadNumericTextBox") { RadNumericTextBox _numeric = (RadNumericTextBox)aControl; if (!String.IsNullOrEmpty(_numeric.Value.ToString())) { _value = _numeric.Value.ToString(); } } else if (_type == "RadSearchBox") { RadSearchBox _search = (RadSearchBox)aControl; if (!String.IsNullOrEmpty(_search.Text)) { _value = _search.Text; if (_search.SearchContext.Items.Count != 0) { _value += "^" + _search.SearchContext.SelectedIndex; } } } //TODO: Multichecklist - what do // Comboboxes can be hard. this might need rework in later future else if (_type == "RadComboBox") { RadComboBox _combo = (RadComboBox)aControl; // if the combobox includes checkboxes if (_combo.CheckBoxes) { foreach (RadComboBoxItem _item in _combo.Items) { // return the value as 1 or 0 ( checked / unchecked ) _value += _item.Checked ? "1" : "0"; } } else if (!String.IsNullOrEmpty(_combo.SelectedValue)) { _value = _combo.SelectedValue; } } else if (_type == "RadButton") { RadButton _button = (RadButton)aControl; // TODO: Set all checks here if (_button.ToggleType == ButtonToggleType.CustomToggle) { _value = _button.SelectedToggleStateIndex.ToString(); } // For everything else else { _value = _button.Checked ? "1" : "0"; } } else if (_type == "RadDatePicker") { RadDatePicker _date = (RadDatePicker)aControl; // Use icelandic dates if (_date.SelectedDate != null) { _value = ((DateTime)_date.SelectedDate).ToString("dd.MM.yyyy"); } } else if (_type == "RadTabStrip") { RadTabStrip _tabstrip = (RadTabStrip)aControl; _value = _tabstrip.SelectedIndex.ToString(); } return(_value); }