本文整理汇总了C#中System.Collections.SortedList.GetValueList方法的典型用法代码示例。如果您正苦于以下问题:C# SortedList.GetValueList方法的具体用法?C# SortedList.GetValueList怎么用?C# SortedList.GetValueList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.SortedList
的用法示例。
在下文中一共展示了SortedList.GetValueList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestGetKeyValueList
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");
}
示例2: BuildListFromEnum
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;
}
示例3: mostrarLista
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);
}
}
示例4: but_consultar_editorial_Click
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);
}
}
}
示例5: BuildListFromEnumByName
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;
}
示例6: but_consultar_libro_Click
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);
}
}
}
示例7: LoadCheckedListBox
///<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)
//.........这里部分代码省略.........
示例8: btnSearch_Click
//.........这里部分代码省略.........
{
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);
}
示例9: CreateGroupingTabs
/// <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);
//.........这里部分代码省略.........
示例10: CheckPatchesConsistent
/// <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;
}
示例11: TestGetValueListBasic
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);
//.........这里部分代码省略.........
示例12: but_eliminar_libro_Click
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);
//.........这里部分代码省略.........
示例13: mostrarLista
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);
}
}
示例14: but_eliminar_persona_Click
//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");
}
//.........这里部分代码省略.........
示例15: mostrarLista
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);
}
}