public string getChecked(CheckBoxList chkList, string ColoumnName) { string strParameter = ""; if (chkList != null) { if (chkList.Items.Count > 0) { foreach (ListItem list in chkList.Items) { if (list.Selected) { if (strParameter == "") { strParameter = " (" + ColoumnName + "='" + list.Text.Trim() + "')"; } else { strParameter = strParameter + " or (" + ColoumnName + "='" + list.Text.Trim() + "')"; } } } } } return strParameter; }
public string getchkList(CheckBoxList chkList, string chkListName) { string strParameter = "<h6>" + chkListName + "</h6> <table cellpadding='0' cellspacing='0' border='1' >"; strParameter = strParameter + "<tr>"; string strMiddleData = ""; if (chkList != null) { int count = chkList.Items.Count; int Status = 0; if (chkList.Items.Count > 0) { foreach (ListItem list in chkList.Items) { if (list.Selected) { Status++; strMiddleData = strMiddleData + "<td> " + list.Text + " </td> "; } } } if (Status == count) { strMiddleData = "<td> " + chkListName + " </td> <td> All </td>"; } } strParameter = strParameter + strMiddleData; strParameter = strParameter + "</tr></table>"; return strParameter; }
protected static void SetCheckBoxListValue(ref CheckBoxList cbList, string value) { if (string.IsNullOrEmpty(value)) { foreach (ListItem item in cbList.Items) item.Selected = false; } else { string[] array = value.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); List<string> valueList = new List<string>(); valueList.AddRange(array); for (int i = 0; i < cbList.Items.Count; i++) { ListItem item = cbList.Items[i]; if (valueList.Contains(item.Text)) { item.Selected = true; } else { item.Selected = false; } } } }
protected void gdvData_RowDataBound(object sender, GridViewRowEventArgs e) { Button btn = new Button(); CheckBoxList rbl = new CheckBoxList(); TextBox txt = new TextBox(); int iRow; if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate) { btn = (Button)e.Row.Cells[5].FindControl("btnDelete");//删除按钮 if (DB.getUserPower(Page.User.Identity.Name) == "0") btn.Enabled = false; else if (gdvData.DataKeys[e.Row.RowIndex].Value.ToString() == Page.User.Identity.Name) btn.Enabled = false; else btn.OnClientClick = "if(!confirm('是否要删除该记录?')) return false;"; } if (e.Row.RowState.ToString().IndexOf("Edit") >= 0) { rbl = (CheckBoxList)e.Row.Cells[4].FindControl("cblParent"); txt = (TextBox)e.Row.Cells[1].FindControl("txtLogin"); string curUserID = gdvData.DataKeys[e.Row.RowIndex].Value.ToString(); DataSet ds = DB.getHostsByUserID(curUserID); if (curUserID == "1")//admin用户不允许修改用户名 txt.Enabled = false; if (DB.getUserPower(curUserID) == "-1")//管理用户不允许修改权限 rbl.Enabled = false; iRow = 0; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { for (int j = iRow; j < rbl.Items.Count; j++) { if (rbl.Items[j].Value.ToString() == ds.Tables[0].Rows[i]["nId"].ToString()) { rbl.Items[j].Selected = true; iRow = j+1; break; } } } DropDownList ddlPower = (DropDownList)e.Row.Cells[3].FindControl("ddlPower"); for (int j = 0; j < ddlPower.Items.Count; j++) { if (ddlPower.Items[j].Value == ddlPower.ToolTip) { ddlPower.SelectedIndex = j; break; } } if (DB.getUserPower(Page.User.Identity.Name) == "0") { rbl.Enabled = false; ddlPower.Enabled = false; } } } }
public void can_specify_item_class_for_checkbox_list() { var cssClass = "highClass"; var html = new CheckBoxList("foo.Bar").Options<FakeEnum>().ItemClass(cssClass).ToString(); var element = html.ShouldHaveHtmlNode("foo_Bar"); var nodes = element.ShouldHaveChildNodesCount(8); foreach (var node in nodes) { node.ShouldHaveAttribute(HtmlAttribute.Class).WithValue(cssClass); } }
public void radio_renders_selected_item_as_checked() { var html = new CheckBoxList("foo.Bar").Options<FakeEnum>() .Selected(new[] { FakeEnum.Zero, FakeEnum.Two }).ToString(); var element = html.ShouldHaveHtmlNode("foo_Bar"); VerifyItem("foo.Bar", (int)FakeEnum.Zero, FakeEnum.Zero.ToString(), element, 0, true); VerifyItem("foo.Bar", (int)FakeEnum.One, FakeEnum.One.ToString(), element, 1, false); VerifyItem("foo.Bar", (int)FakeEnum.Two, FakeEnum.Two.ToString(), element, 2, true); VerifyItem("foo.Bar", (int)FakeEnum.Three, FakeEnum.Three.ToString(), element, 3, false); }
ArrayList GetSelectedItems(CheckBoxList lb) { ArrayList a = new ArrayList(); for (int i = 0; i < lb.Items.Count; i++) { if (lb.Items[i].Selected) a.Add(lb.Items[i].Value); } return a; }
// function to check for checkboxes checked in passed in checkboxlist control public static bool checkBoxListItemChk(CheckBoxList list) { for (int i = 0; i < list.Items.Count; i++) { if (list.Items[i].Selected) { return true; } } return false; }
public void can_generate_checkbox_list_with_formatted_items() { var items = new List<FakeModel> { new FakeModel { Price = 1, Title = "One" }, }; var html = new CheckBoxList("foo.Bar").Options(items, x => x.Price, x => x.Title) .ItemFormat("<div>{0}</div>").ToString(); var element = html.ShouldHaveHtmlNode("foo_Bar"); element.ShouldHaveChildNodesCount(1)[0].ShouldBeNamed(HtmlTag.Div); }
public void Check(CheckBoxList CheckList, string RightValue) { string strRight = Convert.ToString(int.Parse(RightValue), 2); string strOperation; foreach (ListItem item in CheckList.Items) { strOperation = Convert.ToString(int.Parse(Math.Pow(2, double.Parse(item.Value)).ToString()), 2); if ((Convert.ToInt32(strRight, 2) & Convert.ToInt32(strOperation, 2)) != 0) item.Selected = true; else item.Selected = false; } }
public void can_generate_checkbox_list_from_model_choices() { var items = new List<FakeModel> { new FakeModel { Price = 1, Title = "One" }, new FakeModel { Price = 2, Title = "Two" }, }; var html = new CheckBoxList("foo.Bar").Options(items, x => x.Price, x => x.Title).ToString(); var element = html.ShouldHaveHtmlNode("foo_Bar"); VerifyItem("foo.Bar", items[0].Price, items[0].Title, element, 0, false); VerifyItem("foo.Bar", items[1].Price, items[1].Title, element, 1, false); }
public void SetValueCheckBoxList(CheckBoxList cbl, string sValues) { if (!string.IsNullOrEmpty(sValues)) { ArrayList values = StringToArrayList(sValues); foreach (ListItem li in cbl.Items) { if (values.Contains(li.Value)) li.Selected = true; else li.Selected = false; } } }
public string returnSelectedItemsValue(CheckBoxList lsBox) { string seletectedItemsValue = ","; // string.Empty; foreach (ListItem li in lsBox.Items) { if (li.Selected == true) { seletectedItemsValue += li.Value + ","; } } return seletectedItemsValue; }
public override object Deserialize(Cell _data, ConversionContext _context = null) { object data = base.Deserialize(_data); CheckBoxList chkList; if (data == null) { chkList = new CheckBoxList(); } else { chkList = data as CheckBoxList; } if (_context == null || _context.Field == null || _context.Field.Metadata == null) { return chkList; } if (!_context.Field.Metadata.IsLoaded) { _context.Field.Metadata.Load(); } var metadata = _context.Field.Metadata.FirstOrDefault(m => m.Key == ModuleRepository.CheckBoxListMetadataKey); if (metadata != null && !String.IsNullOrWhiteSpace(metadata.Value)) { var json = new JavaScriptSerializer(); var items = json.Deserialize<string[]>(metadata.Value); if (items != null) { foreach (var i in items) { // avoid adding empty entries to the dictionary if (!String.IsNullOrWhiteSpace(i)) { var newItem = new CheckBoxItem { Key = i.EscapeName(), Value = i }; // checked options will already be present in the list if(!chkList.Any(it => it.Value == i)) { chkList.Add(newItem); } } } } } return chkList; }
protected static string GetCheckBoxListValue(CheckBoxList cbList) { StringBuilder buffer = new StringBuilder(); foreach (ListItem item in cbList.Items) { if (item.Selected) { buffer.Append(item.Text + ","); } } if (buffer.Length > 0) buffer.Remove(buffer.Length - 1, 1); return buffer.ToString(); }
public void can_modify_each_checkbox_element_using_the_option_data_item() { var items = new List<FakeModel> { new FakeModel { Price = 1, Title = "One" }, new FakeModel { Price = 2, Title = "Two", Done = true }, }; const string name = "foo"; var html = new CheckBoxList(name).Options(items, x => x.Price, x => x.Title) .EachOption((cb, opt, i) => cb.Disabled(((FakeModel)opt).Done)).ToString(); var element = html.ShouldHaveHtmlNode(name); GetCheckBox(element, name, 0).ShouldNotHaveAttribute("disabled"); GetCheckBox(element, name, 1).ShouldHaveAttribute("disabled"); }
} //Nạp danh sách nhân viên lên Gridview public void NapDSQuyen() { QuyenCollection quyenColl = new QuyenCollection(); quyenColl = quyenBUS.TimDSQuyen(); for (int i = 0; i < 6; i++) { CheckBoxList cblist = new CheckBoxList(); cblist = QuyenTab.Tabs[i].FindControl("CheckBoxList"+(i+1).ToString()) as CheckBoxList; if (quyenColl.Index(i).ChiTietQuyen == null) break; cblist.DataSource = quyenColl.Index(i).ChiTietQuyen; cblist.DataTextField = "TenCTQuyen"; cblist.DataValueField = "MaCTQuyen"; cblist.DataBind(); } }// nạp danh sách quyền cho TabControl
protected void BindPersonInfo(CheckBoxList CBL, DataRow[] dr) { if (dr.Length != 0) { for (int i = 0; i < dr.Length; i++) { string strMCode = dr[i]["MCode"].ToString(); foreach (ListItem LI in CBL.Items) { if (LI.Value == strMCode) { LI.Selected = true; } } } } }
public static void BindModalitiesDDL(string addText, CheckBoxList ddl) { RISDatabaseAccessLayer dataAccess = new RISDatabaseAccessLayer(); SqlConnection connection = (SqlConnection)dataAccess.GetConnection(); connection.Open(); SqlCommand command = new SqlCommand("sp_get_modalities", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@addText", addText); SqlDataReader reader = command.ExecuteReader(); ddl.DataSource = reader; ddl.DataMember = "Name"; ddl.DataTextField = "Name"; ddl.DataValueField = "ModalityId"; ddl.DataBind(); reader.Close(); connection.Close(); }
private void BindData(CheckBoxList list,string temp) { DataTable dt = new DAL.Tables.T_Lotteries().Open("[ID], [Name]", "[ID] in (" + (_Site.UseLotteryList == "" ? "-1" : _Site.UseLotteryList) + ") "+temp, "[Order]"); if (dt == null) { PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", this.GetType().BaseType.FullName); return; } list.Items.Clear(); foreach (DataRow dr in dt.Rows) { list.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString())); } }
private void AddingDynamicCheckBoxList() { Label tblabel = new Label(); tblabel.Text = "Firstname"; tblabel.ID = "lblFrstname"; PlaceHolder1.Controls.Add(tblabel); TextBox tb = new TextBox(); tb.ID = "test"; PlaceHolder1.Controls.Add(tb); CheckBoxList ChkboxList = new CheckBoxList(); ChkboxList.ID = "Chkbox"; //Displaying A,B... in CheckBoxList for (int i = 65; i <= 90; i++) { ChkboxList.Items.Add(new ListItem(Convert.ToChar(i).ToString(), Convert.ToChar(i).ToString())); } PlaceHolder1.Controls.Add(ChkboxList); }
public void LoadCheckBoxList(CheckBoxList checkBoxDisease, string DiseaseCategory) { data = new DataAccess(); data.ConnectToDatabase(); try { SqlCommand cmdTxt = new SqlCommand("Select DiseaseName From Diseases Where DiseaseCategoryName = @DiseaseCategory",data.Connection); cmdTxt.Parameters.Add("@DiseaseCategory", SqlDbType.Char).Value = DiseaseCategory; SqlDataReader dr = cmdTxt.ExecuteReader(); while (dr.Read()) { checkBoxDisease.Items.Add(dr.GetString(0).ToString().Trim()); } dr.Close(); } catch (Exception) { } finally { data.CloseDatabase(); } }
private void ConfigSectionChanged(IConfigSection configSection) { configItemPanel.Children.Clear(); foreach (var configItem in configSection.GetType().GetProperties()) { var displayNameAttribute = (NameAttribute)Attribute.GetCustomAttribute(configItem, typeof(NameAttribute)); if(displayNameAttribute != null) { var b = new Binding(configItem.Name); b.Source = configSection; b.Mode = BindingMode.TwoWay; b.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; var requiredAttribute = (RequiredAttribute)Attribute.GetCustomAttribute(configItem, typeof(RequiredAttribute)); var editorTypeAttribute = (ConfigEditorAttribute)Attribute.GetCustomAttribute(configItem, typeof(ConfigEditorAttribute)); if (ConfigSection.Guid == new Guid("FEACBCE2-8290-4D90-BB05-373B9D7DBBFC") && configItem.Name == "ExcludedIdentifiers") { CreateVisibilityControl(displayNameAttribute); } else if (editorTypeAttribute != null && editorTypeAttribute.Editor == EditorType.CheckBoxList && ConfigSection.Guid == new Guid("FEACBCE2-8290-4D90-BB05-373B9D7DBBFC") && configItem.Name == "ActivatedExporters") { var exporterList = new CheckBoxList(); foreach (var exporter in _allExporters) { exporterList.Add(exporter.ExporterName); } CreateCheckboxListControl(displayNameAttribute, exporterList, b); } else if (editorTypeAttribute != null && editorTypeAttribute.Editor == EditorType.CheckBoxList && editorTypeAttribute.SourceListType != null) { CreateCheckboxListControl(displayNameAttribute, (CheckBoxList)Activator.CreateInstance(editorTypeAttribute.SourceListType) ,b); } else if(editorTypeAttribute != null && editorTypeAttribute.Editor == EditorType.Markdown) { CreateMarkdownControl(displayNameAttribute, requiredAttribute, b); } else if(editorTypeAttribute == null && configItem.PropertyType == typeof(string)) { CreateTextboxControl(displayNameAttribute, requiredAttribute, b); } else if (editorTypeAttribute == null && configItem.PropertyType == typeof(bool)) { CreateCheckboxControl(displayNameAttribute, b); } else if (editorTypeAttribute != null && editorTypeAttribute.Editor == EditorType.ComboBox && editorTypeAttribute.SourceListType != null) { CreateComboboxControl(displayNameAttribute, requiredAttribute, editorTypeAttribute, b); } else if (editorTypeAttribute != null && editorTypeAttribute.Editor == EditorType.Colorpicker) { CreateColorpickerControl(displayNameAttribute, b); } else if (editorTypeAttribute != null && (editorTypeAttribute.Editor == EditorType.Filepicker || editorTypeAttribute.Editor == EditorType.Folderpicker)) { CreateFilesystemControl(displayNameAttribute, requiredAttribute, editorTypeAttribute, b); } } } }
private void generateQuestions(List <Questions> lista) { HtmlGenericControl div = new HtmlGenericControl("div"); div.ID = "section"; div.Attributes.Add("class", "quizz-text"); Panel panel = new Panel(); panel.ID = "panel"; int id = 1; foreach (Questions question in lista) { if (question.Type == "One") { Label title = new Label(); title.Text = "Fråga " + id.ToString() + ": " + question.Title; title.Attributes.Add("class", "title"); Label subject = new Label(); subject.Text = "Ämne: " + question.Subject; subject.Attributes.Add("class", "text"); RadioButtonList radiolist = new RadioButtonList(); radiolist.ID = id.ToString(); radiolist.Attributes.Add("class", "list-style"); foreach (var option in question.Options) { radiolist.Items.Add(option.name); } panel.Controls.Add(title); panel.Controls.Add(subject); if (question.Picture != "") { Image image = new Image(); image.Attributes.Add("class", "picture"); image.ImageUrl = "Pictures/" + question.Picture; panel.Controls.Add(image); } panel.Controls.Add(radiolist); div.Controls.Add(panel); } else { Label title = new Label(); title.Text = "Fråga " + id.ToString() + ": " + question.Title; Label subject = new Label(); subject.Text = "Ämne: " + question.Subject; subject.Attributes.Add("class", "text"); CheckBoxList checkboxlist = new CheckBoxList(); checkboxlist.ID = id.ToString(); checkboxlist.Attributes.Add("class", "list-style"); foreach (var option in question.Options) { checkboxlist.Items.Add(option.name); } panel.Controls.Add(title); panel.Controls.Add(subject); panel.Controls.Add(checkboxlist); div.Controls.Add(panel); } id++; } prov_div.Controls.Add(div); }
public void PintaControles(List <CampoMascara> lstControles, List <HelperMascaraData> datosMascara) { try { if (datosMascara == null) { throw new Exception("Ticket con informacion incorrecta."); } divControles.Controls.Clear(); foreach (CampoMascara campo in lstControles) { HtmlGenericControl hr = new HtmlGenericControl("HR"); HtmlGenericControl createDiv = new HtmlGenericControl("DIV") { ID = "createDiv" + campo.NombreCampo }; createDiv.Attributes["class"] = "form-group col-lg-12 col-md-12 col-sm-12 col-xs-12 tableHeadTicket clearfix"; //createDiv.InnerHtml = campo.Descripcion; Label lbl = new Label { Text = campo.Descripcion + (campo.Requerido ? "<span style='color: red'> *</span>" : string.Empty), CssClass = "col-lg-12 col-md-12 col-sm-12 col-xs-12 proxima12" }; switch (campo.TipoCampoMascara.Id) { case (int)BusinessVariables.EnumeradoresKiiniNet.EnumTiposCampo.Texto: lbl.Attributes["for"] = "txt" + campo.NombreCampo; createDiv.Controls.Add(lbl); TextBox txtAlfanumerico = new TextBox { ID = "txt" + campo.NombreCampo, CssClass = "col-sm-6 form-control", Text = datosMascara.Single(s => s.Campo == campo.NombreCampo).Value, ReadOnly = true }; HtmlGenericControl createDivTexto = new HtmlGenericControl("DIV"); createDivTexto.ID = "createDivTexto" + campo.NombreCampo; createDivTexto.Attributes["class"] = "col-lg-12 col-md-12 col-sm-12 col-xs-12"; createDivTexto.Controls.Add(txtAlfanumerico); createDiv.Controls.Add(createDivTexto); break; case (int)BusinessVariables.EnumeradoresKiiniNet.EnumTiposCampo.TextoMultiLinea: lbl.Attributes["for"] = "txt" + campo.NombreCampo; createDiv.Controls.Add(lbl); TextBox txtMultilinea = new TextBox { ID = "txt" + campo.NombreCampo, CssClass = "form-control", TextMode = TextBoxMode.MultiLine, Text = datosMascara.Single(s => s.Campo == campo.NombreCampo).Value, Rows = 10, ReadOnly = true }; txtMultilinea.Attributes["MaxLength"] = campo.LongitudMaxima.ToString(); txtMultilinea.Attributes["placeholder"] = campo.Descripcion; HtmlGenericControl createDivMultilinea = new HtmlGenericControl("DIV"); createDivMultilinea.ID = "createDivMultilinea" + campo.NombreCampo; createDivMultilinea.Attributes["class"] = "col-lg-12 col-md-12 col-sm-12 col-xs-12"; createDivMultilinea.Controls.Add(txtMultilinea); createDiv.Controls.Add(createDivMultilinea); break; case (int)BusinessVariables.EnumeradoresKiiniNet.EnumTiposCampo.RadioBoton: lbl.Attributes["for"] = "lstRadio" + campo.NombreCampo; createDiv.Attributes.Add("class", "tableHeadMascara"); createDiv.Controls.Add(lbl); RadioButtonList lstRadio = new RadioButtonList { ID = "lstRadio" + campo.NombreCampo, Text = campo.Descripcion, RepeatColumns = 5, RepeatDirection = RepeatDirection.Horizontal, Enabled = false }; if (campo.EsArchivo) { foreach (DataRow row in _servicioCatalogos.ObtenerRegistrosArchivosCatalogo(int.Parse(campo.IdCatalogo.ToString())).Rows) { lstRadio.Items.Add(new ListItem(row[1].ToString(), row[0].ToString())); } } else { if (campo.IdCatalogo != null) { foreach (CatalogoGenerico cat in _servicioMascaras.ObtenerCatalogoCampoMascara((int)campo.IdCatalogo, false, false)) { lstRadio.Items.Add(new ListItem(cat.Descripcion, cat.Id.ToString())); } } } lstRadio.SelectedValue = datosMascara.Single(s => s.Campo == campo.NombreCampo).Value; HtmlGenericControl createDivRadio = new HtmlGenericControl("DIV"); createDivRadio.ID = "createDivRadio" + campo.NombreCampo; createDivRadio.Attributes["class"] = "col-lg-12 col-md-12 col-sm-12 col-xs-12"; createDivRadio.Controls.Add(lstRadio); createDiv.Controls.Add(createDivRadio); break; case (int)BusinessVariables.EnumeradoresKiiniNet.EnumTiposCampo.ListaDespledable: lbl.Attributes["for"] = "ddl" + campo.NombreCampo; createDiv.Controls.Add(lbl); DropDownList ddlCatalogo = new DropDownList { SelectedValue = "0", ID = "ddl" + campo.NombreCampo, Text = campo.Descripcion, CssClass = "col-sm-10 form-control", Enabled = false }; if (campo.EsArchivo) { foreach (DataRow row in _servicioCatalogos.ObtenerRegistrosArchivosCatalogo(int.Parse(campo.IdCatalogo.ToString())).Rows) { ddlCatalogo.Items.Add(new ListItem(row[1].ToString(), row[0].ToString())); } } else { if (campo.IdCatalogo != null) { foreach (CatalogoGenerico cat in _servicioMascaras.ObtenerCatalogoCampoMascara((int)campo.IdCatalogo, true, false)) { ddlCatalogo.Items.Add(new ListItem(cat.Descripcion, cat.Id.ToString())); } } } ddlCatalogo.SelectedValue = datosMascara.Single(s => s.Campo == campo.NombreCampo).Value; HtmlGenericControl createDivDdl = new HtmlGenericControl("DIV"); createDivDdl.ID = "createDivDdl" + campo.NombreCampo; createDivDdl.Attributes["class"] = "col-lg-12 col-md-12 col-sm-12"; createDivDdl.Controls.Add(ddlCatalogo); createDiv.Controls.Add(createDivDdl); break; case (int)BusinessVariables.EnumeradoresKiiniNet.EnumTiposCampo.CasillaDeVerificación: lbl.Attributes["for"] = "chklist" + campo.NombreCampo; createDiv.Attributes.Add("class", "tableHeadMascara"); createDiv.Controls.Add(lbl); CheckBoxList chklist = new CheckBoxList { SelectedValue = "0", ID = "chklist" + campo.NombreCampo, Text = campo.Descripcion, RepeatColumns = 5, RepeatDirection = RepeatDirection.Horizontal, Enabled = false, }; if (campo.EsArchivo) { foreach (DataRow row in _servicioCatalogos.ObtenerRegistrosArchivosCatalogo(int.Parse(campo.IdCatalogo.ToString())).Rows) { chklist.Items.Add(new ListItem(row[1].ToString(), row[0].ToString())); } } else { if (campo.IdCatalogo != null) { foreach (CatalogoGenerico cat in _servicioMascaras.ObtenerCatalogoCampoMascara((int)campo.IdCatalogo, false, false)) { chklist.Items.Add(new ListItem(cat.Descripcion, cat.Id.ToString())); } } } List <int> values = _servicioTicket.CapturaCasillaTicket(IdTicket, campo.NombreCampo); foreach (ListItem item in chklist.Items) { foreach (int value in values) { if (item.Value == value.ToString()) { item.Selected = true; break; } } } HtmlGenericControl createDivchk = new HtmlGenericControl("DIV"); createDivchk.ID = "createDivchk" + campo.NombreCampo; createDivchk.Attributes["class"] = "col-lg-12 col-md-12 col-sm-12"; createDivchk.Controls.Add(chklist); createDiv.Controls.Add(createDivchk); break; case (int)BusinessVariables.EnumeradoresKiiniNet.EnumTiposCampo.NúmeroDecimal: lbl.Attributes["for"] = "txt" + campo.NombreCampo; createDiv.Controls.Add(lbl); TextBox txtDecimal = new TextBox { ID = "txt" + campo.NombreCampo, Text = datosMascara.Single(s => s.Campo == campo.NombreCampo).Value, CssClass = "form-control", ReadOnly = true }; txtDecimal.Attributes["placeholder"] = campo.Descripcion; txtDecimal.Attributes["max"] = campo.ValorMaximo.ToString(); txtDecimal.Attributes["type"] = "number"; txtDecimal.Attributes["step"] = "0.01"; txtDecimal.Attributes["for"] = "DECIMAL"; createDiv.Controls.Add(txtDecimal); break; case (int)BusinessVariables.EnumeradoresKiiniNet.EnumTiposCampo.NúmeroEntero: lbl.Attributes["for"] = "txt" + campo.NombreCampo; createDiv.Controls.Add(lbl); TextBox txtEntero = new TextBox { ID = "txt" + campo.NombreCampo, Text = datosMascara.Single(s => s.Campo == campo.NombreCampo).Value, CssClass = "form-control", ReadOnly = true }; txtEntero.Attributes["placeholder"] = campo.NombreCampo; txtEntero.Attributes["type"] = "number"; txtEntero.Attributes["step"] = "1"; txtEntero.Attributes["min"] = "1"; txtEntero.Attributes["max"] = campo.ValorMaximo.ToString(); HtmlGenericControl createDivEntero = new HtmlGenericControl("DIV"); createDivEntero.ID = "createDivEntero" + campo.NombreCampo; createDivEntero.Attributes["class"] = "col-lg-12 col-md-12 col-sm-12"; createDivEntero.Controls.Add(txtEntero); createDiv.Controls.Add(createDivEntero); break; case (int)BusinessVariables.EnumeradoresKiiniNet.EnumTiposCampo.Fecha: lbl.Attributes["for"] = "FECHA"; createDiv.Controls.Add(lbl); TextBox txtFecha = new TextBox { ID = "txt" + campo.NombreCampo, CssClass = "form-control", Text = DateTime.Parse(datosMascara.Single(s => s.Campo == campo.NombreCampo).Value).ToString("yyyy-MM-dd"), ReadOnly = true }; txtFecha.Attributes["placeholder"] = campo.Descripcion; txtFecha.Attributes["for"] = "FECHA"; txtFecha.Attributes["type"] = "date"; txtFecha.Attributes["step"] = "1"; HtmlGenericControl createDivFecha = new HtmlGenericControl("DIV"); createDivFecha.ID = "createDivEntero" + campo.NombreCampo; createDivFecha.Attributes["class"] = "col-lg-12 col-md-12 col-sm-12"; createDivFecha.Controls.Add(txtFecha); createDiv.Controls.Add(createDivFecha); break; case (int)BusinessVariables.EnumeradoresKiiniNet.EnumTiposCampo.FechaRango: lbl.Attributes["for"] = "FECHAINICIO"; createDiv.Controls.Add(lbl); HtmlGenericControl createDivGrupoFechas = new HtmlGenericControl("DIV"); createDivGrupoFechas.ID = "createDivGrupoFechas" + campo.NombreCampo; createDivGrupoFechas.Attributes["class"] = "form-group"; Label lblDe = new Label { Text = "De:", CssClass = "" }; lblDe.Attributes["for"] = "FECHAINICIO"; createDivGrupoFechas.Controls.Add(lblDe); string nombreCampo = campo.NombreCampo + BusinessVariables.ParametrosMascaraCaptura.PrefijoFechaInicio; TextBox txtFechaInicio = new TextBox { ID = "txt" + campo.NombreCampo + BusinessVariables.ParametrosMascaraCaptura.PrefijoFechaInicio, Text = DateTime.Parse(datosMascara.Single(s => s.Campo == nombreCampo).Value).ToString("yyyy-MM-dd"), CssClass = "form-control", ReadOnly = true }; txtFechaInicio.Attributes["placeholder"] = campo.Descripcion; txtFechaInicio.Attributes["for"] = "FECHAINICIO"; txtFechaInicio.Attributes["type"] = "date"; txtFechaInicio.Attributes["step"] = "1"; createDivGrupoFechas.Controls.Add(txtFechaInicio); Label lblHasta = new Label { Text = "De:", CssClass = "" }; lblHasta.Attributes["for"] = "FECHAFIN"; createDivGrupoFechas.Controls.Add(lblHasta); nombreCampo = campo.NombreCampo + BusinessVariables.ParametrosMascaraCaptura.PrefijoFechaFin; TextBox txtFechaFin = new TextBox { ID = "txt" + campo.NombreCampo + BusinessVariables.ParametrosMascaraCaptura.PrefijoFechaFin, Text = DateTime.Parse(datosMascara.Single(s => s.Campo == nombreCampo).Value).ToString("yyyy-MM-dd"), CssClass = "form-control", ReadOnly = true }; txtFechaFin.Attributes["placeholder"] = campo.Descripcion; txtFechaFin.Attributes["for"] = "FECHAFIN"; txtFechaFin.Attributes["type"] = "date"; txtFechaFin.Attributes["step"] = "1"; createDivGrupoFechas.Controls.Add(txtFechaFin); HtmlGenericControl createDivFormFechas = new HtmlGenericControl("DIV"); createDivFormFechas.Attributes["class"] = "form-inline"; createDivFormFechas.Controls.Add(createDivGrupoFechas); createDiv.Controls.Add(createDivFormFechas); break; case (int)BusinessVariables.EnumeradoresKiiniNet.EnumTiposCampo.Logico: CheckBox chk = new CheckBox { ID = "chk" + campo.NombreCampo, Text = campo.Descripcion, ViewStateMode = ViewStateMode.Inherit, Enabled = false }; HtmlGenericControl createDivCheck = new HtmlGenericControl("DIV"); createDivCheck.ID = "createDivCheck" + campo.NombreCampo; createDivCheck.Attributes["class"] = "col-lg-12 col-md-12 col-sm-12"; createDivCheck.Controls.Add(chk); createDiv.Controls.Add(createDivCheck); break; case (int)BusinessVariables.EnumeradoresKiiniNet.EnumTiposCampo.ExpresiónRegular: lbl.Attributes["for"] = "txt" + campo.NombreCampo; createDiv.Controls.Add(lbl); TextBox txtMascara = new TextBox { ID = "txt" + campo.NombreCampo, Text = campo.Descripcion, CssClass = "form-control", ReadOnly = true }; //txtMascara.Attributes["placeholder"] = campo.Descripcion; txtMascara.Attributes["max"] = campo.ValorMaximo.ToString(); txtMascara.Attributes["for"] = "txt" + campo.Descripcion.Replace(" ", string.Empty); MaskedEditExtender meeMascara = new MaskedEditExtender { ID = "mee" + campo.NombreCampo, TargetControlID = txtMascara.ID, InputDirection = MaskedEditInputDirection.LeftToRight, Mask = campo.MascaraDetalle, MaskType = MaskedEditType.Date, AcceptAMPM = false, AcceptNegative = MaskedEditShowSymbol.None, }; HtmlGenericControl createDivMask = new HtmlGenericControl("DIV"); createDivMask.ID = "createDivMask" + campo.NombreCampo; createDivMask.Attributes["class"] = "col-lg-12 col-md-12 col-sm-12"; createDivMask.Controls.Add(meeMascara); createDivMask.Controls.Add(txtMascara); createDiv.Controls.Add(createDivMask); break; case (int)BusinessVariables.EnumeradoresKiiniNet.EnumTiposCampo.AdjuntarArchivo: lbl.Attributes["for"] = "txt" + campo.NombreCampo; createDiv.Controls.Add(lbl); string archivo = datosMascara.Single(s => s.Campo == campo.NombreCampo).Value; HyperLink lk = new HyperLink(); if (archivo != string.Empty) { lk.Text = archivo; lk.NavigateUrl = ResolveUrl(string.Format("~/Downloads/FrmDownloads.aspx?file={0}", BusinessVariables.Directorios.RepositorioMascara + "~" + archivo)); lk.Style.Add("margin-auto", "10px"); HtmlGenericControl createDivFile = new HtmlGenericControl("DIV"); createDivFile.ID = "createDivFile" + campo.NombreCampo; createDivFile.Attributes["class"] = "col-lg-12 col-md-12 col-sm-12"; createDivFile.Controls.Add(lk); createDiv.Controls.Add(createDivFile); } break; } divControles.Controls.Add(createDiv); } upMascara.Update(); } catch (Exception ex) { throw new Exception(ex.Message); } }
public static void MappingControlShow(object obj, HtmlForm form, ContentPlaceHolder cph) { try { if (obj == null) { return; } List <PropertyInfo> pilist = obj.GetType().GetProperties().ToList(); Control baseControl = cph == null ? (Control)form : (Control)cph; foreach (PropertyInfo pi in pilist) { Control ctrl = baseControl.FindControl("txt" + pi.Name); ctrl = ctrl == null?baseControl.FindControl("lbl" + pi.Name) : ctrl; ctrl = ctrl == null?baseControl.FindControl("lit" + pi.Name) : ctrl; ctrl = ctrl == null?baseControl.FindControl("hid" + pi.Name) : ctrl; ctrl = ctrl == null?baseControl.FindControl("ddl" + pi.Name) : ctrl; ctrl = ctrl == null?baseControl.FindControl("rdo" + pi.Name) : ctrl; ctrl = ctrl == null?baseControl.FindControl("chk" + pi.Name) : ctrl; if (ctrl == null) { continue; } else if (ctrl is TextBox) { TextBox txt = ctrl as TextBox; txt.Text = Wf_ConvertHelper.ToString(pi.GetValue(obj, null)); } else if (ctrl is Label) { Label lbl = ctrl as Label; lbl.Text = Wf_ConvertHelper.ToString(pi.GetValue(obj, null)); } else if (ctrl is Literal) { Literal lit = ctrl as Literal; lit.Text = Wf_ConvertHelper.ToString(pi.GetValue(obj, null)); } else if (ctrl is HiddenField) { HiddenField hid = ctrl as HiddenField; hid.Value = Wf_ConvertHelper.ToString(pi.GetValue(obj, null)); } else if (ctrl is DropDownList) { DropDownList ddl = ctrl as DropDownList; foreach (ListItem item in ddl.Items) { object value = pi.GetValue(obj, null); if (item.Value == Wf_ConvertHelper.ToString(value)) { ddl.SelectedValue = item.Value; } } } else if (ctrl is RadioButtonList) { RadioButtonList rdo = ctrl as RadioButtonList; object value = pi.GetValue(obj, null); string[] arr = Wf_ConvertHelper.ToString(value, "").Split(','); foreach (ListItem item in rdo.Items) { if (arr.Contains(item.Value)) { item.Selected = true; } } } else if (ctrl is CheckBoxList) { CheckBoxList chk = ctrl as CheckBoxList; object value = pi.GetValue(obj, null); string[] arr = Wf_ConvertHelper.ToString(value, "").Split(','); foreach (ListItem item in chk.Items) { if (arr.Contains(item.Value)) { item.Selected = true; } } } continue; } } catch { } }
/// <summary> /// Used when binding the lists to the MailChimp actual subscribers. It will use the /// API to dynamically query each potential subscriber against each configured list. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void dlLists_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { MailChimpLookup item = new MailChimpLookup(e.Item.DataItem as Lookup); if (item.ImageUrl != string.Empty) { Image image = e.Item.FindControl("imgBG") as Image; image.ImageUrl = item.ImageUrl; } else { Literal itemName = e.Item.FindControl("liListName") as Literal; itemName.Text = item.Name; } ImageButton btnSubscribe = e.Item.FindControl("btnSubscribe") as ImageButton; btnSubscribe.CommandName = "Subscribe"; btnSubscribe.CommandArgument = item.ListID; ImageButton btnUnsubscribe = e.Item.FindControl("btnUnsubscribe") as ImageButton; btnUnsubscribe.CommandName = "Unsubscribe"; btnUnsubscribe.CommandArgument = item.ListID; LinkButton lbSaveGroups = e.Item.FindControl("lbSaveGroups") as LinkButton; lbSaveGroups.CommandName = "SaveGroups"; lbSaveGroups.CommandArgument = item.ListID; CheckBoxList cblGroups = e.Item.FindControl("cblGroups") as CheckBoxList; try { // Create a checkbox for each Interest group if MC Groups is enabled. if (EnableMCGroupsSetting) { lbSaveGroups.Visible = false; try { MCInterestGroups mcGroups = api.listInterestGroups(item.ListID); cblGroups.Visible = true; cblGroups.RepeatColumns = (MaxColumnsSetting) ? NumRowsColsSetting : (mcGroups.groups.Count() + NumRowsColsSetting - 1) / NumRowsColsSetting; cblGroups.DataSource = mcGroups.groups; cblGroups.DataBind(); } catch (XmlRpcFaultException ex) { if (ex.FaultCode != MailChimpErrorCodes.List_InterestGroups_NotEnabled) { AddMsg(string.Format(" {0}: {1} (err:{2})", item.Name, ex.FaultString, ex.FaultCode)); } } } // Try to determine if the email address is subscribed/unsubscribed from the MailChimp list MCMemberInfo info = api.listMemberInfo(item.ListID, GetPerson().Emails.FirstActive); // Set the user's groups if "MailChimp groups" is enabled. if (EnableMCGroupsSetting) { lbSaveGroups.Visible = true; // now check the interests that are selected for this user string interests = (from m in info.merges where m.tag == "INTERESTS" select m).FirstOrDefault().val; if (!string.IsNullOrEmpty(interests)) { foreach (ListItem interestCheckbox in cblGroups.Items) { if (interests.Contains(interestCheckbox.Value)) { interestCheckbox.Selected = true; } } } } string hoverInfo = string.Format(" {0}: {1} on {2} EST/EDT", item.Name, info.status, info.timestamp); if ("subscribed".Equals(info.status)) { btnUnsubscribe.ToolTip = hoverInfo; btnUnsubscribe.Visible = true; } else { btnSubscribe.ToolTip = hoverInfo; btnSubscribe.Visible = true; } } catch (XmlRpcFaultException ex) { if (ex.FaultCode == MailChimpErrorCodes.Email_NotExists) { btnSubscribe.Visible = true; } else if (ex.FaultCode == MailChimpErrorCodes.List_NotSubscribed) { btnSubscribe.ToolTip = "Person no longer subscribed."; btnSubscribe.Visible = true; } else { AddMsg(string.Format(" {0}: {1} (err:{2})", item.Name, ex.FaultString, ex.FaultCode)); } } } }
protected void dgAulas_ItemDataBound(object sender, DataGridItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { DropDownList ddlAtividade = (DropDownList)e.Item.FindControl("ddlAtividade"); Label lblData = (Label)e.Item.FindControl("lblData"); TextBox txtDescricao = (TextBox)e.Item.FindControl("txtDescricao"); Label lblDescData = (Label)e.Item.FindControl("lblDescData"); Label lblCorDaData = (Label)e.Item.FindControl("lblCorDaData"); Label lblRecursosAlocados = (Label)e.Item.FindControl("lblRecursosAlocados"); //lblRecursosAlocados.ReadOnly = true; Label lblRecursosAlocadosId = (Label)e.Item.FindControl("lblRecursosAlocadosId"); Label lblAulaId = (Label)e.Item.FindControl("lblAulaId"); Label lblAula = (Label)e.Item.FindControl("lblAula"); Label lblHora = (Label)e.Item.FindControl("lblHora"); Panel pnRecursos = (Panel)e.Item.FindControl("pnRecursos"); HtmlTable tabRecursos = (HtmlTable)e.Item.FindControl("tabRecursos"); int i = tabRecursos.Rows[0].Cells[0].Controls.Count; CheckBoxList cbRecursos = (CheckBoxList)tabRecursos.Rows[0].Cells[0].Controls[1]; ImageButton butDel = (ImageButton)e.Item.FindControl("butDeletar"); ImageButton butTransf = (ImageButton)e.Item.FindControl("butTransferir"); ImageButton butTrocar = (ImageButton)e.Item.FindControl("butTrocar"); //CheckBoxList cbRecursos = (CheckBoxList) tabRecursos.FindControl("cbRecursos"); //Label tmp2 = new Label(); //tmp2.Text = "boo"; //pnRecursos.Controls.Add(tmp2); //Label tmp3 = new Label(); //tmp3.Text = "boo2"; //pnRecursos.Controls.Add(tmp3); //pnRecursos.BackColor = Color.Red; Color cor = argb[0]; //txtDescricao.Attributes.Add("onkeyup", "setDirtyFlag()"); //string call = "testAlert(this," + lblAula.Text + ")"; //txtDescricao.Attributes.Add("onkeyup", call); //txtDescricao.Attributes.Add("onkeyup", "this.className='changed'"); Label lbl = (Label)e.Item.FindControl("lblAula"); lbl.Text = ""; listCData = cdataBo.GetCategoriaDatas(); DateTime dataAtual = Convert.ToDateTime(lblData.Text); List <Recurso> livres = recursosBO.GetRecursosDisponiveis(dataAtual, lblHora.Text); livres.Sort(); Recurso dummy = new Recurso(); dummy.Descricao = "Selecionar..."; dummy.Id = dummyGuid; livres.Insert(0, dummy); DropDownList ddlDisponiveis = (DropDownList)e.Item.FindControl("ddlDisponiveis"); ddlDisponiveis.DataValueField = "Id"; ddlDisponiveis.DataTextField = "Descricao"; ddlDisponiveis.DataSource = livres; ddlDisponiveis.DataBind(); ddlAtividade.DataValueField = "Id"; ddlAtividade.DataTextField = "Descricao"; ddlAtividade.DataSource = listaAtividades; ddlAtividade.DataBind(); ddlAtividade.SelectedValue = categorias[0].ToString(); //Data data = null; //verifica as datas para pintar as linhas // Associa a chamada da funçao Javascript para setar a dirty flag + trocar cor string num = cont2.ToString(); if (cont2++ < 10) { num = "0" + num; } string call = "testAlert(this,'" + num + "')"; txtDescricao.Attributes.Add("onkeyup", call); if ((dataAtual >= cal.InicioG2)) { e.Item.BackColor = Color.LightGray; } else { Data data = VerificaData(dataAtual); if (data != null) { foreach (CategoriaData c in listCData) { if (c.Id == data.Categoria.Id) { if (!c.DiaLetivo) { e.Item.BackColor = c.Cor; e.Item.Enabled = false; lblCorDaData.Text = "True"; txtDescricao.Text = c.Descricao + (txtDescricao.Text != "Feriado" ? " (era " + txtDescricao.Text + ")" : ""); } else { facin = (bool)Session["facin"]; if (facin) { lblDescData.Text = c.Descricao; txtDescricao.Text = c.Descricao; // + " "+facin; // + " - " + txtDescricao.Text; //txtDescricao.Text = txtDescricao.Text; e.Item.BackColor = c.Cor; lblCorDaData.Text = "True"; } else { e.Item.BackColor = cor; lblCorDaData.Text = "False"; } lbl.Text = (cont++).ToString(); break; } /*else * { * lblDescData.Text = c.Descricao; * txtDescricao.Text = c.Descricao + "\n" + txtDescricao.Text; * }*/ } } } else { e.Item.BackColor = cor; lblCorDaData.Text = "False"; lbl.Text = (cont++).ToString(); // Associa a chamada da funçao Javascript para setar a dirty flag + trocar cor /*string num = cont.ToString(); * if (cont < 10) * num = "0" + num; * string call = "testAlert(this,'" + num + "')"; * txtDescricao.Attributes.Add("onkeyup", call); */ } } AtualizaComponentes(e.Item, lblData.Text, lblHora.Text, lblAulaId.Text); /* */ categorias.RemoveAt(0); argb.RemoveAt(0); } }
//输出一个字段 //li_tdnums_onerow:当前行已输出了几列 //li_colnums_show:每行显示几列(标准情况下) //pi_isnewdoc 0:新文档 1:旧文档 //ifhavarole:表单上是否有权限 0:lable输出 1:input输出 //ifflowdoc:是否流程表单 0:非流程 1:流程 //curtacheid:当前环节ID,用于判断字段是否在当前环节有权限 public int GetFieldHtml(TableRow tRow, int li_tdnums_onerow, int li_colnums_show, string hy_fieldid, string pi_isnewdoc, string ifhavarole, string ifflowdoc, string curtacheid) { int li_return = li_tdnums_onerow; string ls_laborinput = "0"; //输出LABLE还是INPUT 0:LABLE 1:INPUT HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global(); HyoaClass.Hyoa_flowfield Hyoa_flowfield = new HyoaClass.Hyoa_flowfield(); DataTable dtfield = Hyoa_flowfield.GetSQLfieldBymudelidAndFieldidAndTableid(this.hy_mudelid.Text, hy_fieldid, this.hy_tableid.Text); int li_left = 30; int li_right = 70; if (dtfield.Rows.Count > 0) { string field_type = dtfield.Rows[0]["hy_fieldtype"].ToString(); //字段类型 if (dtfield.Rows[0]["hy_defaultvaluetype"].ToString() != "5") //如果设置了不显示左侧说明文字,则不加载左侧列 { li_return += 1; //插入单元格(左侧) TableCell tCell = new TableCell(); tRow.Cells.Add(tCell); tCell.Width = Unit.Percentage((li_left / li_colnums_show)); tCell.Height = Unit.Pixel(30); tCell.CssClass = "Tdcellleft"; tCell.HorizontalAlign = HorizontalAlign.Center; tCell.Controls.Add(new LiteralControl(dtfield.Rows[0]["hy_fieldname"].ToString())); } else { li_left = 50; li_right = 50; } //插入单元格(右侧) TableCell tCell2 = new TableCell(); tRow.Cells.Add(tCell2); tCell2.Width = Unit.Percentage((li_right / li_colnums_show)); tCell2.Height = Unit.Pixel(30); tCell2.CssClass = "Tdcellright"; if (dtfield.Rows[0]["hy_align"].ToString() == "left") { tCell2.HorizontalAlign = HorizontalAlign.Left; } if (dtfield.Rows[0]["hy_align"].ToString() == "center") { tCell2.HorizontalAlign = HorizontalAlign.Center; } if (dtfield.Rows[0]["hy_align"].ToString() == "right") { tCell2.HorizontalAlign = HorizontalAlign.Right; } tCell2.ColumnSpan = int.Parse(dtfield.Rows[0]["hy_tdnums"].ToString()); li_return += int.Parse(dtfield.Rows[0]["hy_tdnums"].ToString()); //赋值(新文档取配置的默认值,旧文档取数据库表中的值) string field_docvalue = ""; if (pi_isnewdoc == "0") //新文档 { if (dtfield.Rows[0]["hy_defaultvaluetype"].ToString() != "-1") { if (dtfield.Rows[0]["hy_defaultvaluetype"].ToString() == "0") { field_docvalue = dtfield.Rows[0]["hy_defaultvalue"].ToString(); //手工配置 } if (dtfield.Rows[0]["hy_defaultvaluetype"].ToString() == "1") { DataTable dt_getfieldvalue = Hyoa_global.GetDataTable(dtfield.Rows[0]["hy_defaultvalue"].ToString()); field_docvalue = dt_getfieldvalue.Rows[0][0].ToString(); //SQL语句 } if (dtfield.Rows[0]["hy_defaultvaluetype"].ToString() == "2") { field_docvalue = Session[dtfield.Rows[0]["hy_defaultvalue"].ToString()].ToString(); //SESSION } if (dtfield.Rows[0]["hy_defaultvaluetype"].ToString() == "3") { if (dtfield.Rows[0]["hy_defaultvalue"].ToString() == "yyyy-mm-dd") field_docvalue = System.DateTime.Now.ToString("yyyy-MM-dd"); //当前时间 else field_docvalue = System.DateTime.Now.ToString("yyyy-MM-dd HH:MM:ss"); //当前时间 } if (dtfield.Rows[0]["hy_defaultvaluetype"].ToString() == "4") { //自动生成 if (dtfield.Rows[0]["hy_fieldtype"].ToString() == "数值") { //得到目前最大的数值,然后+1,未找到则赋值为1 DataTable dt_autovalue = Hyoa_global.GetDataTable("select max(hyc_" + hy_fieldid + ") maxint from hyc_" + this.hy_tableid.Text); if (dt_autovalue.Rows[0]["maxint"].ToString() == null || dt_autovalue.Rows[0]["maxint"].ToString() == "") field_docvalue += "1"; else field_docvalue += (System.Int32.Parse(dt_autovalue.Rows[0]["maxint"].ToString()) + 1).ToString(); } else { field_docvalue += System.Guid.NewGuid().ToString(); } } if (dtfield.Rows[0]["hy_defaultvaluetype"].ToString() == "5") { field_docvalue += dtfield.Rows[0]["hy_defaultvalue"].ToString(); } } } else { if (field_type == "文本" || field_type == "多行文本" || field_type == "多行文本_TEXT" || field_type == "文本加按钮" || field_type == "多行文本加按钮" || field_type == "日期" || field_type == "数值" || field_type == "对话框列表" || field_type == "复选框" || field_type == "单选框" || field_type == "口令" || field_type == "编辑器") { string ls_sql = "select hyc_" + hy_fieldid + " from hyc_" + this.hy_tableid.Text + " where DOCID='" + this.txtdocid.Value + "'"; DataTable dt_getdocvalue = Hyoa_global.GetDataTable(ls_sql); if (dt_getdocvalue.Rows.Count > 0) { field_docvalue = dt_getdocvalue.Rows[0][0].ToString(); if (field_type == "日期") { if (field_docvalue.Length > 8) { if (field_docvalue.Substring(0, 8) == "1900-1-1") { field_docvalue = " "; } else { if (dtfield.Rows[0]["hy_defaultvalue"].ToString() == "yyyy-mm-dd") { field_docvalue = System.DateTime.Parse(field_docvalue).ToString("yyyy-MM-dd"); } } } } } } if (field_type == "说明文字") { field_docvalue += dtfield.Rows[0]["hy_defaultvalue"].ToString(); } } //判断是输出LABL还是INPUT if (pi_isnewdoc == "0") //新文档 { if (ifflowdoc == "0") //非流程 { if (ifhavarole == "1") //有权限 { ls_laborinput = "1"; } } else { if (ifhavarole == "1") //有权限 { //有流程(判断当前环节这个字段是否有权限) HyoaClass.Hyoa_flowtachefield Hyoa_flowtachefield = new HyoaClass.Hyoa_flowtachefield(); ls_laborinput = Hyoa_flowtachefield.IfHaveRolebyflowidandtacheidandfieldid(hy_flowid.Text, curtacheid, hy_fieldid); if (ls_laborinput == "0") { field_docvalue = ""; } } else { field_docvalue = ""; } } } else //旧文档 { if (ifflowdoc == "0") //非流程 { if (ifhavarole == "1") //有权限 { ls_laborinput = "1"; //如果文档已经确认,则输出lable string ls_sql = "select hy_ifconfirm from hyc_" + this.hy_tableid.Text + " where DOCID='" + this.txtdocid.Value + "'"; DataTable dt_getifconfirm = Hyoa_global.GetDataTable(ls_sql); if (dt_getifconfirm.Rows.Count > 0) { if (dt_getifconfirm.Rows[0]["hy_ifconfirm"].ToString() == "1") ls_laborinput = "0"; } } } else { if (ifhavarole == "1") //有权限 { //有流程(判断当前环节这个字段是否有权限) HyoaClass.Hyoa_flowtachefield Hyoa_flowtachefield = new HyoaClass.Hyoa_flowtachefield(); ls_laborinput = Hyoa_flowtachefield.IfHaveRolebyflowidandtacheidandfieldid(hy_flowid.Text, curtacheid, hy_fieldid); //如果流程结束了,则输出lable if (hy_curtacheid.Text == "**") { ls_laborinput = "0"; } } } } //如果是输出LABLE,值为空则赋为 不为空时需要转换回车和空格 if (ls_laborinput == "0") { if (field_docvalue == "") { field_docvalue = " "; } else { if (field_type != "编辑器") { field_docvalue = RtfToText(field_docvalue); } } } //单行文本 if (field_type == "文本") { //-----开始输出字段------ if (ls_laborinput == "0") //输出LABLE { Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } else { TextBox txtTextBox = new TextBox(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); if (dtfield.Rows[0]["hy_ifreadonly"].ToString() == "是") { txtTextBox.ReadOnly = true; } if (dtfield.Rows[0]["hy_class"].ToString() != "") { txtTextBox.CssClass = dtfield.Rows[0]["hy_class"].ToString(); } if (dtfield.Rows[0]["hy_width"].ToString() != "") { txtTextBox.Width = Unit.Parse(dtfield.Rows[0]["hy_width"].ToString()); } if (dtfield.Rows[0]["hy_height"].ToString() != "") { txtTextBox.Height = Unit.Parse(dtfield.Rows[0]["hy_height"].ToString()); } if (dtfield.Rows[0]["hy_onclick"].ToString() != "") { txtTextBox.Attributes.Add("onclick", dtfield.Rows[0]["hy_onclick"].ToString()); } if (dtfield.Rows[0]["hy_ondblclick"].ToString() != "") { txtTextBox.Attributes.Add("ondblclick", dtfield.Rows[0]["hy_ondblclick"].ToString()); } if (dtfield.Rows[0]["hy_onchange"].ToString() != "") { txtTextBox.Attributes.Add("onchange", dtfield.Rows[0]["hy_onchange"].ToString()); } if (dtfield.Rows[0]["hy_onkeydown"].ToString() != "") { txtTextBox.Attributes.Add("onkeydown", dtfield.Rows[0]["hy_onkeydown"].ToString()); } if (dtfield.Rows[0]["hy_onkeyup"].ToString() != "") { txtTextBox.Attributes.Add("onkeyup", dtfield.Rows[0]["hy_onkeyup"].ToString()); } txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } } //多行文本 if (field_type == "多行文本") { //-----开始输出字段------ if (ls_laborinput == "0") //输出LABLE { Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } else { TextBox txtTextBox = new TextBox(); txtTextBox.TextMode = TextBoxMode.MultiLine; txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); if (dtfield.Rows[0]["hy_ifreadonly"].ToString() == "是") { txtTextBox.ReadOnly = true; } if (dtfield.Rows[0]["hy_class"].ToString() != "") { txtTextBox.CssClass = dtfield.Rows[0]["hy_class"].ToString(); } if (dtfield.Rows[0]["hy_width"].ToString() != "") { txtTextBox.Width = Unit.Parse(dtfield.Rows[0]["hy_width"].ToString()); } if (dtfield.Rows[0]["hy_height"].ToString() != "") { txtTextBox.Height = Unit.Parse(dtfield.Rows[0]["hy_height"].ToString()); } if (dtfield.Rows[0]["hy_onclick"].ToString() != "") { txtTextBox.Attributes.Add("onclick", dtfield.Rows[0]["hy_onclick"].ToString()); } if (dtfield.Rows[0]["hy_ondblclick"].ToString() != "") { txtTextBox.Attributes.Add("ondblclick", dtfield.Rows[0]["hy_ondblclick"].ToString()); } if (dtfield.Rows[0]["hy_onchange"].ToString() != "") { txtTextBox.Attributes.Add("onchange", dtfield.Rows[0]["hy_onchange"].ToString()); } if (dtfield.Rows[0]["hy_onkeydown"].ToString() != "") { txtTextBox.Attributes.Add("onkeydown", dtfield.Rows[0]["hy_onkeydown"].ToString()); } if (dtfield.Rows[0]["hy_onkeyup"].ToString() != "") { txtTextBox.Attributes.Add("onkeyup", dtfield.Rows[0]["hy_onkeyup"].ToString()); } txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } } //多行文本_TEXT if (field_type == "多行文本_TEXT") { //-----开始输出字段------ if (ls_laborinput == "0") //输出LABLE { Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } else { TextBox txtTextBox = new TextBox(); txtTextBox.TextMode = TextBoxMode.MultiLine; txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); if (dtfield.Rows[0]["hy_ifreadonly"].ToString() == "是") { txtTextBox.ReadOnly = true; } if (dtfield.Rows[0]["hy_class"].ToString() != "") { txtTextBox.CssClass = dtfield.Rows[0]["hy_class"].ToString(); } if (dtfield.Rows[0]["hy_width"].ToString() != "") { txtTextBox.Width = Unit.Parse(dtfield.Rows[0]["hy_width"].ToString()); } if (dtfield.Rows[0]["hy_height"].ToString() != "") { txtTextBox.Height = Unit.Parse(dtfield.Rows[0]["hy_height"].ToString()); } if (dtfield.Rows[0]["hy_onclick"].ToString() != "") { txtTextBox.Attributes.Add("onclick", dtfield.Rows[0]["hy_onclick"].ToString()); } if (dtfield.Rows[0]["hy_ondblclick"].ToString() != "") { txtTextBox.Attributes.Add("ondblclick", dtfield.Rows[0]["hy_ondblclick"].ToString()); } if (dtfield.Rows[0]["hy_onchange"].ToString() != "") { txtTextBox.Attributes.Add("onchange", dtfield.Rows[0]["hy_onchange"].ToString()); } if (dtfield.Rows[0]["hy_onkeydown"].ToString() != "") { txtTextBox.Attributes.Add("onkeydown", dtfield.Rows[0]["hy_onkeydown"].ToString()); } if (dtfield.Rows[0]["hy_onkeyup"].ToString() != "") { txtTextBox.Attributes.Add("onkeyup", dtfield.Rows[0]["hy_onkeyup"].ToString()); } txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } } //按钮 if (field_type == "按钮") { //-----开始输出字段------ if (ls_laborinput == "0") //输出LABLE { Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); txtTextBox.Text = " "; tCell2.Controls.Add(txtTextBox); } else { Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); field_docvalue = "<input type=button id='btn_" + dtfield.Rows[0]["hy_fieldid"].ToString() + "' value='" + dtfield.Rows[0]["hy_fieldname"].ToString() + "' class=btn3 onclick=\"" + dtfield.Rows[0]["hy_onclick"].ToString() + "\" />"; txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } } //一直显示的按钮 if (field_type == "一直显示的按钮") { //-----开始输出字段------ Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); field_docvalue = "<input type=button id='btn_" + dtfield.Rows[0]["hy_fieldid"].ToString() + "' value='" + dtfield.Rows[0]["hy_fieldname"].ToString() + "' class=btn3 onclick=\"" + dtfield.Rows[0]["hy_onclick"].ToString() + "\" />"; txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } //日期 if (field_type == "日期") { //-----开始输出字段------ if (ls_laborinput == "0") //输出LABLE { Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } else { TextBox txtTextBox = new TextBox(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); if (dtfield.Rows[0]["hy_ifreadonly"].ToString() == "是") { txtTextBox.ReadOnly = true; } if (dtfield.Rows[0]["hy_class"].ToString() != "") { txtTextBox.CssClass = dtfield.Rows[0]["hy_class"].ToString(); } if (dtfield.Rows[0]["hy_width"].ToString() != "") { txtTextBox.Width = Unit.Parse(dtfield.Rows[0]["hy_width"].ToString()); } if (dtfield.Rows[0]["hy_height"].ToString() != "") { txtTextBox.Height = Unit.Parse(dtfield.Rows[0]["hy_height"].ToString()); } if (dtfield.Rows[0]["hy_onclick"].ToString() != "") { txtTextBox.Attributes.Add("onclick", dtfield.Rows[0]["hy_onclick"].ToString()); } if (dtfield.Rows[0]["hy_ondblclick"].ToString() != "") { txtTextBox.Attributes.Add("ondblclick", dtfield.Rows[0]["hy_ondblclick"].ToString()); } if (dtfield.Rows[0]["hy_onchange"].ToString() != "") { txtTextBox.Attributes.Add("onchange", dtfield.Rows[0]["hy_onchange"].ToString()); } if (dtfield.Rows[0]["hy_onkeydown"].ToString() != "") { txtTextBox.Attributes.Add("onkeydown", dtfield.Rows[0]["hy_onkeydown"].ToString()); } if (dtfield.Rows[0]["hy_onkeyup"].ToString() != "") { txtTextBox.Attributes.Add("onkeyup", dtfield.Rows[0]["hy_onkeyup"].ToString()); } txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } } //文本加按钮 if (field_type == "文本加按钮") { //-----开始输出字段------ if (ls_laborinput == "0") //输出LABLE { Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } else { TextBox txtTextBox = new TextBox(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); if (dtfield.Rows[0]["hy_ifreadonly"].ToString() == "是") { txtTextBox.ReadOnly = true; } if (dtfield.Rows[0]["hy_class"].ToString() != "") { txtTextBox.CssClass = dtfield.Rows[0]["hy_class"].ToString(); } txtTextBox.Width = Unit.Parse("60%"); if (dtfield.Rows[0]["hy_height"].ToString() != "") { txtTextBox.Height = Unit.Parse(dtfield.Rows[0]["hy_height"].ToString()); } txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); Label txtTextBox2 = new Label(); txtTextBox2.ID = "span_" + dtfield.Rows[0]["hy_fieldid"].ToString(); field_docvalue = "<input type=button id='btn_" + dtfield.Rows[0]["hy_fieldid"].ToString() + "' value=' 选 择 ' class=btn3 onclick=\"" + dtfield.Rows[0]["hy_onclick"].ToString() + "\" />"; txtTextBox2.Text = field_docvalue; tCell2.Controls.Add(txtTextBox2); } } //多行文本加按钮 if (field_type == "多行文本加按钮") { //-----开始输出字段------ if (ls_laborinput == "0") //输出LABLE { Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } else { TextBox txtTextBox = new TextBox(); txtTextBox.TextMode = TextBoxMode.MultiLine; txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); if (dtfield.Rows[0]["hy_ifreadonly"].ToString() == "是") { txtTextBox.ReadOnly = true; } if (dtfield.Rows[0]["hy_class"].ToString() != "") { txtTextBox.CssClass = dtfield.Rows[0]["hy_class"].ToString(); } if (dtfield.Rows[0]["hy_width"].ToString() != "") { txtTextBox.Width = Unit.Parse(dtfield.Rows[0]["hy_width"].ToString()); } if (dtfield.Rows[0]["hy_height"].ToString() != "") { txtTextBox.Height = Unit.Parse(dtfield.Rows[0]["hy_height"].ToString()); } txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); Label txtTextBox2 = new Label(); txtTextBox2.ID = "span_" + dtfield.Rows[0]["hy_fieldid"].ToString(); field_docvalue = "<input type=button id='btn_" + dtfield.Rows[0]["hy_fieldid"].ToString() + "' value=' 选 择 ' class=btn3 onclick=\"" + dtfield.Rows[0]["hy_onclick"].ToString() + "\" />"; txtTextBox2.Text = field_docvalue; tCell2.Controls.Add(txtTextBox2); } } //意见加按钮 if (field_type == "意见加按钮") { //-----开始输出字段------ if (ls_laborinput == "0") //输出LABLE { Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } else { TextBox txtTextBox = new TextBox(); txtTextBox.TextMode = TextBoxMode.MultiLine; txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); if (dtfield.Rows[0]["hy_ifreadonly"].ToString() == "是") { txtTextBox.ReadOnly = true; } if (dtfield.Rows[0]["hy_class"].ToString() != "") { txtTextBox.CssClass = dtfield.Rows[0]["hy_class"].ToString(); } if (dtfield.Rows[0]["hy_width"].ToString() != "") { txtTextBox.Width = Unit.Parse(dtfield.Rows[0]["hy_width"].ToString()); } if (dtfield.Rows[0]["hy_height"].ToString() != "") { txtTextBox.Height = Unit.Parse(dtfield.Rows[0]["hy_height"].ToString()); } //txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); Label txtTextBox2 = new Label(); txtTextBox2.ID = "span_" + dtfield.Rows[0]["hy_fieldid"].ToString(); field_docvalue = "<input type=button id='btn_" + dtfield.Rows[0]["hy_fieldid"].ToString() + "' value=' 选 择 ' class=btn3 onclick=\"" + dtfield.Rows[0]["hy_onclick"].ToString() + "\" /><input type=button id='btn_" + dtfield.Rows[0]["hy_fieldid"].ToString() + "_cz' value=' 重 置 ' class=btn3 onclick=\"document.getElementById('" + dtfield.Rows[0]["hy_fieldid"].ToString() + "').value='';\" />"; txtTextBox2.Text = field_docvalue; tCell2.Controls.Add(txtTextBox2); } } //数值 if (field_type == "数值") { //-----开始输出字段------ if (ls_laborinput == "0") //输出LABLE { Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } else { TextBox txtTextBox = new TextBox(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); if (dtfield.Rows[0]["hy_ifreadonly"].ToString() == "是") { txtTextBox.ReadOnly = true; } if (dtfield.Rows[0]["hy_class"].ToString() != "") { txtTextBox.CssClass = dtfield.Rows[0]["hy_class"].ToString(); } if (dtfield.Rows[0]["hy_width"].ToString() != "") { txtTextBox.Width = Unit.Parse(dtfield.Rows[0]["hy_width"].ToString()); } if (dtfield.Rows[0]["hy_height"].ToString() != "") { txtTextBox.Height = Unit.Parse(dtfield.Rows[0]["hy_height"].ToString()); } if (dtfield.Rows[0]["hy_onclick"].ToString() != "") { txtTextBox.Attributes.Add("onclick", dtfield.Rows[0]["hy_onclick"].ToString()); } if (dtfield.Rows[0]["hy_ondblclick"].ToString() != "") { txtTextBox.Attributes.Add("ondblclick", dtfield.Rows[0]["hy_ondblclick"].ToString()); } if (dtfield.Rows[0]["hy_onchange"].ToString() != "") { txtTextBox.Attributes.Add("onchange", dtfield.Rows[0]["hy_onchange"].ToString()); } if (dtfield.Rows[0]["hy_onkeydown"].ToString() != "") { txtTextBox.Attributes.Add("onkeydown", dtfield.Rows[0]["hy_onkeydown"].ToString()); } if (dtfield.Rows[0]["hy_onkeyup"].ToString() != "") { txtTextBox.Attributes.Add("onkeyup", dtfield.Rows[0]["hy_onkeyup"].ToString()); } txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } } //对话框列表(下拉框 if (field_type == "对话框列表") { //-----开始输出字段------ if (ls_laborinput == "0") //输出LABLE { Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } else { DropDownList ddlDropDownList = new DropDownList(); ddlDropDownList.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); if (dtfield.Rows[0]["hy_class"].ToString() != "") { ddlDropDownList.CssClass = dtfield.Rows[0]["hy_class"].ToString(); } if (dtfield.Rows[0]["hy_height"].ToString() != "") { ddlDropDownList.Height = Unit.Parse(dtfield.Rows[0]["hy_height"].ToString()); } if (dtfield.Rows[0]["hy_onchange"].ToString() != "") { ddlDropDownList.Attributes.Add("onchange", dtfield.Rows[0]["hy_onchange"].ToString()); } if (dtfield.Rows[0]["hy_optiontype"].ToString() == "0") { //手工配置 if (dtfield.Rows[0]["hy_options"].ToString() != "") { string[] lv_options = dtfield.Rows[0]["hy_options"].ToString().Split('#'); for (int i = 0; i < lv_options.Length; i++) { ddlDropDownList.Items.Add(lv_options[i].ToString()); } } } if (dtfield.Rows[0]["hy_optiontype"].ToString() == "1") { //SQL语句 if (dtfield.Rows[0]["hy_options"].ToString() != "") { //如果SQL语句中含有特殊标示,则需要替换 string ls_sql = dtfield.Rows[0]["hy_options"].ToString(); if (ls_sql.Contains("用户ID")) { ls_sql = ls_sql.Replace("用户ID", "'" + Session["hyuid"].ToString() + "'"); } if (ls_sql.Contains("用户名")) { ls_sql = ls_sql.Replace("用户名", "'" + Session["hyuname"].ToString() + "'"); } if (ls_sql.Contains("部门ID")) { ls_sql = ls_sql.Replace("部门ID", "'" + Session["hydeptid"].ToString() + "'"); } if (ls_sql.Contains("部门名")) { ls_sql = ls_sql.Replace("部门名", "'" + Session["hydeptname"].ToString() + "'"); } DataTable dt_options = Hyoa_global.GetDataTable(ls_sql); ddlDropDownList.DataSource = dt_options; ddlDropDownList.DataTextField = dt_options.Columns[0].ColumnName; ddlDropDownList.DataValueField = dt_options.Columns[0].ColumnName; ddlDropDownList.DataBind(); } } ddlDropDownList.Items.Insert(0, new ListItem("--请选择--", "")); ddlDropDownList.SelectedValue = field_docvalue; tCell2.Controls.Add(ddlDropDownList); } } //复选框(查询时直接显示文本框) if (field_type == "复选框") { //-----开始输出字段------ if (ls_laborinput == "0") //输出LABLE { Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } else { CheckBoxList txtTextBox = new CheckBoxList(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); if (dtfield.Rows[0]["hy_class"].ToString() != "") { txtTextBox.CssClass = dtfield.Rows[0]["hy_class"].ToString(); } if (dtfield.Rows[0]["hy_width"].ToString() != "") { txtTextBox.Width = Unit.Parse(dtfield.Rows[0]["hy_width"].ToString()); } if (dtfield.Rows[0]["hy_height"].ToString() != "") { txtTextBox.Height = Unit.Parse(dtfield.Rows[0]["hy_height"].ToString()); } if (dtfield.Rows[0]["hy_onclick"].ToString() != "") { txtTextBox.Attributes.Add("onclick", dtfield.Rows[0]["hy_onclick"].ToString()); } if (dtfield.Rows[0]["hy_optiontype"].ToString() == "0") { //手工配置 if (dtfield.Rows[0]["hy_options"].ToString() != "") { string[] lv_options = dtfield.Rows[0]["hy_options"].ToString().Split('#'); for (int i = 0; i < lv_options.Length; i++) { txtTextBox.Items.Add(lv_options[i].ToString()); } } } if (dtfield.Rows[0]["hy_optiontype"].ToString() == "1") { //SQL语句 //如果SQL语句中含有特殊标示,则需要替换 string ls_sql = dtfield.Rows[0]["hy_options"].ToString(); if (ls_sql.Contains("用户ID")) { ls_sql = ls_sql.Replace("用户ID", "'" + Session["hyuid"].ToString() + "'"); } if (ls_sql.Contains("用户名")) { ls_sql = ls_sql.Replace("用户名", "'" + Session["hyuname"].ToString() + "'"); } if (ls_sql.Contains("部门ID")) { ls_sql = ls_sql.Replace("部门ID", "'" + Session["hydeptid"].ToString() + "'"); } if (ls_sql.Contains("部门名")) { ls_sql = ls_sql.Replace("部门名", "'" + Session["hydeptname"].ToString() + "'"); } if (dtfield.Rows[0]["hy_options"].ToString() != "") { DataTable dt_options = Hyoa_global.GetDataTable(ls_sql); txtTextBox.DataSource = dt_options; txtTextBox.DataTextField = dt_options.Columns[0].ColumnName; txtTextBox.DataValueField = dt_options.Columns[0].ColumnName; txtTextBox.DataBind(); } } if (field_docvalue != "") { field_docvalue = "," + field_docvalue + ","; foreach (ListItem li in txtTextBox.Items) { if (field_docvalue.Contains(li.Value)) li.Selected = true; } } tCell2.Controls.Add(txtTextBox); } } //单选框(查询时直接显示文本框) if (field_type == "单选框") { //-----开始输出字段------ if (ls_laborinput == "0") //输出LABLE { Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } else { RadioButtonList txtTextBox = new RadioButtonList(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); if (dtfield.Rows[0]["hy_class"].ToString() != "") { txtTextBox.CssClass = dtfield.Rows[0]["hy_class"].ToString(); } if (dtfield.Rows[0]["hy_width"].ToString() != "") { txtTextBox.Width = Unit.Parse(dtfield.Rows[0]["hy_width"].ToString()); } if (dtfield.Rows[0]["hy_height"].ToString() != "") { txtTextBox.Height = Unit.Parse(dtfield.Rows[0]["hy_height"].ToString()); } if (dtfield.Rows[0]["hy_onclick"].ToString() != "") { txtTextBox.Attributes.Add("onclick", dtfield.Rows[0]["hy_onclick"].ToString()); } if (dtfield.Rows[0]["hy_optiontype"].ToString() == "0") { //手工配置 if (dtfield.Rows[0]["hy_options"].ToString() != "") { string[] lv_options = dtfield.Rows[0]["hy_options"].ToString().Split('#'); for (int i = 0; i < lv_options.Length; i++) { txtTextBox.Items.Add(lv_options[i].ToString()); } } } if (dtfield.Rows[0]["hy_optiontype"].ToString() == "1") { //SQL语句 //如果SQL语句中含有特殊标示,则需要替换 string ls_sql = dtfield.Rows[0]["hy_options"].ToString(); if (ls_sql.Contains("用户ID")) { ls_sql = ls_sql.Replace("用户ID", "'" + Session["hyuid"].ToString() + "'"); } if (ls_sql.Contains("用户名")) { ls_sql = ls_sql.Replace("用户名", "'" + Session["hyuname"].ToString() + "'"); } if (ls_sql.Contains("部门ID")) { ls_sql = ls_sql.Replace("部门ID", "'" + Session["hydeptid"].ToString() + "'"); } if (ls_sql.Contains("部门名")) { ls_sql = ls_sql.Replace("部门名", "'" + Session["hydeptname"].ToString() + "'"); } if (dtfield.Rows[0]["hy_options"].ToString() != "") { DataTable dt_options = Hyoa_global.GetDataTable(ls_sql); txtTextBox.DataSource = dt_options; txtTextBox.DataTextField = dt_options.Columns[0].ColumnName; txtTextBox.DataValueField = dt_options.Columns[0].ColumnName; txtTextBox.DataBind(); } } txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } } //口令 if (field_type == "口令") { //-----开始输出字段------ if (ls_laborinput == "0") //输出LABLE { Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); txtTextBox.Text = " "; tCell2.Controls.Add(txtTextBox); } else { TextBox txtTextBox = new TextBox(); txtTextBox.TextMode = TextBoxMode.Password; txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); if (dtfield.Rows[0]["hy_ifreadonly"].ToString() == "是") { txtTextBox.ReadOnly = true; } if (dtfield.Rows[0]["hy_class"].ToString() != "") { txtTextBox.CssClass = dtfield.Rows[0]["hy_class"].ToString(); } if (dtfield.Rows[0]["hy_width"].ToString() != "") { txtTextBox.Width = Unit.Parse(dtfield.Rows[0]["hy_width"].ToString()); } if (dtfield.Rows[0]["hy_height"].ToString() != "") { txtTextBox.Height = Unit.Parse(dtfield.Rows[0]["hy_height"].ToString()); } if (dtfield.Rows[0]["hy_onclick"].ToString() != "") { txtTextBox.Attributes.Add("onclick", dtfield.Rows[0]["hy_onclick"].ToString()); } if (dtfield.Rows[0]["hy_ondblclick"].ToString() != "") { txtTextBox.Attributes.Add("ondblclick", dtfield.Rows[0]["hy_ondblclick"].ToString()); } if (dtfield.Rows[0]["hy_onchange"].ToString() != "") { txtTextBox.Attributes.Add("onchange", dtfield.Rows[0]["hy_onchange"].ToString()); } if (dtfield.Rows[0]["hy_onkeydown"].ToString() != "") { txtTextBox.Attributes.Add("onkeydown", dtfield.Rows[0]["hy_onkeydown"].ToString()); } if (dtfield.Rows[0]["hy_onkeyup"].ToString() != "") { txtTextBox.Attributes.Add("onkeyup", dtfield.Rows[0]["hy_onkeyup"].ToString()); } txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } } //附件组件 if (field_type == "附件组件") { //读取附件内容 HyoaClass.Hyoa_fileatt Hyoa_fileatt = new HyoaClass.Hyoa_fileatt(); DataTable dt_fileatt = Hyoa_fileatt.GetfileattByFatheridandFatherfield(this.txtdocid.Value, hy_fieldid); field_docvalue = ""; if (dt_fileatt.Rows.Count > 0) { for (var ii = 0; ii < dt_fileatt.Rows.Count; ii++) { field_docvalue += (ii + 1).ToString() + "、<a href=\"" + dt_fileatt.Rows[ii]["hy_filepath"].ToString() + "\" target=_blank>" + dt_fileatt.Rows[ii]["hy_filename"].ToString() + "</a><br />"; } } //-----开始输出字段------ if (ls_laborinput == "0") //输出LABLE { Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); if (field_docvalue == "") { field_docvalue = " "; } txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } else { Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); field_docvalue += "<input type=button id='uploadfile1' value='附件管理' class=btn3 onclick=\"window.open('ggdy/main_fileatt.aspx?fatherid=" + this.txtdocid.Value + "&fatherfield=" + hy_fieldid + "','filewindow','height=350,width=600,top=100,left=200,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');\" />"; txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } } //说明文字 if (field_type == "说明文字") { //-----开始输出字段------ if (ls_laborinput == "0") //输出LABLE { Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } else { Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } } //编辑器 if (field_type == "编辑器") { //-----开始输出字段------ if (ls_laborinput == "0") //输出LABLE { Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } else { //隐藏文本框 TextBox txtTextBox = new TextBox(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); txtTextBox.Text = field_docvalue; txtTextBox.Style.Value = "display:none"; tCell2.Controls.Add(txtTextBox); //编辑器 Label txtTextBox2 = new Label(); txtTextBox2.ID = "eWebEditor" + dtfield.Rows[0]["hy_fieldid"].ToString(); field_docvalue = "<iframe ID=\"eWebEditor" + dtfield.Rows[0]["hy_fieldid"].ToString() + "\" src=\"system/eWebEditor/ewebeditor.htm?id=" + dtfield.Rows[0]["hy_fieldid"].ToString() + "&style=Portal\" frameborder=0 scrolling=no width=" + dtfield.Rows[0]["hy_width"].ToString() + " height=" + dtfield.Rows[0]["hy_height"].ToString() + "></iframe>"; txtTextBox2.Text = field_docvalue; tCell2.Controls.Add(txtTextBox2); } } //痕迹保留 if (field_type == "痕迹保留") { //-----开始输出字段------ if (ls_laborinput == "0") //输出LABLE { field_docvalue = "<input type=button id=\"btn_" + dtfield.Rows[0]["hy_fieldid"].ToString() + "\" value='正 文' class=btn3 onclick=\"window.open('ntko/readoffice.aspx?newofficetype=1&fatherid=" + this.txtdocid.Value + "&tableid=" + this.hy_tableid.Text + "&tacheByhj=1&jsxd=1&rnd='+Math.random(),'hjblwindow','height=768,width=1024,top=0,left=0,toolbar=no,menubar=no,scrollbars=yes, resizable=yes,location=no, status=no');\" /> "; Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } else { field_docvalue = "<input type=button id=\"btn_" + dtfield.Rows[0]["hy_fieldid"].ToString() + "\" value='正 文' class=btn3 onclick=\"window.open('ntko/editoffice.aspx?newofficetype=1&fatherid=" + this.txtdocid.Value + "&tableid=" + this.hy_tableid.Text + "&tacheByhj=1&jsxd=0&rnd='+Math.random(),'hjblwindow','height=768,width=1024,top=0,left=0,toolbar=no,menubar=no,scrollbars=yes, resizable=yes,location=no, status=no');\" /> "; //如果是流程模块,则根据环节判断一下 if (ifflowdoc == "1") { //判断是否为第一环节 HyoaClass.Hyoa_flowwork Hyoa_flowwork = new HyoaClass.Hyoa_flowwork(); DataTable dtflowwork = Hyoa_flowwork.Getflowworkbyflowidtacheid(this.hy_flowid.Text, "*"); if (dtflowwork.Rows.Count > 0) { if (dtflowwork.Rows[0]["hy_nexttacheid"].ToString() == this.hy_curtacheid.Text) { field_docvalue = "<input type=button id=\"btn_" + dtfield.Rows[0]["hy_fieldid"].ToString() + "\" value='正 文' class=btn3 onclick=\"window.open('ntko/editoffice.aspx?newofficetype=1&fatherid=" + this.txtdocid.Value + "&tableid=" + this.hy_tableid.Text + "&tacheByhj=1&jsxd=0&rnd='+Math.random(),'hjblwindow','height=768,width=1024,top=0,left=0,toolbar=no,menubar=no,scrollbars=yes, resizable=yes,location=no, status=no');\" /> "; } else { //判断是否为最后一个环节 dtflowwork.Clear(); dtflowwork = Hyoa_flowwork.Getflowworkbyflowidtacheid(this.hy_flowid.Text, this.hy_curtacheid.Text); if (dtflowwork.Rows.Count > 0) { if (dtflowwork.Rows[0]["hy_nexttacheid"].ToString() == "**") { field_docvalue = "<input type=button id=\"btn_" + dtfield.Rows[0]["hy_fieldid"].ToString() + "\" value='正 文' class=btn3 onclick=\"window.open('ntko/editoffice.aspx?newofficetype=1&fatherid=" + this.txtdocid.Value + "&tableid=" + this.hy_tableid.Text + "&tacheByhj=0&jsxd=1&rnd='+Math.random(),'hjblwindow','height=768,width=1024,top=0,left=0,toolbar=no,menubar=no,scrollbars=yes, resizable=yes,location=no, status=no');\" /> "; } else { field_docvalue = "<input type=button id=\"btn_" + dtfield.Rows[0]["hy_fieldid"].ToString() + "\" value='正 文' class=btn3 onclick=\"window.open('ntko/editoffice.aspx?newofficetype=1&fatherid=" + this.txtdocid.Value + "&tableid=" + this.hy_tableid.Text + "&tacheByhj=0&jsxd=0&rnd='+Math.random(),'hjblwindow','height=768,width=1024,top=0,left=0,toolbar=no,menubar=no,scrollbars=yes, resizable=yes,location=no, status=no');\" /> "; } } } } } Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } } //IFRAME列表 if (field_type == "IFRAME列表") { //-----开始输出字段------ if (ls_laborinput == "0") //输出LABLE { field_docvalue = "<iframe id=\"ifr_" + dtfield.Rows[0]["hy_fieldid"].ToString() + "\" name=\"ifr_" + dtfield.Rows[0]["hy_fieldid"].ToString() + "\" src=\"" + dtfield.Rows[0]["hy_defaultvalue"].ToString() + "&motherid=" + this.txtdocid.Value + "&ishaverole=0\" frameborder=\"0\" scrolling=\"yes\" height=\"80px\" width=\"98%\"></iframe>"; Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } else { field_docvalue = "<iframe id=\"ifr_" + dtfield.Rows[0]["hy_fieldid"].ToString() + "\" name=\"ifr_" + dtfield.Rows[0]["hy_fieldid"].ToString() + "\" src=\"" + dtfield.Rows[0]["hy_defaultvalue"].ToString() + "&motherid=" + this.txtdocid.Value + "&ishaverole=1\" frameborder=\"0\" scrolling=\"yes\" height=\"80px\" width=\"98%\"></iframe>"; Label txtTextBox = new Label(); txtTextBox.ID = dtfield.Rows[0]["hy_fieldid"].ToString(); txtTextBox.Text = field_docvalue; tCell2.Controls.Add(txtTextBox); } } //子表信息带链接 //子表信息不带链接 } return li_return; }
public void RepeatColumsTooLow() { CheckBoxList c = new CheckBoxList(); c.RepeatColumns = -1; }
public void CellSpacingTooLow() { CheckBoxList c = new CheckBoxList(); c.CellSpacing = -2; }
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { string DepartMentID = DataBinder.Eval(e.Item.DataItem, "DepartMentID").ToString(); DataTable dt = new DataTable(); CheckBoxList chklUSERNAME = new CheckBoxList(); chklUSERNAME = (CheckBoxList)e.Item.FindControl("chklUSERNAME"); CheckBox chkDepartment = new CheckBox(); chkDepartment = (CheckBox)e.Item.FindControl("chkDepartment"); if (this.rblLimitsChoose.SelectedValue == "1" || this.rblLimitsChoose.SelectedValue == "2")//本部门/全员 { string strSQL = "Select ID,REALNAME+'('+USERNAME+')' as USERINFO From USER_Users WHERE DELFLAG=0 and DepartMentID='" + DepartMentID + "'"; dt = pageControl.doSql(strSQL).Tables[0]; //dt = bUSER_Users.GetList("DELFLAG=0 and DepartMentID='" + DepartMentID + "'").Tables[0]; if (dt.Rows.Count > 0) { chklUSERNAME.Visible = true; chklUSERNAME.DataSource = dt; chklUSERNAME.DataTextField = "USERINFO"; chklUSERNAME.DataValueField = "ID"; chklUSERNAME.DataBind(); } else { chklUSERNAME.Visible = false; } } else if (this.rblLimitsChoose.SelectedValue == "3")//项目组成员 { string sql = "SELECT USERID,REALNAME+'('+USERNAME+')' as USERINFO FROM vProject_UserList WHERE ProjectID='" + _projectid + "' and DepartMentID='" + DepartMentID + "'"; dt = pageControl.doSql(sql).Tables[0]; if (dt.Rows.Count > 0) { chklUSERNAME.Visible = true; chklUSERNAME.DataSource = dt; chklUSERNAME.DataTextField = "USERINFO"; chklUSERNAME.DataValueField = "USERID"; chklUSERNAME.DataBind(); } else { chklUSERNAME.Visible = false; } } DataTable dtUserID = new DataTable(); dtUserID = (DataTable)Session["UserID"]; // CheckBoxList chkl = (CheckBoxList)sender; foreach (ListItem li in chklUSERNAME.Items) { if (dtUserID.Rows.Count > 0) { if ((dtUserID.Select("UserID='" + li.Value + "'")).Length > 0) { chkDepartment.Checked = true; li.Selected = true; } } } } }
private Dictionary <string, string> SetFieldValues(int _channel_id) { DataTable dt = new BLL.article_attribute_field().GetList(_channel_id, "").Tables[0]; Dictionary <string, string> dic = new Dictionary <string, string>(); foreach (DataRow dr in dt.Rows) { //查找相应的控件 switch (dr["control_type"].ToString()) { case "single-text": //单行文本 TextBox txtControl = FindControl("field_control_" + dr["name"].ToString()) as TextBox; if (txtControl != null) { dic.Add(dr["name"].ToString(), txtControl.Text.Trim()); } break; case "multi-text": //多行文本 goto case "single-text"; case "editor": //编辑器 HtmlTextArea htmlTextAreaControl = FindControl("field_control_" + dr["name"].ToString()) as HtmlTextArea; if (htmlTextAreaControl != null) { dic.Add(dr["name"].ToString(), htmlTextAreaControl.Value); } break; case "images": //图片上传 goto case "single-text"; case "number": //数字 goto case "single-text"; case "checkbox": //复选框 CheckBox cbControl = FindControl("field_control_" + dr["name"].ToString()) as CheckBox; if (cbControl != null) { if (cbControl.Checked == true) { dic.Add(dr["name"].ToString(), "1"); } else { dic.Add(dr["name"].ToString(), "0"); } } break; case "multi-radio": //多项单选 RadioButtonList rblControl = FindControl("field_control_" + dr["name"].ToString()) as RadioButtonList; if (rblControl != null) { dic.Add(dr["name"].ToString(), rblControl.SelectedValue); } break; case "multi-checkbox": //多项多选 CheckBoxList cblControl = FindControl("field_control_" + dr["name"].ToString()) as CheckBoxList; if (cblControl != null) { StringBuilder tempStr = new StringBuilder(); for (int i = 0; i < cblControl.Items.Count; i++) { if (cblControl.Items[i].Selected) { tempStr.Append(cblControl.Items[i].Value.Replace(',', ',') + ","); } } dic.Add(dr["name"].ToString(), Utils.DelLastComma(tempStr.ToString())); } break; } } return(dic); }
private void BuildFacultyType() { Utilities.DataIO data = new Profiles.Search.Utilities.DataIO(); DropDownList ddl = new DropDownList(); ddl.ID = "ddlChkList"; ListItem lstItem = new ListItem(); ddl.Items.Insert(0, lstItem); ddl.Width = new Unit(250); ddl.Height = new Unit(20); ddl.Attributes.Add("onmousedown", "showdivonClick()"); CheckBoxList chkBxLst = new CheckBoxList(); chkBxLst.ID = "chkLstItem"; chkBxLst.Attributes.Add("onmouseover", "showdiv()"); List <GenericListItem> dtListItem = data.GetFacultyRanks(); int rowNo = dtListItem.Count; string lstValue = string.Empty; string lstID = string.Empty; string javascript = string.Empty; litFacRankScript.Text = "<script>"; for (int i = 0; i < rowNo - 1; i++) { lstValue = dtListItem[i].Text; lstID = dtListItem[i].Value; lstItem = new ListItem("<a href=\"javascript:void(0)\" id=\"alst\" style=\"text-decoration:none;color:Black; \" onclick=\"getSelectedItem(' " + lstValue + "','" + i + "','" + lstID + "','anchor');\">" + lstValue + "</a>", lstID); lstItem.Attributes.Add("onclick", "getSelectedItem('" + lstValue + "','" + i + "','" + lstID + "','listItem');"); if (SearchRequest != null && !lstID.IsNullOrEmpty()) { if (SearchRequest.OuterXml.Contains(lstID)) { javascript += " javascript:getSelectedItem('" + lstValue + "','" + i + "','" + lstID + "','anchor');"; } } chkBxLst.Items.Add(lstItem); } litFacRankScript.Text += javascript + "</script>"; System.Web.UI.HtmlControls.HtmlGenericControl div = new System.Web.UI.HtmlControls.HtmlGenericControl("div"); div.ID = "divChkList"; div.Controls.Add(chkBxLst); div.Style.Add("background-color", "#ffffff"); div.Style.Add("position", "absolute"); div.Style.Add("fload", "left"); div.Style.Add("border", "black 1px solid"); div.Style.Add("width", "249px"); div.Style.Add("height", "180px"); div.Style.Add("overflow", "AUTO"); div.Style.Add("display", "none"); div.Style.Add("padding-top", "25px"); phDDLCHK.Controls.Add(ddl); phDDLList.Controls.Add(div); }
// Deleta o(s) recurso(s) selecionado(s) protected void butDeletar_Click(object sender, ImageClickEventArgs e) { ImageButton butDel = (ImageButton)sender; // O checkbox list está dentro da célula da tabela... HtmlTableCell cell = (HtmlTableCell)butDel.Parent; CheckBoxList cbList = (CheckBoxList)cell.FindControl("cbRecursos"); // Para chegar no DataGridItem correspondente... bleargh! DataGridItem grid = (DataGridItem)cell.Parent.Parent.Parent.Parent.Parent; DropDownList ddlDisponiveis = (DropDownList)grid.FindControl("ddlDisponiveis"); string dataString = ((Label)grid.FindControl("lblData")).Text; DateTime data = Convert.ToDateTime(dataString); string horario = ((Label)grid.FindControl("lblHora")).Text; string aulaString = ((Label)grid.FindControl("lblAulaId")).Text; Guid aulaId = new Guid(aulaString); Aula aula = aulaBo.GetAulaById(aulaId); // Varre o checkbox list do fim para o início, // e remove todos os recursos selecionados (da tela e do BD) List <Recurso> listaRecLib = new List <Recurso>(); for (int r = cbList.Items.Count - 1; r >= 0; r--) { ListItem recurso = cbList.Items[r]; if (recurso.Selected) { Guid recId = new Guid(recurso.Value); Recurso rec = recursosBO.GetRecursoById(recId); Alocacao aloc = new Alocacao(rec, data, horario, null, null); alocBO.UpdateAlocacao(aloc); cbList.Items.RemoveAt(r); // TODO: melhorar isso - só envia email se forem recursos com a palavra "lab" em algum lugar if (rec.Categoria.Descricao.ToLower().Contains("lab")) { listaRecLib.Add(rec); } } } //ImageButton butDel = (ImageButton)grid.FindControl("butDeletar"); ImageButton butTransf = (ImageButton)grid.FindControl("butTransferir"); ImageButton butTrocar = (ImageButton)grid.FindControl("butTrocar"); // Se nenhum restou, esconde botões if (cbList.Items.Count == 0) { butDel.Visible = false; butTransf.Visible = false; butTrocar.Visible = false; } // Recria o dropdownlist de recursos disponíveis //ddlDisponiveis.Items.Clear(); List <Recurso> livres = recursosBO.GetRecursosDisponiveis(data, horario); livres.Sort(); Recurso dummy = new Recurso(); dummy.Descricao = "Selecionar..."; dummy.Id = dummyGuid; livres.Insert(0, dummy); ddlDisponiveis.DataValueField = "Id"; ddlDisponiveis.DataTextField = "Descricao"; ddlDisponiveis.DataSource = livres; ddlDisponiveis.DataBind(); AtualizaTodaGrade(); if (listaRecLib.Count > 0) { EnviarEmailLiberacao("*****@*****.**", listaRecLib, data, horario); } }
protected override void CreateChildControls() { Controls.Clear(); checkBoxListControls.Clear(); if (_report == null) { _report = (Rdl.Engine.Report)Page.Session["RdlReport"]; } if (_report != null) { foreach (Rdl.Engine.ReportParameter r in _report.ReportParameters.Values) { r.LoadValidValues(_report); } } if (_report != null) { List <Control> requiredControls = new List <Control>(); List <Control> optionalControls = new List <Control>(); foreach (Rdl.Engine.ReportParameter parm in _report.ReportParameters.Values) { List <Control> controlList = (parm.Nullable || parm.AllowBlank) ? optionalControls : requiredControls; if (!parm.Hidden) { controlList.Add(new LiteralControl("<div style=\"margin: 5px;\">" + parm.Prompt + " ")); if (parm.ValidValues.Count > 0) { if (parm.MultiValue) { CheckBoxList checkBoxList = new CheckBoxList(); checkBoxList.ID = parm.Name; controlList.Add(new LiteralControl("<div style=\"overflow: scroll; height: 100px;\">")); LiteralControl chkCheckAll = new LiteralControl(); controlList.Add(chkCheckAll); controlList.Add(checkBoxList); controlList.Add(new LiteralControl("</div>")); foreach (Rdl.Engine.ParameterValue value in parm.ValidValues) { checkBoxList.Items.Add(new ListItem(value.Label, value.Value)); } CheckBoxListControls chkControls = new CheckBoxListControls(); chkControls.checkBoxList = checkBoxList; chkControls.chkCheckAll = chkCheckAll; checkBoxListControls.Add(chkControls); if (parm.DefaultValue != null) { foreach (string s in parm.DefaultValue) { foreach (ListItem li in checkBoxList.Items) { if (li.Value == s) { li.Selected = true; } } } } } else { DropDownList ddl = new DropDownList(); controlList.Add(ddl); if (parm.Nullable) { ddl.Items.Add(new ListItem("", "")); } foreach (Rdl.Engine.ParameterValue value in parm.ValidValues) { ddl.Items.Add(new ListItem(value.Label, value.Value)); } ddl.ID = parm.Name; ddl.AutoPostBack = true; if (parm.DefaultValue != null) { foreach (ListItem li in ddl.Items) { if (li.Value == parm.DefaultValue[0]) { ddl.SelectedValue = li.Value; } } } if (parm.Value != null) { foreach (ListItem li in ddl.Items) { if (li.Value == parm.Value.ToString()) { ddl.SelectedValue = li.Value; } } } } } else { switch (parm.DataType.Name) { case "Boolean": CheckBox cb = new CheckBox(); controlList.Add(cb); if (parm.Value != null) { cb.Checked = bool.Parse((string)parm.Value); } else if (parm.DefaultValue != null) { cb.Checked = bool.Parse(parm.DefaultValue[0]); } cb.ID = parm.Name; break; case "DateTime": TextBox tbCal = new TextBox(); tbCal.ID = parm.Name; controlList.Add(tbCal); if (parm.DefaultValue != null && parm.DefaultValue.Length > 0) { tbCal.Text = parm.DefaultValue[0]; } ImageButton ib = new ImageButton(); controlList.Add(ib); ib.ID = parm.Name + "_ib"; ib.ImageUrl = "image." + ReportServer._extension + "?source=resource&name=calendar.bmp"; AjaxControlToolkit.CalendarExtender ce = new AjaxControlToolkit.CalendarExtender(); controlList.Add(ce); ce.PopupButtonID = parm.Name + "_ib"; ce.TargetControlID = parm.Name; ce.ID = parm.Name + "_extender"; break; case "Int32": case "Single": case "String": TextBox tb = new TextBox(); controlList.Add(tb); tb.ID = parm.Name; string sValue = string.Empty; if (parm.MultiValue) { if (parm.Value == null) { if (parm.DefaultValue != null) { foreach (string val in parm.DefaultValue) { sValue += ((sValue.Length > 0) ? "," : string.Empty) + val; } } } else { foreach (string val in (string[])parm.Value) { sValue += ((sValue.Length > 0) ? "," : string.Empty) + val; } } } else { if (parm.Value != null) { sValue = parm.Value.ToString(); } else if (parm.DefaultValue != null) { sValue = parm.DefaultValue[0]; } } tb.Text = sValue; break; } } // Add some space before the next control. controlList.Add(new LiteralControl("</div>")); } //Controls.Add(new LiteralControl("    ")); } Panel panel = new Panel(); UpdatePanel updatePanel = new UpdatePanel(); panel.Controls.Add(updatePanel); btnView = new Button(); panel.Controls.Add(btnView); btnView.Text = "View"; btnView.ID = "ViewReport"; btnView.Click += new EventHandler(btnView_Click); panel.DefaultButton = "ViewReport"; // Add the required and optional parameter controls to the UpdatePanel if (requiredControls.Count > 0) { updatePanel.ContentTemplateContainer.Controls.Add(new LiteralControl("<div><b>Required Parameters:</b>")); foreach (Control ctrl in requiredControls) { updatePanel.ContentTemplateContainer.Controls.Add(ctrl); } updatePanel.ContentTemplateContainer.Controls.Add(new LiteralControl("</div>")); } if (optionalControls.Count > 0) { updatePanel.ContentTemplateContainer.Controls.Add(new LiteralControl("<div><b>Optional Parameters</b>")); foreach (Control ctrl in optionalControls) { updatePanel.ContentTemplateContainer.Controls.Add(ctrl); } updatePanel.ContentTemplateContainer.Controls.Add(new LiteralControl("</div>")); } Controls.Add(panel); } ChildControlsCreated = true; }
/// <summary> /// 返回CheckBoxList中返回的值 /// </summary> /// <param name="CheckBoxList2">checkboxlist</param> /// <returns>返回的整数值</returns> public static int GetSenstiveCheck(CheckBoxList CheckBoxList2) { int result = 0; string[] temp = new string[]{ "0","0","0","0","0"}; foreach (ListItem item in CheckBoxList2.Items) { if (item.Selected) { if (item.Value == "5") { temp[4] = "1"; } if (item.Value == "4") { temp[3] = "1"; } if (item.Value == "3") { temp[2] = "1"; } if (item.Value == "2") { temp[1] = "1"; } if (item.Value == "1") { temp[0] = "1"; } } else { if (item.Value == "5") { temp[4] = "0"; } if (item.Value == "4") { temp[3] = "0"; } if (item.Value == "3") { temp[2] = "0"; } if (item.Value == "2") { temp[1] = "0"; } if (item.Value == "1") { temp[0] = "0"; } } } string a = temp[4] + temp[3] + temp[2] + temp[1] + temp[0]; result = Convert.ToInt32(a, 2); return result; }
protected void SliderNixIt(object sender, EventArgs e) { int songCount = PictureCheckList.Items.Count; CheckBoxList tempList = new CheckBoxList(); for (int i = 0; i < songCount; i++) { if (!PictureCheckList.Items[i].Selected) tempList.Items.Add(PictureCheckList.Items[i]); else { if (System.IO.File.Exists(MapPath(".") + "/UserFiles/" + Session["UserName"].ToString() + "/Slider/" + PictureCheckList.Items[i].Value)) { System.IO.File.Delete(MapPath(".") + "/UserFiles/" + Session["UserName"].ToString() + "/Slider/" + PictureCheckList.Items[i].Value); } } } PictureCheckList.Items.Clear(); for (int j = 0; j < tempList.Items.Count; j++) { PictureCheckList.Items.Add(tempList.Items[j]); } if (PictureCheckList.Items.Count == 0) PictureNixItButton.Visible = false; }
public ProjectWizardPageView(ProjectWizardPageModel model) { var radioSpacing = Platform.IsGtk ? Size.Empty : new Size(2, 2); var content = new DynamicLayout { Spacing = new Size(10, 10) }; if (model.SupportsAppName) { var nameBox = new TextBox(); nameBox.TextBinding.BindDataContext((ProjectWizardPageModel m) => m.AppName); Application.Instance.AsyncInvoke(nameBox.Focus); var nameValid = new Label { TextColor = Global.Theme.ErrorForeground }; nameValid.BindDataContext(c => c.Visible, (ProjectWizardPageModel m) => m.AppNameInvalid); nameValid.BindDataContext(c => c.Text, (ProjectWizardPageModel m) => m.AppNameValidationText); content.BeginHorizontal(); content.Add(HeadingLabel((model.IsLibrary ? "Library" : "App") + " Name:")); content.AddColumn(nameBox, nameValid); content.EndHorizontal(); } else if (!string.IsNullOrEmpty(model.AppName)) { var label = new Label { Text = model.AppName, VerticalAlignment = VerticalAlignment.Center }; content.AddRow(HeadingLabel((model.IsLibrary ? "Library" : "App") + " Name:"), label); } if (model.SupportsCombined) { var platformTypeList = new RadioButtonList { Orientation = Orientation.Vertical, Spacing = radioSpacing, Items = { new ListItem { Text = "Separate projects for each platform", Key = "separate" }, new ListItem { Text = "Single Windows, Linux, and Mac desktop project", Key = "combined" } } }; platformTypeList.BindDataContext(c => c.Enabled, (ProjectWizardPageModel m) => m.AllowCombined); platformTypeList.SelectedKeyBinding .Convert(v => v == "combined", v => v ? "combined" : "separate") .BindDataContext((ProjectWizardPageModel m) => m.Combined); content.AddRow(HeadingLabel("Launcher:"), platformTypeList); } if (model.SupportsXamMac) { var cb = new CheckBox { Text = "Include Xamarin.Mac project", ToolTip = "This enables you to bundle mono with your app so your users don't have to install it separately. You can only compile this on a Mac" }; cb.CheckedBinding.BindDataContext((ProjectWizardPageModel m) => m.IncludeXamMac); content.AddRow(HeadingLabel(string.Empty), cb); } /* * eventually select platforms to include? * * var platformCheckBoxes = new DynamicLayout(); * platformCheckBoxes.BeginHorizontal(); * platformCheckBoxes.Add(new CheckBox { Text = "Gtk2" }); * platformCheckBoxes.Add(new CheckBox { Text = "Gtk3" }); * platformCheckBoxes.EndBeginHorizontal(); * platformCheckBoxes.Add(new CheckBox { Text = "WinForms" }); * platformCheckBoxes.Add(new CheckBox { Text = "Wpf" }); * platformCheckBoxes.Add(new CheckBox { Text = "Direct2D" }); * platformCheckBoxes.EndBeginHorizontal(); * platformCheckBoxes.Add(new CheckBox { Text = "Mac" }); * platformCheckBoxes.Add(new CheckBox { Text = "XamMac" }); * platformCheckBoxes.Add(new CheckBox { Text = "XamMac2" }); * platformCheckBoxes.EndHorizontal(); * * content.Rows.Add(new TableRow(new Label { Text = "Platforms:", TextAlignment = TextAlignment.Right }, platformCheckBoxes)); * /**/ if (model.SupportsFramework) { var frameworkCheckBoxes = new CheckBoxList(); frameworkCheckBoxes.BindDataContext(c => c.DataStore, (ProjectWizardPageModel m) => m.SupportedFrameworks); frameworkCheckBoxes.ItemTextBinding = Binding.Property((ProjectWizardPageModel.FrameworkInfo i) => i.Text); frameworkCheckBoxes.ItemKeyBinding = Binding.Property((ProjectWizardPageModel.FrameworkInfo i) => i.Value); frameworkCheckBoxes.SelectedValuesBinding.BindDataContext((ProjectWizardPageModel m) => m.SelectedFrameworks); content.AddRow(HeadingLabel("Framework:"), frameworkCheckBoxes); } if (model.SupportsProjectType) { var sharedCodeList = new RadioButtonList { Orientation = Orientation.Vertical, Spacing = radioSpacing, }; if (model.SupportsPCL) { sharedCodeList.Items.Add(new ListItem { Text = "Portable Class Library", Key = "pcl" }); sharedCodeList.SelectedKeyBinding.Convert(v => v == "pcl", v => v ? "pcl" : sharedCodeList.SelectedKey).BindDataContext((ProjectWizardPageModel m) => m.UsePCL); } if (model.SupportsNetStandard) { sharedCodeList.Items.Add(new ListItem { Text = ".NET Standard", Key = "netstandard" }); sharedCodeList.SelectedKeyBinding.Convert(v => v == "netstandard", v => v ? "netstandard" : sharedCodeList.SelectedKey).BindDataContext((ProjectWizardPageModel m) => m.UseNetStandard); } if (model.SupportsSAL) { sharedCodeList.Items.Add(new ListItem { Text = "Shared Project", Key = "sal" }); sharedCodeList.SelectedKeyBinding.Convert(v => v == "sal", v => v ? "sal" : sharedCodeList.SelectedKey).BindDataContext((ProjectWizardPageModel m) => m.UseSAL); } sharedCodeList.Items.Add(new ListItem { Text = "Full .NET", Key = "net" }); sharedCodeList.SelectedKeyBinding.Convert(v => v == "net", v => v ? "net" : sharedCodeList.SelectedKey).BindDataContext((ProjectWizardPageModel m) => m.UseNET); content.AddRow(new Label { Text = model.IsLibrary ? "Type:" : "Shared Code:", TextAlignment = TextAlignment.Right }, sharedCodeList); } if (model.SupportsPanelType) { var panelTypeList = new RadioButtonList { Orientation = Orientation.Horizontal, Spacing = radioSpacing, }; panelTypeList.Items.Add(new ListItem { Text = "Code", Key = "code" }); panelTypeList.SelectedKeyBinding.BindDataContext((ProjectWizardPageModel m) => m.Mode); if (model.SupportsXeto) { panelTypeList.Items.Add(new ListItem { Text = "Xaml", Key = "xaml" }); } if (model.SupportsJeto) { panelTypeList.Items.Add(new ListItem { Text = "Json", Key = "json" }); } if (model.SupportsCodePreview) { panelTypeList.Items.Add(new ListItem { Text = "Code Preview", Key = "preview" }); } content.AddRow(HeadingLabel("Form:"), panelTypeList); } if (model.SupportsBase) { var baseTypeList = new RadioButtonList { Orientation = Orientation.Horizontal, Spacing = radioSpacing, }; baseTypeList.Items.Add(new ListItem { Text = "Panel", Key = "Panel" }); baseTypeList.Items.Add(new ListItem { Text = "Dialog", Key = "Dialog" }); baseTypeList.Items.Add(new ListItem { Text = "Form", Key = "Form" }); baseTypeList.SelectedKeyBinding.BindDataContext((ProjectWizardPageModel m) => m.Base); content.AddRow(HeadingLabel("Base:"), baseTypeList); } #if DEBUG var showColorsButton = new Button { Text = "Show all themed colors" }; showColorsButton.Click += (sender, e) => new ThemedColorsDialog().ShowModal(this); content.AddRow(new Panel(), showColorsButton); #endif var informationLabel = new Label(); informationLabel.TextBinding.BindDataContext((ProjectWizardPageModel m) => m.Information); Information = informationLabel; Content = content; DataContext = model; }
private void ReloadChildControls() { if (_report == null) { _report = (Rdl.Engine.Report)Page.Session["RdlReport"]; } if (_report != null) { foreach (Rdl.Engine.ReportParameter r in _report.ReportParameters.Values) { r.LoadValidValues(_report); } } if (_report != null) { foreach (Rdl.Engine.ReportParameter parm in _report.ReportParameters.Values) { if (!parm.Hidden) { if (parm.ValidValues.Count > 0) { if (parm.MultiValue) { CheckBoxList checkBoxList = (CheckBoxList)FindControl(parm.Name); bool reload = false; if (checkBoxList.Items.Count != parm.ValidValues.Count) { reload = true; } else { for (int i = 0; i < parm.ValidValues.Count; i++) { if (parm.ValidValues[i].Label != checkBoxList.Items[i].Text) { reload = true; } } } if (reload) { checkBoxList.Items.Clear(); foreach (Rdl.Engine.ParameterValue value in parm.ValidValues) { checkBoxList.Items.Add(new ListItem(value.Label, value.Value)); } if (parm.DefaultValue != null) { foreach (string s in parm.DefaultValue) { foreach (ListItem li in checkBoxList.Items) { if (li.Value == s) { li.Selected = true; } } } } } } else { DropDownList ddl = (DropDownList)FindControl(parm.Name); bool reload = false; if (ddl.Items.Count != parm.ValidValues.Count) { reload = true; } else { for (int i = 0; i < parm.ValidValues.Count; i++) { if (parm.ValidValues[i].Label != ddl.Items[i].Text) { reload = true; } } } if (reload) { ddl.Items.Clear(); foreach (Rdl.Engine.ParameterValue value in parm.ValidValues) { ddl.Items.Add(new ListItem(value.Label, value.Value)); } if (parm.DefaultValue != null) { foreach (string s in parm.DefaultValue) { foreach (ListItem li in ddl.Items) { if (li.Value == s) { li.Selected = true; } } } } } } } } } } }
public static void SelectALL(this CheckBoxList cbl) { cbl.SelectAND(Convert.ToInt64(Math.Pow(2, cbl.Items.Count) - 1)); }
private void ShowInfo(int _id) { BLL.article bll = new BLL.article(); Model.article model = bll.GetModel(_id); ddlCategoryId.SelectedValue = model.category_id.ToString(); txtCallIndex.Text = model.call_index; txtTitle.Text = model.title; txtLinkUrl.Text = model.link_url; //不是相册图片就绑定 string filename = model.img_url.Substring(model.img_url.LastIndexOf("/") + 1); if (!filename.StartsWith("thumb_")) { txtImgUrl.Text = model.img_url; } txtSeoTitle.Text = model.seo_title; txtSeoKeywords.Text = model.seo_keywords; txtSeoDescription.Text = model.seo_description; txtZhaiyao.Text = model.zhaiyao; txtContent.Value = model.content; txtSortId.Text = model.sort_id.ToString(); txtClick.Text = model.click.ToString(); rblStatus.SelectedValue = model.status.ToString(); txtAddTime.Text = model.add_time.ToString("yyyy-MM-dd HH:mm:ss"); if (model.is_msg == 1) { cblItem.Items[0].Selected = true; } if (model.is_top == 1) { cblItem.Items[1].Selected = true; } if (model.is_red == 1) { cblItem.Items[2].Selected = true; } if (model.is_hot == 1) { cblItem.Items[3].Selected = true; } if (model.is_slide == 1) { cblItem.Items[4].Selected = true; } //扩展字段赋值 List <Model.article_attribute_field> ls1 = new BLL.article_attribute_field().GetModelList(this.channel_id, ""); foreach (Model.article_attribute_field modelt1 in ls1) { switch (modelt1.control_type) { case "single-text": //单行文本 TextBox txtControl = FindControl("field_control_" + modelt1.name) as TextBox; if (txtControl != null && model.fields.ContainsKey(modelt1.name)) { if (modelt1.is_password == 1) { txtControl.Attributes.Add("value", model.fields[modelt1.name]); } else { txtControl.Text = model.fields[modelt1.name]; } } break; case "multi-text": //多行文本 goto case "single-text"; case "editor": //编辑器 HtmlTextArea txtAreaControl = FindControl("field_control_" + modelt1.name) as HtmlTextArea; if (txtAreaControl != null && model.fields.ContainsKey(modelt1.name)) { txtAreaControl.Value = model.fields[modelt1.name]; } break; case "images": //图片上传 goto case "single-text"; case "number": //数字 goto case "single-text"; case "checkbox": //复选框 CheckBox cbControl = FindControl("field_control_" + modelt1.name) as CheckBox; if (cbControl != null && model.fields.ContainsKey(modelt1.name)) { if (model.fields[modelt1.name] == "1") { cbControl.Checked = true; } else { cbControl.Checked = false; } } break; case "multi-radio": //多项单选 RadioButtonList rblControl = FindControl("field_control_" + modelt1.name) as RadioButtonList; if (rblControl != null && model.fields.ContainsKey(modelt1.name)) { rblControl.SelectedValue = model.fields[modelt1.name]; } break; case "multi-checkbox": //多项多选 CheckBoxList cblControl = FindControl("field_control_" + modelt1.name) as CheckBoxList; if (cblControl != null && model.fields.ContainsKey(modelt1.name)) { string[] valArr = model.fields[modelt1.name].Split(','); for (int i = 0; i < cblControl.Items.Count; i++) { cblControl.Items[i].Selected = false; //先取消默认的选中 foreach (string str in valArr) { if (cblControl.Items[i].Value == str) { cblControl.Items[i].Selected = true; } } } } break; } } //绑定图片相册 if (filename.StartsWith("thumb_")) { hidFocusPhoto.Value = model.img_url; //封面图片 } rptAlbumList.DataSource = model.albums; rptAlbumList.DataBind(); //绑定内容附件 rptAttachList.DataSource = model.attach; rptAttachList.DataBind(); //赋值用户组价格 if (model.group_price != null) { for (int i = 0; i < this.rptPrice.Items.Count; i++) { int hideId = Convert.ToInt32(((HiddenField)this.rptPrice.Items[i].FindControl("hideGroupId")).Value); foreach (Model.user_group_price modelt in model.group_price) { if (hideId == modelt.group_id) { ((HiddenField)this.rptPrice.Items[i].FindControl("hidePriceId")).Value = modelt.id.ToString(); ((TextBox)this.rptPrice.Items[i].FindControl("txtGroupPrice")).Text = modelt.price.ToString(); } } } } }
/// <summary> /// button事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click(object sender, RoutedEventArgs e) { Controls.Button btn = sender as Controls.Button; if (btn != null) { if (btn.Tag != null) { int index = 0; char[] tmp; Hashtable ht = new Hashtable(); CheckBoxList cbl = null; switch ((string)btn.Tag) { case "Type1": cbl = cblNumber1; break; case "Type2": cbl = cblNumber2; break; case "Type3": cbl = cblNumber3; break; case "Type4": cbl = cblNumber4; break; case "Unit1": cbl = cblNumber1_2; break; case "Unit2": cbl = cblNumber2_2; break; case "Unit3": cbl = cblNumber3_2; break; case "Unit4": cbl = cblNumber4_2; break; case "Clear1": cblNumber1.Clear(); cblNumber1_2.Clear(); BaseHelper.GetChildren(dpType1, ht); break; case "Clear2": cblNumber2.Clear(); cblNumber2_2.Clear(); BaseHelper.GetChildren(dpType2, ht); break; case "Clear3": cblNumber3.Clear(); cblNumber3_2.Clear(); BaseHelper.GetChildren(dpType3, ht); break; case "Clear4": cblNumber4.Clear(); cblNumber4_2.Clear(); BaseHelper.GetChildren(dpType4, ht); break; case "Select1": cblNumber1.SelectedAll(); cblNumber1_2.SelectedValue = cblNumber1_2.SelectedValue[0] + "1111"; BaseHelper.GetChildren(dpType1, ht); break; case "Select2": cblNumber2.SelectedAll(); cblNumber2_2.SelectedValue = cblNumber2_2.SelectedValue[0] + "1111"; BaseHelper.GetChildren(dpType2, ht); break; case "Select3": cblNumber3.SelectedAll(); cblNumber3_2.SelectedValue = cblNumber3_2.SelectedValue[0] + "1111"; BaseHelper.GetChildren(dpType3, ht); break; case "Select4": cblNumber4.SelectedAll(); cblNumber4_2.SelectedValue = cblNumber4_2.SelectedValue[0] + "1111"; BaseHelper.GetChildren(dpType4, ht); break; case "Remark": Forms.MessageBox.Show("可以选择多个胆组。"); break; } if (cbl != null) { int.TryParse(btn.Content.ToString(), out index); tmp = cbl.SelectedValue.ToArray(); tmp[index] = (tmp[index] == '1' ? '0' : '1'); if (tmp[index] == '1') { btn.Background = System.Windows.Media.Brushes.LawnGreen; } else { btn.Background = System.Windows.Media.Brushes.Gainsboro; } cbl.SelectedValue = string.Join("", tmp); } foreach (var b in ht.Values) { if (b is Controls.Button) { Controls.Button bt = b as Controls.Button; if (((string)bt.Tag).Contains("Select") || ((string)bt.Tag).Contains("Clear")) { continue; } if (((string)btn.Tag).Contains("Select")) { if (bt.Content.ToString() == "0" && ((string)bt.Tag).Contains("Unit")) { continue; } bt.Background = System.Windows.Media.Brushes.LawnGreen; } else { bt.Background = System.Windows.Media.Brushes.Gainsboro; } } } } } }
protected string GetCondition() { string condition = ""; if (TextBox1.Text != "") { condition += "and IMMaterialBasicData.IMMBD_MaterialName like'%" + TextBox1.Text.ToString() + "%'"; } if (TextBox_SPTime2.Text != "") { if (TextBox_SPTime3.Text != "") { condition += "and PMPAM_ApplyTime >='" + Convert.ToDateTime(TextBox_SPTime2.Text.ToString()) + "'" + "and PMPAM_ApplyTime<='" + Convert.ToDateTime(TextBox_SPTime3.Text.ToString()) + "'"; } else { condition += "and PMPAM_ApplyTime >='" + Convert.ToDateTime(TextBox_SPTime2.Text.ToString()) + "'"; } } else if (TextBox_SPTime2.Text == "" && TextBox_SPTime3.Text != "") { ScriptManager.RegisterClientScriptBlock(Page, GetType(), "alert", "alert('请选择开始时间!')", true); } if (TextBox2.Text != "") { condition += "and IMMaterialBasicData.IMMBD_SpecificationModel='" + TextBox2.Text.ToString() + "'"; } int a = 0; foreach (Control ct in Panel_OASearch.Controls) { if (ct.GetType().ToString().Equals("System.Web.UI.WebControls.CheckBoxList")) { CheckBoxList cb = (CheckBoxList)ct; foreach (ListItem items in cb.Items) { if (items.Selected) { a++; if (a == 1) { label_Type.Text = "IMMaterialType.IMMT_MaterialType='" + items.Value + "'"; } if (a > 1) { label_Type.Text += " or IMMaterialType.IMMT_MaterialType='" + items.Value + "'"; } } } if (a > 0) { condition += "and (" + label_Type.Text + ")"; } //this.label_CB.Text = cb.Items.Cast<ListItem>().Where(listItem => listItem.Selected == true).Aggregate<ListItem, string>(null, (current, listItem) => current + (listItem.Value)) + "'"; //if (this.label_CB.Text != ",") //{ // this.label_Type.Text = "and IMMaterialType.IMMT_MaterialType='" + cb.Items.Cast<ListItem>().Where(listItem => listItem.Selected == true).Aggregate<ListItem, string>(null, (current, listItem) => current + (listItem.Value)) + "or IMMaterialType.IMMT_MaterialType='" + "'"; // condition += this.label_Type.Text; //} } } return(condition); }
public static object MappingControlObject(object obj, HtmlForm form, ContentPlaceHolder cph, bool SqlKeyWordsFilter) { try { if (obj == null) { return(obj); } List <PropertyInfo> pilist = obj.GetType().GetProperties().ToList(); Control baseControl = cph == null ? (Control)form : (Control)cph; foreach (PropertyInfo pi in pilist) { Control ctrl = baseControl.FindControl("txt" + pi.Name); ctrl = ctrl == null?baseControl.FindControl("lbl" + pi.Name) : ctrl; ctrl = ctrl == null?baseControl.FindControl("lit" + pi.Name) : ctrl; ctrl = ctrl == null?baseControl.FindControl("hid" + pi.Name) : ctrl; ctrl = ctrl == null?baseControl.FindControl("ddl" + pi.Name) : ctrl; ctrl = ctrl == null?baseControl.FindControl("rdo" + pi.Name) : ctrl; ctrl = ctrl == null?baseControl.FindControl("chk" + pi.Name) : ctrl; if (ctrl == null) { continue; } else if (ctrl is TextBox) { TextBox txt = ctrl as TextBox; if (Wf_StringHelper.IsNullOrEmptyByTrim(txt.Text)) { continue; } pi.SetValue(obj, ChangeType(txt.Text, pi.PropertyType, SqlKeyWordsFilter), null); } else if (ctrl is Label) { Label lbl = ctrl as Label; if (Wf_StringHelper.IsNullOrEmptyByTrim(lbl.Text)) { continue; } pi.SetValue(obj, ChangeType(lbl.Text, pi.PropertyType, SqlKeyWordsFilter), null); } else if (ctrl is Literal) { Literal lit = ctrl as Literal; if (Wf_StringHelper.IsNullOrEmptyByTrim(lit.Text)) { continue; } pi.SetValue(obj, ChangeType(lit.Text, pi.PropertyType, SqlKeyWordsFilter), null); } else if (ctrl is HiddenField) { HiddenField hid = ctrl as HiddenField; if (Wf_StringHelper.IsNullOrEmptyByTrim(hid.Value)) { continue; } pi.SetValue(obj, ChangeType(hid.Value, pi.PropertyType, SqlKeyWordsFilter), null); } else if (ctrl is DropDownList) { DropDownList ddl = ctrl as DropDownList; if (Wf_StringHelper.IsNullOrEmptyByTrim(ddl.SelectedValue)) { continue; } pi.SetValue(obj, ChangeType(ddl.SelectedValue, pi.PropertyType, SqlKeyWordsFilter), null); } else if (ctrl is RadioButtonList) { RadioButtonList rdo = ctrl as RadioButtonList; string value = ""; foreach (ListItem item in rdo.Items) { if (item.Selected) { value += Wf_StringHelper.IsNullOrEmptyByTrim(value) ? item.Value : "," + item.Value; } } if (Wf_StringHelper.IsNullOrEmptyByTrim(value)) { continue; } pi.SetValue(obj, ChangeType(value, pi.PropertyType, SqlKeyWordsFilter), null); } else if (ctrl is CheckBoxList) { CheckBoxList chk = ctrl as CheckBoxList; string value = ""; foreach (ListItem item in chk.Items) { if (item.Selected) { value += Wf_StringHelper.IsNullOrEmptyByTrim(value) ? item.Value : "," + item.Value; } } if (Wf_StringHelper.IsNullOrEmptyByTrim(value)) { continue; } pi.SetValue(obj, ChangeType(value, pi.PropertyType, SqlKeyWordsFilter), null); } continue; } return(obj); } catch (Exception) { return(null); } }
public void CreateAttributeControls() { var productVariant = this.ProductService.GetProductVariantById(this.ProductVariantId); if (productVariant != null) { this.phAttributes.Controls.Clear(); var productVariantAttributes = productVariant.ProductVariantAttributes; if (productVariantAttributes.Count > 0) { StringBuilder adjustmentTableScripts = new StringBuilder(); StringBuilder attributeScripts = new StringBuilder(); this.Visible = true; foreach (var attribute in productVariantAttributes) { var divAttribute = new Panel(); var attributeTitle = new Label(); if (attribute.IsRequired) { attributeTitle.Text = "<span>*</span> "; } //text prompt / title string textPrompt = string.Empty; if (!string.IsNullOrEmpty(attribute.TextPrompt)) { textPrompt = attribute.TextPrompt; } else { textPrompt = attribute.ProductAttribute.LocalizedName; } attributeTitle.Text += Server.HtmlEncode(textPrompt); attributeTitle.Style.Add("font-weight", "bold"); //description if (!string.IsNullOrEmpty(attribute.ProductAttribute.LocalizedDescription)) { attributeTitle.Text += string.Format("<br /><span>{0}</span>", Server.HtmlEncode(attribute.ProductAttribute.LocalizedDescription)); } bool addBreak = true; switch (attribute.AttributeControlType) { case AttributeControlTypeEnum.TextBox: { addBreak = false; } break; default: break; } if (addBreak) { attributeTitle.Text += "<br />"; } else { attributeTitle.Text += " "; } divAttribute.Controls.Add(attributeTitle); phAttributes.Controls.Add(divAttribute); string controlId = string.Format("{0}_{1}", attribute.ProductAttribute.ProductAttributeId, attribute.ProductVariantAttributeId); switch (attribute.AttributeControlType) { case AttributeControlTypeEnum.DropdownList: { var ddlAttributes = new DropDownList(); ddlAttributes.ID = controlId; divAttribute.Controls.Add(ddlAttributes); ddlAttributes.Items.Clear(); //dynamic price update if (this.SettingManager.GetSettingValueBoolean("ProductAttribute.EnableDynamicPriceUpdate")) { adjustmentTableScripts.AppendFormat("{0}['{1}'] = new Array(", AdjustmentTableName, ddlAttributes.ClientID); attributeScripts.AppendFormat("$('#{0}').change(function(){{{1}();}});\n", ddlAttributes.ClientID, AdjustmentFuncName); } int numberOfJsArrayItems = 0; if (!attribute.IsRequired) { ddlAttributes.Items.Add(new ListItem("---", "0")); //dynamic price update if (this.SettingManager.GetSettingValueBoolean("ProductAttribute.EnableDynamicPriceUpdate")) { adjustmentTableScripts.AppendFormat(CultureInfo.InvariantCulture, "{0},", decimal.Zero); numberOfJsArrayItems++; } } var pvaValues = attribute.ProductVariantAttributeValues; //values bool preSelectedSet = false; foreach (var pvaValue in pvaValues) { string pvaValueName = pvaValue.LocalizedName; //display price if allowed if (!this.HidePrices && (!this.SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") || (NopContext.Current.User != null && !NopContext.Current.User.IsGuest))) { decimal taxRate = decimal.Zero; decimal priceAdjustmentBase = this.TaxService.GetPrice(productVariant, pvaValue.PriceAdjustment, out taxRate); decimal priceAdjustment = this.CurrencyService.ConvertCurrency(priceAdjustmentBase, this.CurrencyService.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); if (priceAdjustmentBase > decimal.Zero) { pvaValueName += string.Format(" [+{0}]", PriceHelper.FormatPrice(priceAdjustment, false, false)); } else if (priceAdjustmentBase < decimal.Zero) { pvaValueName += string.Format(" [-{0}]", PriceHelper.FormatPrice(-priceAdjustment, false, false)); } //dynamic price update if (this.SettingManager.GetSettingValueBoolean("ProductAttribute.EnableDynamicPriceUpdate")) { adjustmentTableScripts.AppendFormat(CultureInfo.InvariantCulture, "{0},", (float)priceAdjustment); numberOfJsArrayItems++; } } var pvaValueItem = new ListItem(pvaValueName, pvaValue.ProductVariantAttributeValueId.ToString()); if (!preSelectedSet && pvaValue.IsPreSelected) { pvaValueItem.Selected = pvaValue.IsPreSelected; preSelectedSet = true; } ddlAttributes.Items.Add(pvaValueItem); } //dynamic price update if (this.SettingManager.GetSettingValueBoolean("ProductAttribute.EnableDynamicPriceUpdate")) { //If you create an array with a single numeric parameter, that number is used for specifying the number of elements in this array. //so have a little hack here (we need at least two elements) if (numberOfJsArrayItems == 1) { adjustmentTableScripts.AppendFormat(CultureInfo.InvariantCulture, "{0},", decimal.Zero); } } //dynamic price update if (this.SettingManager.GetSettingValueBoolean("ProductAttribute.EnableDynamicPriceUpdate")) { adjustmentTableScripts.Length -= 1; adjustmentTableScripts.Append(");\n"); } } break; case AttributeControlTypeEnum.RadioList: { var rblAttributes = new RadioButtonList(); rblAttributes.ID = controlId; divAttribute.Controls.Add(rblAttributes); rblAttributes.Items.Clear(); var pvaValues = attribute.ProductVariantAttributeValues; bool preSelectedSet = false; foreach (var pvaValue in pvaValues) { string pvaValueName = pvaValue.LocalizedName; //display price if allowed if (!this.HidePrices && (!this.SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") || (NopContext.Current.User != null && !NopContext.Current.User.IsGuest))) { decimal taxRate = decimal.Zero; decimal priceAdjustmentBase = this.TaxService.GetPrice(productVariant, pvaValue.PriceAdjustment, out taxRate); decimal priceAdjustment = this.CurrencyService.ConvertCurrency(priceAdjustmentBase, this.CurrencyService.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); if (priceAdjustmentBase > decimal.Zero) { pvaValueName += string.Format(" [+{0}]", PriceHelper.FormatPrice(priceAdjustment, false, false)); } else if (priceAdjustmentBase < decimal.Zero) { pvaValueName += string.Format(" [-{0}]", PriceHelper.FormatPrice(-priceAdjustment, false, false)); } //dynamic price update if (this.SettingManager.GetSettingValueBoolean("ProductAttribute.EnableDynamicPriceUpdate")) { adjustmentTableScripts.AppendFormat(CultureInfo.InvariantCulture, "{0}['{1}_{2}'] = {3};\n", AdjustmentTableName, rblAttributes.ClientID, rblAttributes.Items.Count, (float)priceAdjustment); attributeScripts.AppendFormat("$('#{0}_{1}').click(function(){{{2}();}});\n", rblAttributes.ClientID, rblAttributes.Items.Count, AdjustmentFuncName); } } var pvaValueItem = new ListItem(Server.HtmlEncode(pvaValueName), pvaValue.ProductVariantAttributeValueId.ToString()); if (!preSelectedSet && pvaValue.IsPreSelected) { pvaValueItem.Selected = pvaValue.IsPreSelected; preSelectedSet = true; } rblAttributes.Items.Add(pvaValueItem); } } break; case AttributeControlTypeEnum.Checkboxes: { var cblAttributes = new CheckBoxList(); cblAttributes.ID = controlId; divAttribute.Controls.Add(cblAttributes); cblAttributes.Items.Clear(); //values var pvaValues = attribute.ProductVariantAttributeValues; foreach (var pvaValue in pvaValues) { string pvaValueName = pvaValue.LocalizedName; //display price if allowed if (!this.HidePrices && (!this.SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") || (NopContext.Current.User != null && !NopContext.Current.User.IsGuest))) { decimal taxRate = decimal.Zero; decimal priceAdjustmentBase = this.TaxService.GetPrice(productVariant, pvaValue.PriceAdjustment, out taxRate); decimal priceAdjustment = this.CurrencyService.ConvertCurrency(priceAdjustmentBase, this.CurrencyService.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); if (priceAdjustmentBase > decimal.Zero) { pvaValueName += string.Format(" [+{0}]", PriceHelper.FormatPrice(priceAdjustment, false, false)); } else if (priceAdjustmentBase < decimal.Zero) { pvaValueName += string.Format(" [-{0}]", PriceHelper.FormatPrice(-priceAdjustment, false, false)); } //dynamic price update if (this.SettingManager.GetSettingValueBoolean("ProductAttribute.EnableDynamicPriceUpdate")) { adjustmentTableScripts.AppendFormat(CultureInfo.InvariantCulture, "{0}['{1}_{2}'] = {3};\n", AdjustmentTableName, cblAttributes.ClientID, cblAttributes.Items.Count, (float)priceAdjustment); attributeScripts.AppendFormat("$('#{0}_{1}').click(function(){{{2}();}});\n", cblAttributes.ClientID, cblAttributes.Items.Count, AdjustmentFuncName); } } var pvaValueItem = new ListItem(Server.HtmlEncode(pvaValueName), pvaValue.ProductVariantAttributeValueId.ToString()); pvaValueItem.Selected = pvaValue.IsPreSelected; cblAttributes.Items.Add(pvaValueItem); } } break; case AttributeControlTypeEnum.TextBox: { var txtAttribute = new TextBox(); txtAttribute.Width = this.SettingManager.GetSettingValueInteger("ProductAttribute.Textbox.Width", 300); txtAttribute.ID = controlId; divAttribute.Controls.Add(txtAttribute); } break; case AttributeControlTypeEnum.MultilineTextbox: { var txtAttribute = new TextBox(); txtAttribute.ID = controlId; txtAttribute.TextMode = TextBoxMode.MultiLine; txtAttribute.Width = this.SettingManager.GetSettingValueInteger("ProductAttribute.MultiTextbox.Width", 300); txtAttribute.Height = this.SettingManager.GetSettingValueInteger("ProductAttribute.MultiTextbox.Height", 150); divAttribute.Controls.Add(txtAttribute); } break; case AttributeControlTypeEnum.Datepicker: { var datePicker = new NopDatePicker(); //changes these properties in order to change year range datePicker.FirstYear = DateTime.Now.Year; datePicker.LastYear = DateTime.Now.Year + 1; datePicker.ID = controlId; divAttribute.Controls.Add(datePicker); } break; default: break; } } //display price if allowed if (!this.HidePrices && (!this.SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") || (NopContext.Current.User != null && !NopContext.Current.User.IsGuest))) { //dynamic price update if (this.SettingManager.GetSettingValueBoolean("ProductAttribute.EnableDynamicPriceUpdate")) { lblAdjustmentTableScripts.Text = adjustmentTableScripts.ToString(); lblAttributeScripts.Text = attributeScripts.ToString(); phDynPrice.Visible = true; } else { phDynPrice.Visible = false; } } else { phDynPrice.Visible = false; } } else { this.Visible = false; } } else { this.Visible = false; } }
protected void grdQuiz_RowDataBound(object sender, GridViewRowEventArgs e) { try { if ((e.Row.RowState & DataControlRowState.Edit) > 0) { TextBox txtOption = (e.Row.FindControl("txtGridOptionAdd") as TextBox); LinkButton btnAdd = (e.Row.FindControl("btnGridAddOption") as LinkButton); LinkButton btnRemove = (e.Row.FindControl("btnGridRemoveOpt") as LinkButton); RadioButtonList gridRdbList = (e.Row.FindControl("gridRdbList") as RadioButtonList); CheckBoxList gridCheckList = (e.Row.FindControl("grdCheckList") as CheckBoxList); Label questionId = (e.Row.FindControl("lblQuestionId") as Label); CheckBox gridIsAns = (e.Row.FindControl("chkgridIsAnswer") as CheckBox); Label q = (e.Row.FindControl("lblQuestionType") as Label); if (questionId != null) { int i = Convert.ToInt32(questionId.Text); professor_Quiz_WCFLib.optionModel[] optModel = OptionData(i); foreach (professor_Quiz_WCFLib.optionModel item in optModel) { ListItem LI = new ListItem(); LI.Text = item.option_value; LI.Value = item.PK_Option_id.ToString(); if (item.isAnswer == 1) { LI.Selected = true; } if (q.Text == "Optional") { txtOption.Visible = true; btnAdd.Visible = true; btnRemove.Visible = true; gridRdbList.Visible = true; gridRdbList.Items.Add(LI); } else if (q.Text == "Multiple Choice" || q.Text == "Fill in the blanks") { txtOption.Visible = true; btnAdd.Visible = true; btnRemove.Visible = true; gridCheckList.Visible = true; gridCheckList.Items.Add(LI); if (q.Text == "Multiple Choice") { gridIsAns.Visible = true; } } } } } if (e.Row.RowType == DataControlRowType.DataRow) { RadioButtonList myRadioList = (e.Row.FindControl("lblOption") as RadioButtonList); CheckBoxList myCheckList = (e.Row.FindControl("lblCheckList") as CheckBoxList); Label questionId = (e.Row.FindControl("lblQuestionId") as Label); Label qM = (e.Row.FindControl("lblQuestionMark") as Label); t = t + float.Parse(qM.Text); Label quesType = (e.Row.FindControl("lblQuestionType") as Label); if (questionId != null) { int i = Convert.ToInt32(questionId.Text); professor_Quiz_WCFLib.optionModel[] optModel = OptionData(i); foreach (professor_Quiz_WCFLib.optionModel item in optModel) { ListItem LI = new ListItem(); LI.Text = item.option_value; LI.Value = item.PK_Option_id.ToString(); if (item.isAnswer == 1) { LI.Selected = true; } if (quesType.Text == "Optional") { myRadioList.Items.Add(LI); myRadioList.Visible = true; } else if (quesType.Text == "Multiple Choice") { myCheckList.Visible = true; myCheckList.Items.Add(LI); } } } } if (e.Row.RowType == DataControlRowType.Footer) { Label lblTotalMarks = (Label)e.Row.FindControl("lblGridWeightage"); lblTotalMarks.Text = t.ToString(); } } catch (Exception ex) { } }
private TableRow CreateRowForCustomField(TypeField typeField, string group, List <CrmCustomField> valueFields, CustomFieldDto Field) { var tr = new TableRow() { ID = "TableRow" + group + Field.Id }; var tcName = new TableCell() { ID = "TableCellName" + group + Field.Id }; var labelName = new Label() { ID = "LabelFieldName" + group + Field.Id, Text = Field.Name // + "_" + Field.TypeId }; tcName.Controls.Add(labelName); tr.Cells.Add(tcName); var tcValue = new TableCell() { ID = "TableCellValue" + group + Field.Id }; var hfIdField = new HiddenField() { ID = "HiddenFieldIdField" + group + Field.Id, Value = Field.Id.ToString() }; tcValue.Controls.Add(hfIdField); var hfGroup = new HiddenField() { ID = "HiddenFieldGroupField" + group + Field.Id, Value = group }; tcValue.Controls.Add(hfGroup); var hfTypeField = new HiddenField() { ID = "HiddenFieldTypeField" + group + Field.Id, Value = Field.TypeId.ToString() }; tcValue.Controls.Add(hfTypeField); switch (Field.TypeId) { case 5: { var selectValue = new CheckBoxList() { ID = "CheckBoxListFieldValue" + group + Field.Id }; var enums = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, string> >(Field.Enums.ToString()); foreach (var option in enums) { selectValue.Items.Add(new ListItem() { Value = option.Key.ToString(), Text = option.Value }); } ; var selectedValue = valueFields.FirstOrDefault(r => r.Id == Field.Id); if (selectedValue != null) { foreach (var _val in selectedValue.Values) { var option = selectValue.Items.FindByValue(_val.Enum); if (option != null) { option.Selected = true; } } } ; tcValue.Controls.Add(selectValue); } break; case 4: { var selectValue = new DropDownList() { ID = "DropDownListFieldValue" + group + Field.Id, CssClass = "form-control" }; var enums = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, string> >(Field.Enums.ToString()); selectValue.Items.Add(new ListItem() { Value = "", Text = "-----" }); foreach (var option in enums) { selectValue.Items.Add(new ListItem() { Value = option.Key.ToString(), Text = option.Value }); } ; var selectedValue = valueFields.FirstOrDefault(r => r.Id == Field.Id); if (selectedValue != null && selectValue.Items.FindByValue(selectedValue.Values.FirstOrDefault().Enum) != null) { selectValue.SelectedValue = selectedValue.Values.FirstOrDefault().Enum; } ; tcValue.Controls.Add(selectValue); } break; case 2: { var selectedValue = valueFields.FirstOrDefault(r => r.Id == Field.Id); var val = selectedValue != null && selectedValue.Values != null && selectedValue.Values.FirstOrDefault() != null?selectedValue.Values.FirstOrDefault().Value : ""; var numValue = new TextBox() { ID = "TextBoxFieldValue" + group + Field.Id, Text = val, TextMode = TextBoxMode.Number, CssClass = "form-control" }; tcValue.Controls.Add(numValue); } break; case 1: { var selectedValue = valueFields.FirstOrDefault(r => r.Id == Field.Id); var val = selectedValue != null && selectedValue.Values != null && selectedValue.Values.FirstOrDefault() != null?selectedValue.Values.FirstOrDefault().Value : ""; var numValue = new TextBox() { ID = "TextBoxFieldValue" + group + Field.Id, Text = val, TextMode = TextBoxMode.SingleLine, CssClass = "form-control" }; tcValue.Controls.Add(numValue); } break; case 3: { var selectedValue = valueFields.FirstOrDefault(r => r.Id == Field.Id); var val = selectedValue != null && selectedValue.Values != null && selectedValue.Values.FirstOrDefault() != null?selectedValue.Values.FirstOrDefault().Value : ""; var numValue = new CheckBox() { ID = "CheckBoxFieldValue" + group + Field.Id, Checked = val == "True" }; tcValue.Controls.Add(numValue); } break; case 8: { if (Session.Contents["MultiFields" + group + Field.Id.ToString()] == null) { Session.Contents["MultiFields" + group + Field.Id.ToString()] = new Dictionary <String, Panel>(); } var sessionFields = (Session.Contents["MultiFields" + group + Field.Id.ToString()] as Dictionary <String, Panel>); var it = 0; var selectedValue = valueFields.FirstOrDefault(r => r.Id == Field.Id); var vals = selectedValue != null && selectedValue.Values != null ? selectedValue.Values : new List <CrmCustomFieldValue>(); foreach (var val in vals) { var lc = new Panel() { ID = "Panel" + group + Field.Id + it, CssClass = "input-group" }; var ddl = new DropDownList() { ID = "DropDownListValue" + group + Field.Id + it, Width = 100, CssClass = "input-group-prepend" }; var enums = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, string> >(Field.Enums.ToString()); foreach (var option in enums) { ddl.Items.Add(new ListItem() { Value = option.Key.ToString(), Text = option.Value }); } ; ddl.SelectedValue = val.Enum; lc.Controls.Add(ddl); var numValue = new TextBox() { ID = "TextBoxFieldValue" + group + Field.Id + it, Text = val.Value, CssClass = "form-control" }; lc.Controls.Add(numValue); var addValue = new Button() { ID = "ButtonFieldValue" + group + Field.Id + it, Text = "+", CssClass = "input-group-append input-group-text" }; addValue.Click += addValue_Click; addValue.CommandArgument = JsonConvert.SerializeObject(Field); lc.Controls.Add(addValue); if (sessionFields.ContainsKey(lc.ID) != null) { sessionFields.Remove(lc.ID); } tcValue.Controls.Add(lc); it++; } foreach (var panel in sessionFields) { tcValue.Controls.Add(panel.Value); it++; } if (it == 0) { var lc = new Panel() { ID = "Panel" + group + Field.Id + it, CssClass = "input-group" }; var ddl = new DropDownList() { ID = "DropDownListValue" + group + Field.Id + it, Width = 100, CssClass = "input-group-prepend" }; var enums = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, string> >(Field.Enums.ToString()); foreach (var option in enums) { ddl.Items.Add(new ListItem() { Value = option.Key.ToString(), Text = option.Value }); } ; ddl.SelectedIndex = 0; lc.Controls.Add(ddl); var numValue = new TextBox() { ID = "TextBoxFieldValue" + group + Field.Id + it, Text = "", CssClass = "form-control" }; lc.Controls.Add(numValue); var addValue = new Button() { ID = "ButtonFieldValue" + group + Field.Id + it, Text = "+", CssClass = "input-group-append input-group-text" }; addValue.Click += addValue_Click; lc.Controls.Add(addValue); tcValue.Controls.Add(lc); } Session.Contents["MultiFields" + group + Field.Id.ToString()] = sessionFields; } break; case 9: { var selectedValue = valueFields.FirstOrDefault(r => r.Id == Field.Id); var val = selectedValue != null && selectedValue.Values != null && selectedValue.Values.FirstOrDefault() != null?selectedValue.Values.FirstOrDefault().Value : ""; var numValue = new TextBox() { ID = "TextBoxFieldValue" + group + Field.Id, Text = val, TextMode = TextBoxMode.MultiLine, CssClass = "form-control" }; tcValue.Controls.Add(numValue); } break; } tr.Cells.Add(tcValue); return(tr); }
private void CreateCheckboxListControl(NameAttribute displayNameAttribute, CheckBoxList sourceList, Binding b) { var checkBoxListControl = new ConfigCheckBoxListControl(_localController.GetLocalStrings<SDGuiStrings>()); checkBoxListControl.ConfigItemDisplayName = _localController.GetLocalString(displayNameAttribute.LocalType, displayNameAttribute.DisplayName); checkBoxListControl.SourceList = sourceList; checkBoxListControl.SetBinding(ConfigCheckBoxListControl.SelectedItemsProperty, b); configItemPanel.Children.Add(checkBoxListControl); }
//==================执行与数据库的关联操作===================== protected void getCom(int i) { string dd1 = Application["d1"].ToString(); string dd2 = Application["d2"].ToString(); SqlConnection con = dataconn.getcon(); switch (i) { //从数据库中选择单选题 case 1: SqlDataAdapter myadapter1 = new SqlDataAdapter("select * " + "from tb_Questions where que_type='单选题'and que_lessonid='" + dd1 + "'and que_taotiid='" + dd2 + "'order by id desc", con); DataSet myds1 = new DataSet(); myadapter1.Fill(myds1); DataList1.DataSource = myds1; DataList1.DataBind(); //生成单选题题号 for (int tID1 = 1; tID1 <= DataList1.Items.Count; tID1++) { Label lblSelect = (Label)DataList1.Items[tID1 - 1].FindControl("Label2"); lblSelect.Text = tID1.ToString() + "、"; } break; //从数据库中选择多选题 case 2: SqlDataAdapter myadapter2 = new SqlDataAdapter("select * " + "from tb_Questions where que_type='多选题'and que_lessonid='" + dd1 + "'and que_taotiid='" + dd2 + "'order by id desc", con); DataSet myds2 = new DataSet(); myadapter2.Fill(myds2); DataList2.DataSource = myds2; DataList2.DataBind(); //生成多选题题号 for (int tID2 = 1; tID2 <= DataList2.Items.Count; tID2++) { Label lblDSelect = (Label)DataList2.Items[tID2 - 1].FindControl("Label24"); lblDSelect.Text = tID2.ToString() + "、"; } break; //核对单选题答案 case 3: SqlDataAdapter myadapter3 = new SqlDataAdapter("select id,que_answer" + " from tb_Questions where que_type='单选题'and que_lessonid=" + dd1 + " and que_taotiid=" + dd2 + " order by id desc", con); DataSet myds3 = new DataSet(); myadapter3.Fill(myds3); DataRow[] row1 = myds3.Tables[0].Select(); //计算单选题成 foreach (DataRow answer1 in row1) { int_row1 += 1; if (int_row1 <= 3) { RadioButtonList rbl = (RadioButtonList)(DataList1.Items[int_row1 - 1].FindControl("RadioButtonList1")); if (rbl.SelectedValue == "") { this.lblSel.Text = "0"; } else { if (answer1["que_answer"].ToString().Trim() == rbl.SelectedValue.ToString().Trim()) { int_row1Point += 40 / DataList1.Items.Count; this.lblSel.Text = int_row1Point.ToString(); } } } } break; //核对多选题答案 case 4: SqlDataAdapter myadapter4 = new SqlDataAdapter("select id,que_answer" + " from tb_Questions where que_type='多选题'and que_lessonid=" + dd1 + " and que_taotiid=" + dd2 + " order by id desc", con); DataSet myds4 = new DataSet(); myadapter4.Fill(myds4); DataRow[] row2 = myds4.Tables[0].Select(); //计算多选题成绩 foreach (DataRow answer2 in row2) { int_row2 += 1; if (int_row2 <= 3) { CheckBoxList cbl = (CheckBoxList)(DataList2.Items[int_row2 - 1].FindControl("CheckBoxList1")); if (cbl.SelectedValue == "") { lblDSel.Text = "0"; } else { this.TextBox1.Text = ""; for (int q = 0; q < cbl.Items.Count; q++) { if (cbl.Items[q].Selected == true) { this.TextBox1.Text = TextBox1.Text.Trim() + cbl.Items[q].Value + ", "; } } if (answer2["que_answer"].ToString().Trim() + "," == this.TextBox1.Text.Trim()) { int_row2Point += 60 / DataList2.Items.Count; this.lblDSel.Text = int_row2Point.ToString(); } } } } break; } }
private String ObtenerValuesSeleccionados(CheckBoxList checkSecciones) { String resultado = ""; foreach(ListItem item in checkSecciones.Items) { if (item.Selected == true) { if (String.IsNullOrEmpty(resultado) == true) { resultado = item.Value; } else { resultado += "*" + item.Value; } } } return resultado; }
private void BindPanel(Panel panel) { foreach (Control ctr in panel.Controls) { if (ctr is TextBox) { TextBox txt = (TextBox)ctr; if (dts.Columns.Contains(txt.ID.Substring(3))) { txt.Text = dts.Rows[0][txt.ID.Substring(3)].ToString(); } } if (ctr is Label) { Label lb = (Label)ctr; if (dts.Columns.Contains(lb.ID.Substring(2))) { lb.Text = dts.Rows[0][lb.ID.Substring(2)].ToString(); } } if (ctr is RadioButtonList) { RadioButtonList rbl = (RadioButtonList)ctr; if (dts.Columns.Contains(rbl.ID.Substring(3))) { rbl.SelectedValue = dts.Rows[0][rbl.ID.Substring(3)].ToString(); } } if (ctr is CheckBoxList) { CheckBoxList cbxl = (CheckBoxList)ctr; if (dts.Columns.Contains(cbxl.ID.Substring(4))) { if (dts.Rows[0][cbxl.ID.Substring(4)].ToString().Contains('|')) { string[] str = dts.Rows[0][cbxl.ID.Substring(4)].ToString().Split('|'); for (int j = 0, a = str.Length; j < a; j++) { for (int k = 0, b = cbxl.Items.Count; k < b; k++) { if (cbxl.Items[k].Text == str[j]) { cbxl.Items[k].Selected = true; break; } } } } else { for (int k = 0, b = cbxl.Items.Count; k < b; k++) { if (cbxl.Items[k].Text == dts.Rows[0][cbxl.ID.Substring(4)].ToString()) { cbxl.Items[k].Selected = true; break; } } } } } } }
protected void NixIt(object sender, EventArgs e) { int songCount = SongCheckList.Items.Count; CheckBoxList tempList = new CheckBoxList(); for (int i = 0; i < songCount; i++) { if (!SongCheckList.Items[i].Selected) tempList.Items.Add(SongCheckList.Items[i]); } SongCheckList.Items.Clear(); for (int j = 0; j < tempList.Items.Count; j++) { SongCheckList.Items.Add(tempList.Items[j]); } if (SongCheckList.Items.Count == 0) DeleteSongButton.Visible = false; }
public DBTerm GetFilters(string TableName, string EmpPosIDFieldName) { if (!string.IsNullOrEmpty(TableName)) { if (!TableName.Trim().Equals(string.Empty)) { TableName = TableName.Trim() + "."; } } OR companyTerm = null; string selectedCompanyValueList = string.Empty; //OR companyOrTerm = null; foreach (RepeaterItem companyRepeaterItem in CompanyRepeater.Items) { string selectedHierarchyElementValueList = string.Empty; string selectedNotSelectedHierarchyLevelList = string.Empty; CheckBox companyChcekBox = (CheckBox)companyRepeaterItem.FindControl("ItemSelect"); HtmlInputHidden hiddenInput = (HtmlInputHidden)companyRepeaterItem.FindControl("CompanyID"); Repeater hLevelRepeater = (Repeater)companyRepeaterItem.FindControl("HierarchyLevel"); foreach (RepeaterItem hLevelRepeaterItem in hLevelRepeater.Items) { OR orTerm = null; CheckBoxList hElementList = (CheckBoxList)hLevelRepeaterItem.FindControl("HierarchyElementList"); foreach (ListItem item in hElementList.Items) { if (item.Selected) { if (!string.IsNullOrEmpty(item.Value)) { //if (orTerm == null) // orTerm = new OR(); //orTerm.add(new Match("eh.HElementID", item.Value)); if (!string.IsNullOrEmpty(selectedHierarchyElementValueList)) { selectedHierarchyElementValueList += ","; } selectedHierarchyElementValueList += item.Value; } else if (hElementList is CheckBoxList) { //if (orTerm == null) // orTerm = new OR(); //DBFilter dbFilter = new DBFilter(); //dbFilter.add(new MatchField("eh.HElementID", "he.HElementID")); //AND andHElement = new AND(); //andHElement.add(new Match("eh.HLevelID", hElementList.Attributes["HLevelID"])); //orTerm.add(new Exists("HierarchyElement he", dbFilter, true)); if (!string.IsNullOrEmpty(selectedNotSelectedHierarchyLevelList)) { selectedNotSelectedHierarchyLevelList += ","; } selectedNotSelectedHierarchyLevelList += hElementList.Attributes["HLevelID"]; } } } if (orTerm != null) { DBFilter sub = new DBFilter(); sub.add(new MatchField(TableName + EmpPosIDFieldName, "eh.EmpPosID")); sub.add(orTerm); if (companyTerm == null) { companyTerm = new OR(); } companyTerm.add(new Exists(EEmpHierarchy.db.dbclass.tableName + " eh", sub)); } } if (!string.IsNullOrEmpty(selectedHierarchyElementValueList) || !string.IsNullOrEmpty(selectedNotSelectedHierarchyLevelList)) { if (companyTerm == null) { companyTerm = new OR(); } OR orHierarchyElementTerm = new OR(); if (!string.IsNullOrEmpty(selectedHierarchyElementValueList)) { orHierarchyElementTerm.add(new IN("eh.HElementID", selectedHierarchyElementValueList, null)); } if (!string.IsNullOrEmpty(selectedNotSelectedHierarchyLevelList)) { DBFilter dbFilter = new DBFilter(); dbFilter.add(new MatchField("eh.HElementID", "he.HElementID")); AND andHElement = new AND(); andHElement.add(new Exists("HierarchyElement he", dbFilter, true)); andHElement.add(new IN("eh.HLevelID", selectedNotSelectedHierarchyLevelList, null)); orHierarchyElementTerm.add(andHElement); } DBFilter sub = new DBFilter(); sub.add(new MatchField(TableName + EmpPosIDFieldName, "eh.EmpPosID")); sub.add(new IN(TableName + "CompanyID", hiddenInput.Value, null)); sub.add(orHierarchyElementTerm); companyTerm.add(new Exists(EEmpHierarchy.db.dbclass.tableName + " eh", sub)); } else if (companyChcekBox.Checked) { //if (companyOrTerm == null) //{ // companyOrTerm = new OR(); // if (companyTerm == null) // companyTerm = new AND(); // companyTerm.add(companyOrTerm); //} if (!string.IsNullOrEmpty(selectedCompanyValueList)) { selectedCompanyValueList += ","; } selectedCompanyValueList += hiddenInput.Value; //companyOrTerm.add(new Match(TableName + "CompanyID", hiddenInput.Value)); } } if (!string.IsNullOrEmpty(selectedCompanyValueList)) { if (companyTerm == null) { companyTerm = new OR(); } companyTerm.add(new IN(TableName + "CompanyID", selectedCompanyValueList, null)); } return(companyTerm); }
public void RepeatDirection_Invalid() { CheckBoxList c = new CheckBoxList(); c.RepeatDirection = (RepeatDirection)Int32.MaxValue; }
private void CreateOtherField(int _channel_id) { List <Model.article_attribute_field> ls = new BLL.article_attribute_field().GetModelList(this.channel_id, "is_sys=0"); if (ls.Count > 0) { field_tab_item.Visible = true; field_tab_content.Visible = true; } foreach (Model.article_attribute_field modelt in ls) { //创建一个dl标签 HtmlGenericControl htmlDL = new HtmlGenericControl("dl"); HtmlGenericControl htmlDT = new HtmlGenericControl("dt"); HtmlGenericControl htmlDD = new HtmlGenericControl("dd"); htmlDT.InnerHtml = modelt.title; switch (modelt.control_type) { case "single-text": //单行文本 //创建一个TextBox控件 TextBox txtControl = new TextBox(); txtControl.ID = "field_control_" + modelt.name; //CSS样式及TextMode设置 if (modelt.control_type == "single-text") //单行 { txtControl.CssClass = "input normal"; //是否密码框 if (modelt.is_password == 1) { txtControl.TextMode = TextBoxMode.Password; } } else if (modelt.control_type == "multi-text") //多行 { txtControl.CssClass = "input"; txtControl.TextMode = TextBoxMode.MultiLine; } else if (modelt.control_type == "number") //数字 { txtControl.CssClass = "input small"; } else if (modelt.control_type == "images") //图片 { txtControl.CssClass = "input normal upload-path"; } //设置默认值 txtControl.Text = modelt.default_value; //验证提示信息 if (!string.IsNullOrEmpty(modelt.valid_tip_msg)) { txtControl.Attributes.Add("tipmsg", modelt.valid_tip_msg); } //验证失败提示信息 if (!string.IsNullOrEmpty(modelt.valid_error_msg)) { txtControl.Attributes.Add("errormsg", modelt.valid_error_msg); } //验证表达式 if (!string.IsNullOrEmpty(modelt.valid_pattern)) { txtControl.Attributes.Add("datatype", modelt.valid_pattern); txtControl.Attributes.Add("sucmsg", " "); } //创建一个Label控件 Label labelControl = new Label(); labelControl.CssClass = "Validform_checktip"; labelControl.Text = modelt.valid_tip_msg; //将控件添加至DD中 htmlDD.Controls.Add(txtControl); //如果是图片则添加上传按钮 if (modelt.control_type == "images") { HtmlGenericControl htmlBtn = new HtmlGenericControl("div"); htmlBtn.Attributes.Add("class", "upload-box upload-img"); htmlBtn.Attributes.Add("style", "margin-left:4px;"); htmlDD.Controls.Add(htmlBtn); } htmlDD.Controls.Add(labelControl); break; case "multi-text": //多行文本 goto case "single-text"; case "editor": //编辑器 HtmlTextArea txtTextArea = new HtmlTextArea(); txtTextArea.ID = "field_control_" + modelt.name; txtTextArea.Attributes.Add("style", "visibility:hidden;"); //是否简洁型编辑器 if (modelt.editor_type == 1) { txtTextArea.Attributes.Add("class", "editor-mini"); } else { txtTextArea.Attributes.Add("class", "editor"); } txtTextArea.Value = modelt.default_value; //默认值 //验证提示信息 if (!string.IsNullOrEmpty(modelt.valid_tip_msg)) { txtTextArea.Attributes.Add("tipmsg", modelt.valid_tip_msg); } //验证失败提示信息 if (!string.IsNullOrEmpty(modelt.valid_error_msg)) { txtTextArea.Attributes.Add("errormsg", modelt.valid_error_msg); } //验证表达式 if (!string.IsNullOrEmpty(modelt.valid_pattern)) { txtTextArea.Attributes.Add("datatype", modelt.valid_pattern); txtTextArea.Attributes.Add("sucmsg", " "); } //创建一个Label控件 Label labelControl2 = new Label(); labelControl2.CssClass = "Validform_checktip"; labelControl2.Text = modelt.valid_tip_msg; //将控件添加至DD中 htmlDD.Controls.Add(txtTextArea); htmlDD.Controls.Add(labelControl2); break; case "images": //图片上传 goto case "single-text"; case "number": //数字 goto case "single-text"; case "checkbox": //复选框 CheckBox cbControl = new CheckBox(); cbControl.ID = "field_control_" + modelt.name; //默认值 if (modelt.default_value == "1") { cbControl.Checked = true; } HtmlGenericControl htmlDiv1 = new HtmlGenericControl("div"); htmlDiv1.Attributes.Add("class", "rule-single-checkbox"); htmlDiv1.Controls.Add(cbControl); //将控件添加至DD中 htmlDD.Controls.Add(htmlDiv1); if (!string.IsNullOrEmpty(modelt.valid_tip_msg)) { //创建一个Label控件 Label labelControl3 = new Label(); labelControl3.CssClass = "Validform_checktip"; labelControl3.Text = modelt.valid_tip_msg; htmlDD.Controls.Add(labelControl3); } break; case "multi-radio": //多项单选 RadioButtonList rblControl = new RadioButtonList(); rblControl.ID = "field_control_" + modelt.name; rblControl.RepeatDirection = RepeatDirection.Horizontal; rblControl.RepeatLayout = RepeatLayout.Flow; HtmlGenericControl htmlDiv2 = new HtmlGenericControl("div"); htmlDiv2.Attributes.Add("class", "rule-multi-radio"); htmlDiv2.Controls.Add(rblControl); //赋值选项 string[] valArr = modelt.item_option.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None); for (int i = 0; i < valArr.Length; i++) { string[] valItemArr = valArr[i].Split('|'); if (valItemArr.Length == 2) { rblControl.Items.Add(new ListItem(valItemArr[0], valItemArr[1])); } } rblControl.SelectedValue = modelt.default_value; //默认值 //创建一个Label控件 Label labelControl4 = new Label(); labelControl4.CssClass = "Validform_checktip"; labelControl4.Text = modelt.valid_tip_msg; //将控件添加至DD中 htmlDD.Controls.Add(htmlDiv2); htmlDD.Controls.Add(labelControl4); break; case "multi-checkbox": //多项多选 CheckBoxList cblControl = new CheckBoxList(); cblControl.ID = "field_control_" + modelt.name; cblControl.RepeatDirection = RepeatDirection.Horizontal; cblControl.RepeatLayout = RepeatLayout.Flow; HtmlGenericControl htmlDiv3 = new HtmlGenericControl("div"); htmlDiv3.Attributes.Add("class", "rule-multi-checkbox"); htmlDiv3.Controls.Add(cblControl); //赋值选项 string[] valArr2 = modelt.item_option.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None); for (int i = 0; i < valArr2.Length; i++) { string[] valItemArr2 = valArr2[i].Split('|'); if (valItemArr2.Length == 2) { cblControl.Items.Add(new ListItem(valItemArr2[0], valItemArr2[1])); } } cblControl.SelectedValue = modelt.default_value; //默认值 //创建一个Label控件 Label labelControl5 = new Label(); labelControl5.CssClass = "Validform_checktip"; labelControl5.Text = modelt.valid_tip_msg; //将控件添加至DD中 htmlDD.Controls.Add(htmlDiv3); htmlDD.Controls.Add(labelControl5); break; } //将DT和DD添加到DL中 htmlDL.Controls.Add(htmlDT); htmlDL.Controls.Add(htmlDD); //将DL添加至field_tab_content中 field_tab_content.Controls.Add(htmlDL); } }
public void RepeatLayout_Invalid() { CheckBoxList c = new CheckBoxList(); c.RepeatLayout = (RepeatLayout)Int32.MaxValue; }
public void TextAlign_Invalid() { CheckBoxList c = new CheckBoxList(); c.TextAlign = (TextAlign)Int32.MaxValue; }
protected void cbl_OnSelectedIndexChanged(object sender, EventArgs e) { int count = 0; string newValue = ""; CheckBoxList cbl = new CheckBoxList(); cbl = (CheckBoxList)sender; // Loop through checkBoxList to grab selected items values foreach (ListItem aListItem in cbl.Items) { if (aListItem.Selected) { if (count <= 0) newValue += aListItem.Value; else newValue += "," + aListItem.Value; count++; } } ViewState[cbl.ID] = newValue; // Grab all reporting information from the database getReportInfo(parameter, packaging, sortExpression, sortOrder); }
protected void Salvar_Click(object sender, EventArgs e) { if (Page.IsValid) { CheckBoxList chkTipoPessoa = (CheckBoxList)dvManutencao.FindControl("chkTipoPessoa"); DropDownList ddlEspeciePessoa = (DropDownList)dvManutencao.FindControl("ddlEspeciePessoa"); bool tipoPessoaColaborador = false; bool tipoPessoaCliente = false; bool tipoPessoaParte = false; bool tipoPessoaAdvogado = false; bool tipoPessoaTerceiro = false; if (chkTipoPessoa != null) { foreach (ListItem item in chkTipoPessoa.Items) { if (item.Selected) { switch (item.Value) { case "tipoPessoaColaborador": tipoPessoaColaborador = true; break; case "tipoPessoaCliente": tipoPessoaCliente = true; break; case "tipoPessoaParte": tipoPessoaParte = true; break; case "tipoPessoaAdvogado": tipoPessoaAdvogado = true; break; case "tipoPessoaTerceiro": tipoPessoaTerceiro = true; break; } } } } try { if (dvManutencao.CurrentMode == DetailsViewMode.Edit) { dvManutencao.UpdateItem(false); dvContato.UpdateItem(false); if (tipoPessoaColaborador) { dvColaborador.UpdateItem(false); } if (tipoPessoaAdvogado) { dvAdvogado.UpdateItem(false); } dvReferencias.UpdateItem(false); switch (ddlEspeciePessoa.SelectedValue) { case "F": dvDadosProfissionais.UpdateItem(false); dvPessoaFisica.UpdateItem(false); break; case "J": dvPessoaJuridica.UpdateItem(false); break; } } else { dvManutencao.InsertItem(true); dvContato.InsertItem(true); if (tipoPessoaColaborador) { dvColaborador.InsertItem(true); } if (tipoPessoaAdvogado) { dvAdvogado.InsertItem(true); } dvReferencias.InsertItem(true); switch (ddlEspeciePessoa.SelectedValue) { case "F": dvDadosProfissionais.InsertItem(true); dvPessoaFisica.InsertItem(true); break; case "J": dvPessoaJuridica.InsertItem(true); break; } } } catch (Exception Ex) { } } }