public void TestGetKeyValueList() { var dic1 = new SortedList(); for (int i = 0; i < 100; i++) dic1.Add("Key_" + i, "Value_" + i); var ilst1 = dic1.GetKeyList(); var hsh1 = new Hashtable(); DoIListTests(dic1, ilst1, hsh1, DicType.Key); Assert.False(hsh1.Count != 2 || !hsh1.ContainsKey("IsReadOnly") || !hsh1.ContainsKey("IsFixedSize"), "Error, KeyList"); dic1 = new SortedList(); for (int i = 0; i < 100; i++) dic1.Add("Key_" + i, "Value_" + i); ilst1 = dic1.GetValueList(); hsh1 = new Hashtable(); DoIListTests(dic1, ilst1, hsh1, DicType.Value); Assert.False(hsh1.Count != 2 || !hsh1.ContainsKey("IsReadOnly") || !hsh1.ContainsKey("IsFixedSize"), "Error, ValueList"); }
public static ListItemCollection BuildListFromEnum(Enum objEnum) { ListItemCollection colListItems = new ListItemCollection(); ListItem liItem; SortedList colSortedListItems = new SortedList(); foreach (int value in Enum.GetValues(objEnum.GetType())) { liItem = new ListItem(); liItem.Value = value.ToString(); liItem.Text = StringEnum.GetStringValue((Enum)Enum.Parse(objEnum.GetType(), value.ToString(), true)); if (liItem.Text != string.Empty) { colSortedListItems.Add(liItem.Text, liItem); } liItem = null; } foreach (ListItem liListItem in colSortedListItems.GetValueList()) { colListItems.Add(liListItem); } return colListItems; }
public void mostrarLista() { try { if ((lib.OptenerEditorial(lib)).v_editorial.Count != 0) { SLeditorial = new SortedList(); foreach (String editorial in lib.v_editorial) { SLeditorial.Add(editorial, editorial); } com_editorial.DataSource = SLeditorial.GetValueList(); com_editorial.SelectedItem = lib.v_Deditorial; com_editorial.Show(); } if ((lib.OptenerTipoLibro(lib)).v_tipo_libro.Count != 0) { SLtipolibro = new SortedList(); foreach (String tipolibro in lib.v_tipo_libro) { SLtipolibro.Add(tipolibro, tipolibro); } com_tipo_libro.DataSource = SLtipolibro.GetValueList(); com_tipo_libro.SelectedItem = lib.v_Dtipo_libro; com_tipo_libro.Show(); } if ((lib.OptenerIdioma(lib)).v_idioma.Count != 0) { SLidioma = new SortedList(); foreach (String idioma in lib.v_idioma) { SLidioma.Add(idioma, idioma); } com_idioma.DataSource = SLidioma.GetValueList(); com_idioma.SelectedItem = lib.v_Didioma; com_idioma.Show(); } } catch (SqlException ex) { for (int i = 0; i < ex.Errors.Count; i++) { errorMessages.Append("Index #" + i + "\n" + "Message: " + ex.Errors[i].Message + "\n" + "LineNumber: " + ex.Errors[i].LineNumber + "\n" + "Source: " + ex.Errors[i].Source + "\n" + "Procedure: " + ex.Errors[i].Procedure + "\n"); } Console.WriteLine(errorMessages.ToString()); MessageBox.Show(ex.Errors[0].Message.ToString(), "Modificar Libro", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void but_consultar_editorial_Click(object sender, EventArgs e) { StringBuilder errorMessages = new StringBuilder(); Editorial edi = new Editorial(); if (tex_nombre_editorial.Text.Length == 0) { this.inicializarDatos(); MessageBox.Show("Debe ingresar un Nombre", "Consultar Editorial", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { try { edi.v_nombre_editorial = tex_nombre_editorial.Text; //edi.v_Dpais= com_pais.SelectedItem.ToString(); if ((edi.ConsultarEditorial(edi)).v_nombre_editorial.Length != 0) { tex_nombre_editorial.Text = edi.v_nombre_editorial; tex_direccion.Text = edi.v_direccion_editorial; SLpais = new SortedList(); SLpais.Add(edi.v_Dpais, edi.v_Dpais); com_pais.DataSource = SLpais.GetValueList(); com_pais.Show(); } } catch (SqlException ex) { for (int i = 0; i < ex.Errors.Count; i++) { errorMessages.Append("Index #" + i + "\n" + "Message: " + ex.Errors[i].Message + "\n" + "LineNumber: " + ex.Errors[i].LineNumber + "\n" + "Source: " + ex.Errors[i].Source + "\n" + "Procedure: " + ex.Errors[i].Procedure + "\n"); } Console.WriteLine(errorMessages.ToString()); this.inicializarDatos(); SLpais.Clear(); com_pais.DataSource = null; com_pais.Show(); MessageBox.Show(ex.Errors[0].Message.ToString(), "Consultar Editorial", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
static public int GetValueList(IntPtr l) { try { System.Collections.SortedList self = (System.Collections.SortedList)checkSelf(l); var ret = self.GetValueList(); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
public static string GetIdEntidades(string familia) { //retorno un string con una lista de todos los iddeentidades de una familia determinada string aux = string.Empty; if (!_loaded) { //DeclareTypes(pathFamilia, _nameFamilia); DeclareTypes(); } if (_nameFamilia.ContainsValue(familia)) { for (int i = 0; i < _nameFamilia.Count; i++) { if (Convert.ToString(_nameFamilia.GetValueList()[i]).Equals(familia)) { aux = aux + "," + Convert.ToString(_nameFamilia.GetKeyList()[i]); } } } if (familia.Equals(string.Empty)) { for (int i = 0; i < _nameFamilia.Count; i++) { aux = aux + "," + Convert.ToString(_nameFamilia.GetKeyList()[i]); } } if (aux != null && aux != string.Empty) { return(aux.Substring(1)); //saco la primer coma } else { return(string.Empty); } }
public static ListItemCollection BuildListFromEnumByName(Enum objEnum) { ListItemCollection colListItems = new ListItemCollection(); ListItem liItem; SortedList colSortedListItems = new SortedList(); foreach (string strName in Enum.GetNames(objEnum.GetType())) { liItem = new ListItem(); liItem.Value = strName; liItem.Text = strName; colSortedListItems.Add(liItem.Text, liItem); } foreach (ListItem liListItem in colSortedListItems.GetValueList()) { colListItems.Add(liListItem); } return colListItems; }
private void but_consultar_libro_Click(object sender, EventArgs e) { if (tex_isbn.Text.Length == 0) { this.inicializarDatos(); MessageBox.Show("Debe ingresar un ISBN", "Consultar Libro", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { try { Libro lib = new Libro(); lib.v_isbn = tex_isbn.Text; if ((lib.ConsultarLibro(lib)).v_isbn.Length != 0) { tex_isbn.Text = lib.v_isbn; tex_titulo.Text = lib.v_titulo; tex_edicion.Text = lib.v_edicion; tex_autor.Text = lib.v_autor; tex_año.Text = lib.v_año; SLeditorial = new SortedList(); SLeditorial.Add(lib.v_Deditorial, lib.v_Deditorial); com_editorial.DataSource = SLeditorial.GetValueList(); com_editorial.Show(); com_editorial.Enabled = false; SLeditorial.Clear(); SLtipolibro = new SortedList(); SLtipolibro.Add(lib.v_Dtipo_libro, lib.v_Dtipo_libro); com_tipo_libro.DataSource = SLtipolibro.GetValueList(); com_tipo_libro.Show(); com_tipo_libro.Enabled = false; SLtipolibro.Clear(); SLidioma = new SortedList(); SLidioma.Add(lib.v_Didioma, lib.v_Didioma); com_idioma.DataSource = SLidioma.GetValueList(); com_idioma.Show(); com_idioma.Enabled = false; SLidioma.Clear(); } } catch (SqlException ex) { for (int i = 0; i < ex.Errors.Count; i++) { errorMessages.Append("Index #" + i + "\n" + "Message: " + ex.Errors[i].Message + "\n" + "LineNumber: " + ex.Errors[i].LineNumber + "\n" + "Source: " + ex.Errors[i].Source + "\n" + "Procedure: " + ex.Errors[i].Procedure + "\n"); } Console.WriteLine(errorMessages.ToString()); this.inicializarDatos(); MessageBox.Show(ex.Errors[0].Message.ToString(), "Consultar Libro", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
///<summary> ///Find all users profiles on chosen server. ///</summary> ///<param name="servername">string</param> ///<param name="usermask">string</param> ///<returns>void</returns> private void LoadCheckedListBox(string servername, string usermask) { int i = 0; //is this a student by year search Boolean exist = CheckIfStudentByYearExists(); Boolean existDisabled = CheckIfDisabledAccounts(); //remove anything already loaded in CheckedListbox clb_FileInfo.Items.Clear(); WmiPropertiesHelper wp = new WmiPropertiesHelper(); try { SortedList sl = new SortedList(); //hashttable for student lists comparison Hashtable ht = new Hashtable(); //returns all users for the server specified - used for sl = wp.GetUserList(servername, usermask); //student checklist box if (exist) { //yearByStudentSL (key,value) //2016,sortedlist of 2016 students //2017,sortedlist of 2016 students ... ht = GetStudentUserListByYear(yearByStudentSL,this.checkedListBox1); } ICollection values = sl.GetValueList(); //narrow list to specific students foreach (WmiPropertiesHelper wh in values) { if (this.tb_user.Text.ToString() != "") { Regex r = new Regex(usermask.ToLower()); if (r.IsMatch(wh.ToString().ToLower())) { //student year checkbox if (exist) { //check the hashtable for match if (ht.Contains(wh.ToString().ToUpper())) { //if disabled accounts checked then see if the user account is in the adDisabledAccountsHT if (CheckDisabledAccountHashTable(existDisabled, wh.ToString().ToUpper())) { clb_FileInfo.Items.Add(wh); i++; } } } else { //if disabled accounts checked then see if the user account is in the adDisabledAccountsHT if (CheckDisabledAccountHashTable(existDisabled, wh.ToString().ToUpper())) { clb_FileInfo.Items.Add(wh); i++; } } } } else { //student checklist box if (exist) { if (ht.Contains(wh.ToString().ToUpper())) { //if disabled accounts checked then see if the user account is in the adDisabledAccountsHT if (CheckDisabledAccountHashTable(existDisabled, wh.ToString().ToUpper())) { clb_FileInfo.Items.Add(wh); i++; } } } else { //if disabled accounts checked then see if the user account is in the adDisabledAccountsHT if (CheckDisabledAccountHashTable(existDisabled, wh.ToString().ToUpper())) { clb_FileInfo.Items.Add(wh); i++; } } } } if (i > 0) { UpdateStatusStrip(i + " User profiles found"); } else { UpdateStatusStrip("No user profiles found"); } } catch (System.Runtime.InteropServices.COMException ex) { string mess = ""; switch ((uint)ex.ErrorCode) { case 0x80070005: mess = string.Format("{0} Unauthorized System Exceptionn caught.", ex); break; case 0x800706BA: mess = string.Format("{0} Unauthorized System Exceptionn caught.", ex); break; default: MessageBox.Show("Error opening worksheet: " + ex.Message); break; } UpdateStatusStrip("Error connecting to " + servername); MessageBox.Show(mess, "Server Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } //HRESULT cases not returned - will come back later to catch exception catch (Exception ex) { string mess = ""; switch ((uint)ex.HResult) { default: mess = string.Format("{0} Exception caught.", ex); break; } UpdateStatusStrip("Error connecting to " + servername); MessageBox.Show(mess, "Server Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
//搜寻 protected void btnSearch_Click(object sender, EventArgs e) { string strCondition = " rm.ReportID=" + DNTRequest.GetString("ReportID"), strColumns = ""; SortedList slOrder = new SortedList(), slColumns = new SortedList(), slStatistics = new SortedList(); DataTable dt = DbHelper.GetInstance().GetWorkflow_ReportDetailDataTableByKeyCol(DNTRequest.GetString("ReportID")); if (dt.Rows.Count > 0) { for (int i = 0; i < GridView1.Rows.Count; i++) { DataKey dk = GridView1.DataKeys[i]; int GroupID = Convert.ToInt32(dk[1]); string FieldID = dk[2].ToString(); string FieldName = dk[3].ToString(); int DataTypeID = Convert.ToInt32(dk[4]); int FieldHTMLTypeID = Convert.ToInt32(dk[5]); string tablePrefix = ""; if (dt.Select("FieldID=" + FieldID).Length > 0) { DataRow dvF = dt.Select("FieldID=" + FieldID)[0]; //用于设置排序及统计字段 System.Web.UI.WebControls.CheckBox cbIsShow = (System.Web.UI.WebControls.CheckBox)GridView1.Rows[i].FindControl("cbIsShow"); if (GroupID == 0) tablePrefix = "m."; else tablePrefix = "d."; //设置排序表达式 if (dvF["IsOrder"].ToString() == "1") { if (dvF["OrderPattern"].ToString() == "2") slOrder.Add(dvF["OrderIndex"], tablePrefix + FieldName + " DESC"); else slOrder.Add(dvF["OrderIndex"], tablePrefix + FieldName); } //设置列的显示顺序、统计字段顺序 if (cbIsShow.Checked) { slColumns.Add(dvF["DisplayOrder"], tablePrefix + FieldName); if (dvF["IsStatistics"].ToString() == "1") slStatistics.Add(dvF["DisplayOrder"], tablePrefix + FieldName); } System.Web.UI.WebControls.CheckBox cbCondition = (System.Web.UI.WebControls.CheckBox)GridView1.Rows[i].FindControl("cbCondition"); PlaceHolder ph = (PlaceHolder)GridView1.Rows[i].FindControl("placeHolder"); if (cbCondition.Checked) { switch (FieldHTMLTypeID) { case 1: //Label break; case 2: //Textbox if (DataTypeID == 1 || DataTypeID == 2 || DataTypeID == 3) { GPRP.GPRPControls.DropDownList ddlField = (GPRP.GPRPControls.DropDownList)ph.FindControl("ddlCompare" + FieldID); GPRP.GPRPControls.TextBox txtField = (GPRP.GPRPControls.TextBox)ph.FindControl("field" + FieldID); if (txtField.Text.Trim() != "") { if (DataTypeID == 1) if (ddlField.SelectedValue.ToUpper() == "LIKE" || ddlField.SelectedValue.ToUpper().Replace(" ", "") == "NOTLIKE") strCondition += " and " + tablePrefix + FieldName + ddlField.SelectedValue + "'%" + txtField.Text.Trim() + "%'"; else strCondition += " and " + tablePrefix + FieldName + ddlField.SelectedValue + "'" + txtField.Text.Trim() + "'"; else strCondition += " and " + tablePrefix + FieldName + ddlField.SelectedValue + txtField.Text.Trim(); } } else { GPRP.GPRPControls.DropDownList ddlField1 = (GPRP.GPRPControls.DropDownList)ph.FindControl("ddlCompareT1" + FieldID); GPRP.GPRPControls.DropDownList ddlField2 = (GPRP.GPRPControls.DropDownList)ph.FindControl("ddlCompareT2" + FieldID); GPRP.GPRPControls.TextBox txtField1 = (GPRP.GPRPControls.TextBox)ph.FindControl("fieldT1" + FieldID); GPRP.GPRPControls.TextBox txtField2 = (GPRP.GPRPControls.TextBox)ph.FindControl("fieldT2" + FieldID); if (txtField1.Text.Trim() != "") { strCondition += " and " + tablePrefix + FieldName + ddlField1.SelectedValue + "'" + txtField1.Text.Trim() + "'"; } if (txtField2.Text.Trim() != "") { strCondition += " and " + tablePrefix + FieldName + ddlField2.SelectedValue + "'" + txtField2.Text.Trim() + "'"; } } break; case 3: //TextArea GPRP.GPRPControls.DropDownList ddlField3 = (GPRP.GPRPControls.DropDownList)ph.FindControl("ddlCompare" + FieldID); GPRP.GPRPControls.TextBox txtField3 = (GPRP.GPRPControls.TextBox)ph.FindControl("field" + FieldID); if (txtField3.Text.Trim() != "") { if (ddlField3.SelectedValue.ToUpper() == "LIKE" || ddlField3.SelectedValue.ToUpper().Replace(" ", "") == "NOTLIKE") strCondition += " and " + tablePrefix + FieldName + ddlField3.SelectedValue + "'%" + txtField3.Text.Trim() + "%'"; else strCondition += " and " + tablePrefix + FieldName + ddlField3.SelectedValue + "'" + txtField3.Text.Trim() + "'"; } break; case 4: //checkboxList GPRP.GPRPControls.DropDownList ddlField4 = (GPRP.GPRPControls.DropDownList)ph.FindControl("ddlCompare" + FieldID); GPRP.GPRPControls.CheckBoxList chkLstField = (GPRP.GPRPControls.CheckBoxList)ph.FindControl("field" + FieldID); ; if (chkLstField.SelectedIndex >= 0) { for (int j = 0; j < chkLstField.Items.Count; j++) { if (chkLstField.Items[j].Selected) { if (ddlField4.SelectedValue.ToUpper() == "LIKE" || ddlField4.SelectedValue.ToUpper().Replace(" ", "") == "NOTLIKE") strCondition += " and " + tablePrefix + FieldName + ddlField4.SelectedValue + "'%" + chkLstField.Items[j].Value + "%'"; else strCondition += " and " + tablePrefix + FieldName + ddlField4.SelectedValue + "'" + chkLstField.Items[j].Value + "'"; } } } break; case 5: // dropdownlist GPRP.GPRPControls.DropDownList ddlField5 = (GPRP.GPRPControls.DropDownList)ph.FindControl("ddlCompare" + FieldID); GPRP.GPRPControls.DropDownList dropField = (GPRP.GPRPControls.DropDownList)ph.FindControl("field" + FieldID); ; if (ddlField5.SelectedValue.ToUpper() == "LIKE" || ddlField5.SelectedValue.ToUpper().Replace(" ", "") == "NOTLIKE") strCondition += " and " + tablePrefix + FieldName + ddlField5.SelectedValue + "'%" + dropField.SelectedValue + "%'"; else strCondition += " and " + tablePrefix + FieldName + ddlField5.SelectedValue + "'" + dropField.SelectedValue + "'"; break; case 6: //checkbox,不用加比较符下拉框 System.Web.UI.WebControls.CheckBox chkField = (System.Web.UI.WebControls.CheckBox)ph.FindControl("field" + FieldID); if (chkField.Checked) strCondition += " and " + tablePrefix + FieldName + "='1'"; break; case 7: //uploadFile break; case 8: //浏览形式按钮 GPRP.GPRPControls.DropDownList ddlField8 = (GPRP.GPRPControls.DropDownList)ph.FindControl("ddlCompare" + FieldID); System.Web.UI.WebControls.HiddenField txtBrowseFieldValue = (System.Web.UI.WebControls.HiddenField)ph.FindControl("field" + FieldID); ; if (txtBrowseFieldValue.Value.Trim() != "") { if (ddlField8.SelectedValue.ToUpper() == "LIKE" || ddlField8.SelectedValue.ToUpper().Replace(" ", "") == "NOTLIKE") strCondition += " and " + tablePrefix + FieldName + ddlField8.SelectedValue + "'%" + txtBrowseFieldValue.Value.Trim() + "%'"; else strCondition += " and " + tablePrefix + FieldName + ddlField8.SelectedValue + "'" + txtBrowseFieldValue.Value.Trim() + "'"; } break; } } } } //对SortedList进行分析 string strOrder = "", //排序 strSum = "";//用来sum的列 for (int i = 0; i < slColumns.Keys.Count; i++) strColumns += slColumns.GetValueList()[i].ToString() + ","; for (int i = 0; i < slOrder.Keys.Count; i++) strOrder += slOrder.GetValueList()[i].ToString() + ","; for (int i = 0; i < slStatistics.Keys.Count; i++) strSum += slStatistics.GetValueList()[i].ToString() + ","; /* string strGroupBy = "";//Groupby的列(strColumns中除去strSum之后的字串) SortedList slGroupBy = new SortedList(); slGroupBy = slColumns; if (slGroupBy.Count > 0 && slStatistics.Count>0) { for (int i = 0; i < slStatistics.Keys.Count; i++) slGroupBy.Remove(slStatistics.GetKey[i]); } for (int i = 0; i < slGroupBy.Keys.Count; i++) strGroupBy += slGroupBy.GetValueList()[i].ToString() + ","; strGroupBy = strGroupBy.Substring(0, strGroupBy.Length - 1); */ strColumns = strColumns.Substring(0, strColumns.Length - 1); strOrder = strOrder.Substring(0, strOrder.Length - 1); strSum = strSum.Substring(0, strSum.Length - 1); if (strColumns == "") { // string strScript = "<script type='text/javascript' lanuage='javascript'> alert('" + ResourceManager.GetString("Operation_RECORD") + "'); </script>"; string strScript = "<script type='text/javascript' lanuage='javascript'> alert('您没有选择任何报表显示字段,请确认!'); </script>"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alert", strScript, false); } else { Response.Redirect("GGC0Report.aspx?ReportID=" + DNTRequest.GetString("ReportID") + "&strCondition=" + Server.UrlEncode(strCondition) + "&strColumns=" + Server.UrlEncode(strColumns) + "&strOrder=" + Server.UrlEncode(strOrder) + "&strGroupBy=" + Server.UrlEncode(strSum)); } } System.Web.UI.ScriptManager.RegisterStartupScript(btnSearch, this.GetType(), "ButtonHideScript", strButtonHideScript, false); }
/// <summary> /// Create the grouping tabs control hirarchy /// </summary> /// <param name="useDataSource"> /// if set to <c>true</c> [use data source]. /// </param> /// <param name="settingsOrder"> /// The settings order. /// </param> private void CreateGroupingTabs(bool useDataSource, SortedList settingsOrder) { if (!useDataSource) { // recover control hierarchy from view state is not implemented return; } var tabPanelGroup = new HtmlGenericControl("div"); tabPanelGroup.Attributes.Add("id", "tpg1"); tabPanelGroup.Attributes.Add("class", "tabPanelGroup"); var tabGroup = new HtmlGenericControl("ul"); tabGroup.Attributes.Add("class", "tabGroup"); tabPanelGroup.Controls.Add(tabGroup); var tabPanel = new HtmlGenericControl("div"); tabPanel.Attributes.Add("class", "tabPanel"); var tabDefault = new HtmlGenericControl("li"); tabDefault.Attributes.Add("class", "tabDefault"); var aDefault = new HtmlGenericControl("a"); aDefault.Attributes.Add("href", "#id"); tabDefault.Controls.Add(aDefault); var fieldset = new HtmlGenericControl("dummy"); var tbl = new Table(); Dictionary<string, string> dicc = new Dictionary<string, string>(); // Initialize controls var currentGroup = SettingItemGroup.NONE; foreach (string currentSetting in settingsOrder.GetValueList()) { var currentItem = (ISettingItem)this.settings[currentSetting]; if (aDefault.InnerText.Length == 0) { tabDefault = new HtmlGenericControl("li"); tabDefault.Attributes.Add("class", "tabDefault"); // App_GlobalResources //tabDefault.InnerText = General.GetString(currentItem.Group.ToString()); aDefault = new HtmlGenericControl("a"); aDefault.Attributes.Add("href", "#" + currentItem.Group.ToString()); aDefault.InnerText = General.GetString(currentItem.Group.ToString()); tabDefault.Controls.Add(aDefault); } if (currentItem.Group != currentGroup) { if (fieldset.Attributes.Count > 0) { // add built fieldset fieldset.Controls.Add(tbl); tabPanel.Controls.Add(fieldset); tabPanelGroup.Controls.Add(tabPanel); if(tabDefault.Controls.Count == 1){ var TabName = string.Empty; foreach (var t in tabDefault.Controls) { TabName = ((HtmlGenericControl)t).InnerText; } if (!dicc.ContainsKey(TabName)) { dicc.Add(TabName, TabName); tabGroup.Controls.Add(tabDefault); } } else{ tabGroup.Controls.Add(tabDefault); } } // start a new fieldset fieldset = CreateNewFieldSet(currentItem); tabPanel = new HtmlGenericControl("div"); tabPanel.Attributes.Add("class", "tabPanel"); tabPanel.Attributes.Add("id", currentItem.Group.ToString()); tabDefault = new HtmlGenericControl("li"); tabDefault.Attributes.Add("class", "tabDefault"); aDefault = new HtmlGenericControl("a"); aDefault.Attributes.Add("href", "#" + currentItem.Group.ToString()); aDefault.InnerText = General.GetString(currentItem.Group.ToString()); tabDefault.Controls.Add(aDefault); // start a new table tbl = new Table(); tbl.Attributes.Add("class", "SettingsTableGroup"); tbl.Attributes.Add("width", "100%"); currentGroup = currentItem.Group; } tbl.Rows.Add(this.CreateOneSettingRow(currentSetting, currentItem)); } if (tabDefault.Controls.Count == 1) { var TabName = string.Empty; foreach (var t in tabDefault.Controls) { TabName = ((HtmlGenericControl)t).InnerText; } if (!dicc.ContainsKey(TabName)) { dicc.Add(TabName, TabName); tabGroup.Controls.Add(tabDefault); } } else { tabGroup.Controls.Add(tabDefault); } fieldset.Controls.Add(tbl); tabPanel.Controls.Add(fieldset); tabPanelGroup.Controls.Add(tabPanel); this.Controls.AddAt(0, tabPanelGroup); this.groupingTabsCreated = true; }
/// <summary> /// see if any patches are missing; is there a direct line between FCurrentlyInstalledVersion and FLatestAvailablePatch? /// </summary> /// <returns>return a list of all patches that should be applied. empty list if there is a problem</returns> public SortedList CheckPatchesConsistent(SortedList AOrderedListOfAllPatches) { SortedList ResultPatchList = new SortedList(); TFileVersionInfo testPatchVersion; // get the latest patch that is available FLatestAvailablePatch = new TFileVersionInfo(FCurrentlyInstalledVersion); foreach (string patch in AOrderedListOfAllPatches.GetValueList()) { testPatchVersion = TPatchFileVersionInfo.GetLatestPatchVersionFromDiffZipName(patch); if (testPatchVersion.Compare(FLatestAvailablePatch) > 0) { FLatestAvailablePatch = testPatchVersion; } } // drop unnecessary patch files // ie. patch files leading to the same version, eg. 2.2.11-1 and 2.2.12-2 to 2.2.12-3 // we only want the biggest step testPatchVersion = new TFileVersionInfo(FCurrentlyInstalledVersion); bool patchesAvailable = true; while (patchesAvailable) { StringCollection applyingPatches = new StringCollection(); foreach (string patch in AOrderedListOfAllPatches.GetValueList()) { if (TPatchFileVersionInfo.PatchApplies(testPatchVersion, patch)) { applyingPatches.Add(patch); } } patchesAvailable = (applyingPatches.Count > 0); if (applyingPatches.Count > 0) { // see which of the applying patches takes us further string highestPatch = applyingPatches[0]; TFileVersionInfo highestPatchVersion = TPatchFileVersionInfo.GetLatestPatchVersionFromDiffZipName(highestPatch); foreach (string patch in applyingPatches) { if (TPatchFileVersionInfo.GetLatestPatchVersionFromDiffZipName(patch).Compare(highestPatchVersion) > 0) { highestPatch = patch; highestPatchVersion = TPatchFileVersionInfo.GetLatestPatchVersionFromDiffZipName(highestPatch); } } ResultPatchList.Add(highestPatch, highestPatch); testPatchVersion = highestPatchVersion; } } if (FLatestAvailablePatch.Compare(testPatchVersion) != 0) { // check for a generic patch file, starting from version 0.0.99.99 foreach (string patch in AOrderedListOfAllPatches.GetValueList()) { if (patch.Contains("0.0.99.99")) { testPatchVersion = TPatchFileVersionInfo.GetLatestPatchVersionFromDiffZipName(patch); ResultPatchList.Clear(); ResultPatchList.Add(patch, patch); } } } if (FLatestAvailablePatch.Compare(testPatchVersion) != 0) { TLogging.Log("missing patchfile from version " + testPatchVersion.ToString() + " to " + FLatestAvailablePatch.ToString()); return new SortedList(); } return ResultPatchList; }
public void Write(System.Xml.XmlWriter writer) { // Write the XML declaration if (_options.WriteXMLDecl) writer.WriteStartDocument(true); // Write header info writer.WriteComment("FlowChart.NET diagram"); // Write the root element writer.WriteStartElement("Diagram"); writer.WriteAttributeString("Version", Version.ToString()); // Write brushes int id = 0; SortedList brushes = new SortedList(); foreach(Brush b in Brush.Brushes) { brushes.Add(id, b); // Map brushes to ids id++; } writer.WriteStartElement("Brushes"); writer.WriteAttributeString("Count", XmlConvert.FromInt32(brushes.Count)); for(int i = 0; i < brushes.Count; i++) { FlowChartX.Brush b = (FlowChartX.Brush)brushes.GetValueList()[i]; WriteBrushElement(writer, b, brushes); } // Close the Brushes element writer.WriteEndElement(); // Write the environment information writer.WriteStartElement("Environment"); // Write appearance information WriteProperties(writer, _diagram, _appearanceProps, "Appearance"); // Write behaviour information WriteProperties(writer, _diagram, _behaviourProps, "Behaviour"); // Write defaults information WriteProperties(writer, _diagram, _defaultProps, "Defaults"); // Write default brush and pens writer.WriteStartElement("DefaultsGDI"); WriteBrushRefElement(writer, _diagram.BoxBrush, "BoxBrush", brushes); WriteBrushRefElement(writer, _diagram.TableBrush, "TableBrush", brushes); WriteBrushRefElement(writer, _diagram.ArrowBrush, "ArrowBrush", brushes); WriteBrushRefElement(writer, _diagram.BackBrush, "BackBrush", brushes); WriteBrushRefElement(writer, _diagram.ExteriorBrush, "ExteriorBrush", brushes); WritePenElement(writer, _diagram.BoxPen, "BoxPen", brushes); WritePenElement(writer, _diagram.TablePen, "TablePen", brushes); WritePenElement(writer, _diagram.ArrowPen, "ArrowPen", brushes); writer.WriteEndElement(); // Write grid information WriteProperties(writer, _diagram, _gridProps, "Grid"); // Write layout information WriteProperties(writer, _diagram, _layoutProps, "Layout"); // Write miscellaneous information WriteProperties(writer, _diagram, _miscProps, "Miscellaneous"); // Close the environment element writer.WriteEndElement(); // Write the box information writer.WriteStartElement("Boxes"); writer.WriteAttributeString("Count", XmlConvert.FromInt32(_diagram.Boxes.Count)); id = 0; SortedList sl = new SortedList(); foreach(Box b in _diagram.Boxes) { writer.WriteStartElement("Box"); writer.WriteAttributeString("Id", XmlConvert.FromInt32(id)); writer.WriteAttributeString("ZIndex", XmlConvert.FromInt32(b.ZIndex)); // Write the shape type string shape = "Invalid"; switch(b.Style) { case BoxStyle.Delay: shape = "Delay"; break; case BoxStyle.Ellipse: shape = "Ellipse"; break; case BoxStyle.Rectangle: shape = "Rectangle"; break; case BoxStyle.Rhombus: shape = "Decision"; break; case BoxStyle.RoundedRectangle: shape = "RoundRectangle"; break; case BoxStyle.Shape: // Only shapes with assigned ids are serialized shape = b.Shape.Id; if (shape == "") { // Possibly one of the old predefined shapes foreach (ShapeTemplate newShape in ShapeTemplate.Shapes) { if (b.Shape.Equals(newShape)) { shape = newShape.Id; break; } } if (shape == "") shape = "Rectangle"; } break; } writer.WriteElementString("Shape", shape); // Write brush index WriteBrushRefElement(writer, b.Brush, "Brush", brushes); // Write the pen WritePenElement(writer, b.Pen, "Pen", brushes); // Write the tag WriteTagElement(writer, b); // Write constraints WriteConstraints(writer, b); // Write properties WriteProperties(writer, b, _boxProps, null); writer.WriteEndElement(); sl.Add(id, b); // map boxes to ids id++; } // Close boxes element writer.WriteEndElement(); // Write the control host information writer.WriteStartElement("ControlHosts"); writer.WriteAttributeString("Count", XmlConvert.FromInt32(_diagram.ControlHosts.Count)); BinaryFormatter fmt = new BinaryFormatter(); foreach (ControlHost h in _diagram.ControlHosts) { writer.WriteStartElement("Host"); writer.WriteAttributeString("Id", XmlConvert.FromInt32(id)); writer.WriteAttributeString("ZIndex", XmlConvert.FromInt32(h.ZIndex)); if (h.Control != null) { System.Type type = h.Control.GetType(); writer.WriteAttributeString("ControlAssembly", type.Assembly.GetName().Name); writer.WriteAttributeString("ControlType", type.FullName); // Find the z-index of the contained control int controlZIndex = 0; for (int i = 0; i < _diagram.Controls.Count; i++) { if (_diagram.Controls[i] == h.Control) { controlZIndex = i; break; } } writer.WriteAttributeString("ControlZIndex", controlZIndex.ToString()); } else { writer.WriteAttributeString("ControlAssembly", ""); writer.WriteAttributeString("ControlType", ""); writer.WriteAttributeString("ControlZIndex", "0"); } // Write brush index WriteBrushRefElement(writer, h.Brush, "Brush", brushes); // Write the pen WritePenElement(writer, h.Pen, "Pen", brushes); // Write control properties WriteControlProperties(writer, h.Control, fmt); // Write control host properties WriteProperties(writer, h, _hostProps, null); // Write the tag WriteTagElement(writer, h); // Write constraints WriteConstraints(writer, h); writer.WriteEndElement(); sl.Add(id, h); // map hosts to ids id++; } writer.WriteEndElement(); // Write table information writer.WriteStartElement("Tables"); writer.WriteAttributeString("Count", XmlConvert.FromInt32(_diagram.Tables.Count)); foreach(Table t in _diagram.Tables) { writer.WriteStartElement("Table"); writer.WriteAttributeString("Id", XmlConvert.FromInt32(id)); writer.WriteAttributeString("ZIndex", XmlConvert.FromInt32(t.ZIndex)); writer.WriteAttributeString("Rows", XmlConvert.FromInt32(t.RowCount)); writer.WriteAttributeString("Columns", XmlConvert.FromInt32(t.ColumnCount)); // Write table data writer.WriteStartElement("Data"); for(int r = 0; r < t.RowCount; r++) { for(int c = 0; c < t.ColumnCount; c++) { Table.Cell cell = t[c, r]; writer.WriteStartElement("Cell"); WriteBrushRefElement(writer, cell.Brush, "Brush", brushes); // Write the tag WriteTagElement(writer, cell); WriteProperties(writer, cell, new string[] { "Text", "TextFormat", "Picture", "PicturePos", "TextColor", "HyperLink", "ToolTip", "RowSpan", "ColumnSpan", }, null); writer.WriteEndElement(); } } writer.WriteEndElement(); // Write row data writer.WriteStartElement("Rows"); for(int r = 0; r < t.RowCount; r++) { writer.WriteStartElement("Row"); WriteProperties(writer, t.Rows[r], new string[] { "Height", "AnchorPattern", "Header", "Expanded" }, null); writer.WriteEndElement(); } writer.WriteEndElement(); // Write column data writer.WriteStartElement("Columns"); for(int c = 0; c < t.ColumnCount; c++) { writer.WriteStartElement("Column"); WriteProperties(writer, t.Columns[c], new string[] { "ColumnStyle", "Width" }, null); writer.WriteEndElement(); } writer.WriteEndElement(); // Write brush index WriteBrushRefElement(writer, t.Brush, "Brush", brushes); // Write caption background brush WriteBrushRefElement(writer, t.CaptionBackBrush, "CaptionBackBrush", brushes); // Write the pen WritePenElement(writer, t.Pen, "Pen", brushes); // Write the tag WriteTagElement(writer, t); // Write constraints WriteConstraints(writer, t); // Write properties WriteProperties(writer, t, _tableProps, null); writer.WriteEndElement(); sl.Add(id, t); // map tables to ids id++; } // Close tables element writer.WriteEndElement(); // Write containers in v7 writer.WriteStartElement("Containers"); writer.WriteAttributeString("Count", "0"); writer.WriteEndElement(); // Write arrows data writer.WriteStartElement("Arrows"); writer.WriteAttributeString("Count", XmlConvert.FromInt32(_diagram.Arrows.Count)); int oi, di; int aid = id; foreach(Arrow a in _diagram.Arrows) { writer.WriteStartElement("Arrow"); writer.WriteAttributeString("Id", XmlConvert.FromInt32(aid)); writer.WriteAttributeString("ZIndex", XmlConvert.FromInt32(a.ZIndex)); if (a.Origin != _diagram.Dummy) { oi = sl.IndexOfValue(a.Origin); if(oi < 0) throw new Exception("Unexpected arrow origin index"); id = (int)sl.GetKey(oi); } else { id = -1; } writer.WriteAttributeString("From", XmlConvert.FromInt32(id)); if(a.Origin is Table) writer.WriteAttributeString("RowFrom", XmlConvert.FromInt32(a.OrgnIndex)); if (a.Destination != _diagram.Dummy) { di = sl.IndexOfValue(a.Destination); if(di < 0) throw new Exception("Unexpected arrow destination index"); id = (int)sl.GetKey(di); } else { id = -1; } writer.WriteAttributeString("To", XmlConvert.FromInt32(id)); if(a.Destination is Table) writer.WriteAttributeString("RowTo", XmlConvert.FromInt32(a.DestIndex)); // Write control points writer.WriteStartElement("Data"); foreach(PointF pt in a.ControlPoints) { writer.WriteStartElement("Point"); writer.WriteAttributeString("X", XmlConvert.FromSingle(pt.X)); writer.WriteAttributeString("Y", XmlConvert.FromSingle(pt.Y)); writer.WriteEndElement(); } writer.WriteEndElement(); // Write brush index WriteBrushRefElement(writer, a.Brush, "Brush", brushes); // Write pen WritePenElement(writer, a.Pen, "Pen", brushes); // Write head pen WritePenElement(writer, a.HeadPen, "HeadPen", brushes); // Write the tag WriteTagElement(writer, a); // Write arrow properties WriteProperties(writer, a, _arrowProps, null); writer.WriteEndElement(); sl.Add(aid, a); // map arrows to ids aid++; } // Close arrows element writer.WriteEndElement(); // Write group objects writer.WriteStartElement("Groups"); writer.WriteAttributeString("Count", XmlConvert.FromInt32(_diagram.Groups.Count)); foreach(Group g in _diagram.Groups) { writer.WriteStartElement("Group"); oi = sl.IndexOfValue(g.MainObject); if(oi < 0) throw new Exception("Unexpected group master index"); id = (int)sl.GetKey(oi); // Write group's main object writer.WriteStartElement("MainObject"); writer.WriteAttributeString("Id", XmlConvert.FromInt32(id)); writer.WriteEndElement(); // Write group's visibility writer.WriteElementString("Visible", g.Visible.ToString()); // Write AutoDeleteItems flag writer.WriteElementString("AutoDeleteItems", g.AutoDeleteItems.ToString()); // Write Expandable flag writer.WriteElementString("Expandable", g.Expandable.ToString()); // Write FollowMasterRotation flag writer.WriteElementString("FollowMasterRotation", g.FollowMasterRotation.ToString()); // Write group's tag WriteTagElement(writer, g); // Write attached objects writer.WriteStartElement("Attachments"); writer.WriteAttributeString("Count", XmlConvert.FromInt32(g.Attachments.Count)); foreach(Attachment at in g.Attachments) { writer.WriteStartElement("Attachment"); writer.WriteElementString("Data", XmlConvert.FromInt32(at.attData)); oi = sl.IndexOfValue(at.node); if(oi < 0) throw new Exception("Unexpected group attachee index"); id = (int)sl.GetKey(oi); writer.WriteElementString("Object", XmlConvert.FromInt32(id)); WriteRectangleFElement(writer, "Percents", at.percents); writer.WriteElementString("Type", at.type.ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndElement(); } // Close groups element writer.WriteEndElement(); // Close the diagram element writer.WriteEndElement(); // Finish with this document if (_options.WriteXMLDecl) writer.WriteEndDocument(); writer.Flush(); }
public override IList GetValueList() { lock (_root) { return(_list.GetValueList()); } }
private void mostrarLista() { StringBuilder errorMessages = new StringBuilder(); Bibliografia bi = new Bibliografia(); try { if ((bi.OptenerIsbn(bi)).v_isbn.Count != 0) { SLisbn = new SortedList(); foreach (String isbn in bi.v_isbn) { SLisbn.Add(isbn, isbn); } com_isbn.DataSource = SLisbn.GetValueList(); com_isbn.Show(); } if ((bi.OptenerTipoBibliografia(bi)).v_tipoBibliografia.Count != 0) { SLtipobibliografia = new SortedList(); foreach (String tipobibliografias in bi.v_tipoBibliografia) { SLtipobibliografia.Add(tipobibliografias, tipobibliografias); } com_tipo_bibliografia.DataSource = SLtipobibliografia.GetValueList(); com_tipo_bibliografia.Show(); } } catch (SqlException ex) { for (int i = 0; i < ex.Errors.Count; i++) { errorMessages.Append("Index #" + i + "\n" + "Message: " + ex.Errors[i].Message + "\n" + "LineNumber: " + ex.Errors[i].LineNumber + "\n" + "Source: " + ex.Errors[i].Source + "\n" + "Procedure: " + ex.Errors[i].Procedure + "\n"); } Console.WriteLine(errorMessages.ToString()); MessageBox.Show(ex.Errors[0].Message.ToString(), "Asignar Libros", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void but_eliminar_libro_Click(object sender, EventArgs e) { StringBuilder errorMessages = new StringBuilder(); Libro lib = new Libro(); if (tex_isbn.Text.Length == 0) { this.inicializarDatos(); MessageBox.Show("Debe ingresar un ISBN", "Eliminar Libro", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { try { lib.v_isbn = tex_isbn.Text; if ((lib.ConsultarLibro(lib)).v_isbn.Length != 0) { tex_isbn.Text = lib.v_isbn; tex_titulo.Text = lib.v_titulo; tex_edicion.Text = lib.v_edicion; tex_autor.Text = lib.v_autor; tex_año.Text = lib.v_año; SLeditorial = new SortedList(); SLeditorial.Add(lib.v_Deditorial, lib.v_Deditorial); com_editorial.DataSource = SLeditorial.GetValueList(); com_editorial.Show(); com_editorial.Enabled = false; SLeditorial.Clear(); SLtipolibro = new SortedList(); SLtipolibro.Add(lib.v_Dtipo_libro, lib.v_Dtipo_libro); com_tipo_libro.DataSource = SLtipolibro.GetValueList(); com_tipo_libro.Show(); com_tipo_libro.Enabled = false; SLtipolibro.Clear(); SLidioma = new SortedList(); SLidioma.Add(lib.v_Didioma, lib.v_Didioma); com_idioma.DataSource = SLidioma.GetValueList(); com_idioma.Show(); com_idioma.Enabled = false; SLidioma.Clear(); lib.v_usuario_m = this.usuario; if ((MessageBox.Show("¿Desea eliminar el Libro con Titulo: " + lib.v_titulo + " ?", "Eliminar Libro", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)) { try { if (lib.EliminarLibro(lib) != 0) { this.inicializarDatos(); MessageBox.Show("Libro eliminada correctamente", "Eliminar Libro", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (SqlException ex) { for (int i = 0; i < ex.Errors.Count; i++) { errorMessages.Append("Index #" + i + "\n" + "Message: " + ex.Errors[i].Message + "\n" + "LineNumber: " + ex.Errors[i].LineNumber + "\n" + "Source: " + ex.Errors[i].Source + "\n" + "Procedure: " + ex.Errors[i].Procedure + "\n"); } Console.WriteLine(errorMessages.ToString()); this.inicializarDatos(); MessageBox.Show(ex.Errors[0].Message.ToString(), "Eliminar Libro", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } catch (SqlException ex) { for (int i = 0; i < ex.Errors.Count; i++) { errorMessages.Append("Index #" + i + "\n" + "Message: " + ex.Errors[i].Message + "\n" + "LineNumber: " + ex.Errors[i].LineNumber + "\n" + "Source: " + ex.Errors[i].Source + "\n" + "Procedure: " + ex.Errors[i].Procedure + "\n"); } Console.WriteLine(errorMessages.ToString()); this.inicializarDatos(); MessageBox.Show(ex.Errors[0].Message.ToString(), "Eliminar Libro", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
//private void mostrarLista() //{ // StringBuilder errorMessages = new StringBuilder(); // Editorial edi = new Editorial(); // try // { // if ((edi.OptenerPais(edi)).v_pais.Count != 0) // { // SLpais = new SortedList(); // foreach (String pais in edi.v_pais) // { // SLpais.Add(pais, pais); // } // com_pais.DataSource = SLpais.GetValueList(); // com_pais.Show(); // } // } // catch (SqlException ex) // { // for (int i = 0; i < ex.Errors.Count; i++) // { // errorMessages.Append("Index #" + i + "\n" + // "Message: " + ex.Errors[i].Message + "\n" + // "LineNumber: " + ex.Errors[i].LineNumber + "\n" + // "Source: " + ex.Errors[i].Source + "\n" + // "Procedure: " + ex.Errors[i].Procedure + "\n"); // } // Console.WriteLine(errorMessages.ToString()); // MessageBox.Show(ex.Errors[0].Message.ToString(), // "Eliminar Editorial", // MessageBoxButtons.OK, // MessageBoxIcon.Warning); // } //} private void but_eliminar_persona_Click(object sender, EventArgs e) { StringBuilder errorMessages = new StringBuilder(); Editorial edi = new Editorial(); if (tex_nombre_editorial.Text.Length == 0) { this.inicializarDatos(); MessageBox.Show("Debe ingresar un Nombre", "Eliminar Editorial", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { try { edi.v_nombre_editorial = tex_nombre_editorial.Text; //edi.v_Dpais = com_pais.SelectedItem.ToString(); edi.v_usuario_m = this.usuario; if ((edi.ConsultarEditorial(edi)).v_nombre_editorial.Length != 0) { tex_nombre_editorial.Text = edi.v_nombre_editorial; tex_direccion.Text = edi.v_direccion_editorial; SLpais = new SortedList(); SLpais.Add(edi.v_Dpais, edi.v_Dpais); com_pais.DataSource = SLpais.GetValueList(); com_pais.Show(); com_pais.Enabled = false; if ((MessageBox.Show("¿Desea eliminar la Editorial con Nombre: " + edi.v_nombre_editorial + " ?", "Eliminar Editorial", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)) { try { if (edi.EliminarEditorial(edi) != 0) { SLpais.Clear(); com_pais.DataSource = null; com_pais.Show(); this.inicializarDatos(); MessageBox.Show("Editorial eliminada correctamente", "Eliminar Editorial", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (SqlException ex) { for (int i = 0; i < ex.Errors.Count; i++) { SLpais.Clear(); com_pais.DataSource = null; com_pais.Show(); errorMessages.Append("Index #" + i + "\n" + "Message: " + ex.Errors[i].Message + "\n" + "LineNumber: " + ex.Errors[i].LineNumber + "\n" + "Source: " + ex.Errors[i].Source + "\n" + "Procedure: " + ex.Errors[i].Procedure + "\n"); } Console.WriteLine(errorMessages.ToString()); this.inicializarDatos(); MessageBox.Show(ex.Errors[0].Message.ToString(), "Eliminar Editorial", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } catch (SqlException ex) { for (int i = 0; i < ex.Errors.Count; i++) { errorMessages.Append("Index #" + i + "\n" + "Message: " + ex.Errors[i].Message + "\n" + "LineNumber: " + ex.Errors[i].LineNumber + "\n" + "Source: " + ex.Errors[i].Source + "\n" + "Procedure: " + ex.Errors[i].Procedure + "\n"); } SLpais.Clear(); com_pais.DataSource = null; com_pais.Show(); Console.WriteLine(errorMessages.ToString()); this.inicializarDatos(); MessageBox.Show(ex.Errors[0].Message.ToString(), "Eliminar Editorial", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
private void mostrarLista() { StringBuilder errorMessages = new StringBuilder(); Carrera ca = new Carrera(); try { if ((ca.OptenerMateria(ca)).v_materia.Count != 0) { SLfacultad = new SortedList(); foreach (String materia in ca.v_materia) { SLfacultad.Add(materia, materia); } com_materia.DataSource = SLfacultad.GetValueList(); com_materia.Show(); } } catch (SqlException ex) { for (int i = 0; i < ex.Errors.Count; i++) { errorMessages.Append("Index #" + i + "\n" + "Message: " + ex.Errors[i].Message + "\n" + "LineNumber: " + ex.Errors[i].LineNumber + "\n" + "Source: " + ex.Errors[i].Source + "\n" + "Procedure: " + ex.Errors[i].Procedure + "\n"); } Console.WriteLine(errorMessages.ToString()); MessageBox.Show(ex.Errors[0].Message.ToString(), "Asignar Materia", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public void TestGetValueListBasic() { StringBuilder sblMsg = new StringBuilder(99); SortedList sl2 = null; IEnumerator en = null; StringBuilder sbl3 = new StringBuilder(99); StringBuilder sbl4 = new StringBuilder(99); StringBuilder sblWork1 = new StringBuilder(99); int i3 = 0; int i = 0; int j = 0; // // Constructor: Create SortedList using this as IComparer and default settings. // sl2 = new SortedList(); // Verify that the SortedList is not null. Assert.NotNull(sl2); // Verify that the SortedList is empty. Assert.Equal(0, sl2.Count); // Testcase: Set - null key, ArgExc expected Assert.Throws<ArgumentNullException>(() => { sl2[null] = 0; }); Assert.Equal(0, sl2.Count); // Testcase: Set - null val sl2[(object)100] = (object)null; Assert.Equal(1, sl2.Count); // Testcase: vanila Set sl2[(object)100] = 1; Assert.Equal(1, sl2.Count); sl2.Clear(); Assert.Equal(0, sl2.Count); // Testcase: add key-val pairs for (i = 0; i < 100; i++) { sl2.Add(i + 100, i); } Assert.Equal(100, sl2.Count); for (i = 0; i < 100; i++) { j = i + 100; Assert.True(sl2.ContainsKey((int)j)); Assert.True(sl2.ContainsValue(i)); object o2 = sl2[(int)j]; Assert.NotNull(o2); Assert.True(o2.Equals(i), "Error, entry for key " + j.ToString() + " is " + o2.ToString() + " but should have been " + i.ToString()); } // FOR // testcase: GetValueList // ICollection.GetEnumerator() first test the boundaries on the Remove method thru GetEnumerator implementation en = (IEnumerator)sl2.GetValueList().GetEnumerator(); // Boundary for Current Assert.Throws<InvalidOperationException>(() => { object throwaway = en.Current; } ); j = 0; // go over the enumarator en = (IEnumerator)sl2.GetValueList().GetEnumerator(); while (en.MoveNext()) { // Current to see the order i3 = (int)en.Current; Assert.Equal(i3, j); // GetObject again to see the same order i3 = (int)en.Current; Assert.Equal(i3, j); j++; } // Boundary for GetObject Assert.Throws<InvalidOperationException>(() => { object throwawayobj = en.Current; } ); // Boundary for MoveNext: call MoveNext to make sure it returns false Assert.False((en.MoveNext()) || (j != 100)); // call again MoveNext to make sure it still returns false Assert.False(en.MoveNext()); Assert.Equal(100, sl2.Count); // now modify the sortedlist while enumerator is still active en = (IEnumerator)sl2.GetKeyList().GetEnumerator(); //can remove an item thru en en.MoveNext(); sl2[1] = 0; // Set (int index, object val) // this works fine // Boundary for MoveNext Assert.Throws<InvalidOperationException>(() => { en.MoveNext(); }); }
private void mostrarLista() { try { if ((bi.OptenerMateria(bi)).v_materia.Count != 0) { SLmateria = new SortedList(); foreach (String materia in bi.v_materia) { SLmateria.Add(materia, materia); } com_materia.DataSource = SLmateria.GetValueList(); com_materia.Show(); } if ((bi.OptenerSemestre(bi)).v_semestre.Count != 0) { SLsemestre = new SortedList(); foreach (String semestre in bi.v_semestre) { SLsemestre.Add(semestre, semestre); } com_semestre.DataSource = SLsemestre.GetValueList(); com_semestre.Show(); } } catch (SqlException ex) { for (int i = 0; i < ex.Errors.Count; i++) { errorMessages.Append("Index #" + i + "\n" + "Message: " + ex.Errors[i].Message + "\n" + "LineNumber: " + ex.Errors[i].LineNumber + "\n" + "Source: " + ex.Errors[i].Source + "\n" + "Procedure: " + ex.Errors[i].Procedure + "\n"); } Console.WriteLine(errorMessages.ToString()); MessageBox.Show(ex.Errors[0].Message.ToString(), "Solicitar Bibliografía", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void mostrarLista() { StringBuilder errorMessages = new StringBuilder(); Materia mat = new Materia(); try { if ((mat.OptenerFacultad(mat)).v_facultad.Count != 0) { SLfacultad = new SortedList(); foreach (String facu in mat.v_facultad) { SLfacultad.Add(facu, facu); } com_facultad.DataSource = SLfacultad.GetValueList(); com_facultad.Show(); } } catch (SqlException ex) { for (int i = 0; i < ex.Errors.Count; i++) { errorMessages.Append("Index #" + i + "\n" + "Message: " + ex.Errors[i].Message + "\n" + "LineNumber: " + ex.Errors[i].LineNumber + "\n" + "Source: " + ex.Errors[i].Source + "\n" + "Procedure: " + ex.Errors[i].Procedure + "\n"); } Console.WriteLine(errorMessages.ToString()); MessageBox.Show(ex.Errors[0].Message.ToString(), "Agregar Materia", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void mostrarLista() { StringBuilder errorMessages = new StringBuilder(); Persona per = new Persona(); try { if ((per.OptenerPais(per)).v_pais.Count != 0) { SLpais = new SortedList(); foreach (String pais in per.v_pais) { SLpais.Add(pais, pais); } com_pais_nacimiento.DataSource = SLpais.GetValueList(); com_pais_nacimiento.Show(); } if ((per.OptenerDocumento(per)).v_tipodocumento.Count != 0) { SLtipodocumento = new SortedList(); foreach (String tipodocumento in per.v_tipodocumento) { SLtipodocumento.Add(tipodocumento, tipodocumento); } com_tipo_documento.DataSource = SLtipodocumento.GetValueList(); com_tipo_documento.Show(); } if ((per.OptenerTipoPersona(per)).v_tipopersona.Count != 0) { SLtipopersona = new SortedList(); foreach (String tipopersona in per.v_tipopersona) { SLtipopersona.Add(tipopersona, tipopersona); } com_tipo_persona.DataSource = SLtipopersona.GetValueList(); com_tipo_persona.Show(); } } catch (SqlException ex) { for (int i = 0; i < ex.Errors.Count; i++) { errorMessages.Append("Index #" + i + "\n" + "Message: " + ex.Errors[i].Message + "\n" + "LineNumber: " + ex.Errors[i].LineNumber + "\n" + "Source: " + ex.Errors[i].Source + "\n" + "Procedure: " + ex.Errors[i].Procedure + "\n"); } Console.WriteLine(errorMessages.ToString()); MessageBox.Show(ex.Errors[0].Message.ToString(), "Agregar Persona", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// Create the flat settings groups control hirarchy /// </summary> /// <param name="useDataSource"> /// if set to <c>true</c> [use data source]. /// </param> /// <param name="settingsOrder"> /// The settings order. /// </param> private void CreateGroupFlat(bool useDataSource, SortedList settingsOrder) { if (!useDataSource) { // recover control hierarchy from view state is not implemented return; } var fieldset = new HtmlGenericControl("dummy"); var tbl = new Table(); // Initialize controls var currentGroup = SettingItemGroup.NONE; foreach (string currentSetting in settingsOrder.GetValueList()) { var currentItem = (ISettingItem) this.settings[currentSetting]; if (currentItem.Group != currentGroup) { if (fieldset.Attributes.Count > 0) { // add built fieldset fieldset.Controls.Add(tbl); this.Controls.Add(fieldset); } // start a new fieldset fieldset = CreateNewFieldSet(currentItem); // start a new table tbl = new Table(); tbl.Attributes.Add("class", "SettingsTableGroup"); tbl.Attributes.Add("width", "100%"); currentGroup = currentItem.Group; } tbl.Rows.Add(this.CreateOneSettingRow(currentSetting, currentItem)); } fieldset.Controls.Add(tbl); this.Controls.Add(fieldset); }
private void mostrarFacultad() { try { if ((mat.OptenerFacultad(mat)).v_facultad.Count != 0) { SLfacultad = new SortedList(); foreach (String pais in mat.v_facultad) { SLfacultad.Add(pais, pais); } com_facultad.DataSource = SLfacultad.GetValueList(); com_facultad.SelectedItem = mat.v_Dfacultad; com_facultad.Show(); } } catch (SqlException ex) { for (int i = 0; i < ex.Errors.Count; i++) { errorMessages.Append("Index #" + i + "\n" + "Message: " + ex.Errors[i].Message + "\n" + "LineNumber: " + ex.Errors[i].LineNumber + "\n" + "Source: " + ex.Errors[i].Source + "\n" + "Procedure: " + ex.Errors[i].Procedure + "\n"); } Console.WriteLine(errorMessages.ToString()); MessageBox.Show(ex.Errors[0].Message.ToString(), "Modificar Materia", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void mostrarLista() { StringBuilder errorMessages = new StringBuilder(); Editorial edi = new Editorial(); try { if ((edi.OptenerPais(edi)).v_pais.Count != 0) { SLpais = new SortedList(); foreach (String pais in edi.v_pais) { SLpais.Add(pais, pais); } com_pais.DataSource = SLpais.GetValueList(); com_pais.Show(); } } catch (SqlException ex) { for (int i = 0; i < ex.Errors.Count; i++) { errorMessages.Append("Index #" + i + "\n" + "Message: " + ex.Errors[i].Message + "\n" + "LineNumber: " + ex.Errors[i].LineNumber + "\n" + "Source: " + ex.Errors[i].Source + "\n" + "Procedure: " + ex.Errors[i].Procedure + "\n"); } Console.WriteLine(errorMessages.ToString()); MessageBox.Show(ex.Errors[0].Message.ToString(), "Agregar Editorial", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public double[,] CalcCachedInterpolationInfo(double a_dTime, SortedList a_sorted) { double[,] aReturn = new double[,]{{1}}; int nIndex = 0; // if (a_sorted.ContainsKey(a_dTime)) nIndex = a_sorted.IndexOfKey(a_dTime); if (nIndex >= 0) { return new double[,]{{(double)a_sorted.GetByIndex(nIndex)}}; } else { a_sorted.Add(a_dTime, -4711); nIndex = a_sorted.IndexOfKey(a_dTime); a_sorted.RemoveAt(nIndex); } //nIndex is meant to represent the next index after a_dTime. //If a_dTime is the same as a key, nIndex should be that key's index - 1 if (nIndex <= 0) return new double[,]{{(double)a_sorted.GetByIndex(0)}}; if (nIndex >= a_sorted.Count) return new double[,]{{(double)a_sorted.GetByIndex(a_sorted.Count-1)}}; double dTimeAtIndexBefore = (double)a_sorted.GetKey(nIndex-1); double dTimeAtIndexAfter = (double)a_sorted.GetKey(nIndex); if (a_dTime == dTimeAtIndexAfter) { /* if (nPos < nCnt) then nPos = nPos+1 fTimePosBefore = a_paList.getPropAt(nPos-1) fTimePosAfter = a_paList.getPropAt(nPos)*/ } double dVal1 = 0; double dVal2 = (double)a_sorted.GetValueList()[nIndex-1]; double dVal3 = (double)a_sorted.GetValueList()[nIndex]; double dVal4 = 0; //TODO: support commands in the list! //if (ilk(mvVal2) = #List) then mvVal2 = mvVal3 //if (ilk(mvVal3) = #List) then mvVal3 = mvVal2 if (nIndex == 1) dVal1 = dVal2; else dVal1 = (double)a_sorted.GetValueList()[nIndex-2]; //if (ilk(mvVal1) = #List) then mvVal1 = mvVal2 if (nIndex == a_sorted.Count-1) dVal4 = dVal3; else dVal4 = (double)a_sorted.GetValueList()[nIndex+1]; //TODO if (ilk(mvVal4) = #List) then mvVal4 = mvVal3 aReturn = new double[,] {{dVal1, 0}, {dVal2, dTimeAtIndexBefore}, {dVal3, dTimeAtIndexAfter}, {dVal4,0}}; return aReturn; }