本文整理汇总了C#中Alert.AddSuccess方法的典型用法代码示例。如果您正苦于以下问题:C# Alert.AddSuccess方法的具体用法?C# Alert.AddSuccess怎么用?C# Alert.AddSuccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Alert
的用法示例。
在下文中一共展示了Alert.AddSuccess方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnSubmit_Click
protected void btnSubmit_Click(object sender, EventArgs e)
{
BrokenRulesDisplay.ResetBrokenRules();
Alert alert = new Alert(BrokenRulesDisplay);
bool canSave = true;
#region Error Checking
// Check if a stack is selected
if (lstSwitches.SelectedIndex < 0)
{
alert.AddError("Select Stack Error", "Both a device and a VLAN must be selected before saving the record.");
canSave = false;
}
// Check if the selected VoIP VLAN is used as a Native or Tagged on any interfaces
if (canSave && lstVLANs.SelectedIndex != 0)
{
string query = @"SELECT COUNT(*)
FROM InterfaceVLANs
WHERE VLANID = " + lstVLANs.SelectedValue;
int matches = int.Parse(Risque.Utility.SqlHelper.GetSingleSqlValue(query, sdsSwitches.ConnectionString));
if (matches != 0)
{
alert.AddError("In Use Error", "This VLAN is used elsewhere. A VoIP VLAN cannot be used as a tagged or native VLAN.");
canSave = false;
}
}
#endregion Error Checking
if (canSave)
{
// Get the Stack's properties.
DeviceManagementGroup dmg = DeviceManagementGroup.GetByIdentification(int.Parse(lstSwitches.SelectedValue));
// Assign the VoIP VLAN to the stack.
dmg.VoIPVLANID = lstVLANs.SelectedIndex != 0 ? (int?) int.Parse(lstVLANs.SelectedValue) : null;
// Update the VLAN to be a VoIP Vlan
if (lstVLANs.SelectedIndex != 0)
{
Vlan v = Vlan.GetByIdentification(int.Parse(lstVLANs.SelectedValue));
v.IsVoIP = true;
v.Save();
}
// Save settings & display success mesage.
dmg.Save();
alert.AddSuccess("Success", "Successfully associated device " + lstSwitches.SelectedItem + " with VLAN " + lstVLANs.SelectedItem + ".");
}
alert.ShowBrokenRules();
}
示例2: btnUpload_Click
//.........这里部分代码省略.........
}
}
// Create StreamReader
StreamReader sr = new StreamReader(csvFile);
try
{
if (valid)
{
int i = 0;
string line;
// Keep track of PICS to deduplicate
List<string> validPiCs = new List<string>();
// ENTER readline loop
while ((line = sr.ReadLine()) != null)
{
// check line
if (line.Equals(string.Empty) || i == 0)
{
i++;
continue;
}
String strpattern = "[0-9a-z,A-Z\t\v\r\n]";
if (!Regex.IsMatch(line, strpattern))
{
valid = false;
alert.AddError("Line invalid", "Line " + (i + 1) + " is invalid.");
continue;
}
//--Split the Line into an Array of Strings using Commas
string[] values = line.Split(Convert.ToChar(","));
//--Validate Line Numbers
String strlinepattern = "^[0-9]+$";
if (!Regex.IsMatch(values[0], strlinepattern))
{
valid = false;
alert.AddError("Invalid line number", "Line number at line " + i + " is invalid.");
}
//Run validation to ensure the line items are in the correct format
if (!CheckLine_csv(values, alert, validPiCs))
{
valid = false;
}
i++;
}
if (!validPiCs.Any())
{
valid = false;
alert.AddWarning("No Data", "There were no records in the bulk upload file to be processed.");
}
if (valid)
{
i = 0;
// Passed checkCSVLine Method -- So add to Line Items
csvFile.Seek(0, SeekOrigin.Begin); // Start at the beginning
while ((line = sr.ReadLine()) != null)
{
if (line.Equals(string.Empty) || i == 0)
{
i++;
continue;
}
//--Fix Excel Weirdness and smart single quotes and apostrophe--//
line = Regex.Replace(line, "[\u2018\u2019\u201A]", "'");
//--Smart double quotes
line = Regex.Replace(line, "[\u201C\u201D\u201E]", "\"");
//--Ellipsis
line = Regex.Replace(line, "[\u2026\uFFFD]", "...");
//--Split line into array using comma
string[] values = line.Split(Convert.ToChar(","));
//--Add to line items!
AddLine_csv(values);
i++;
}
} // END of Readline Loop
}
}
catch
{
valid = false;
alert.AddError("Critical error", "The file submitted includes a critical error and cannot be validated.");
}
finally
{
sr.Close(); //Close the stream reader
}
if (valid)
{
alert.AddSuccess("Success", "The items from the uploaded file have been added to this ticket successfully.");
}
//Bind The GridViews and Datatables
BindAmdLineItems();
BindRepairLineItems();
alert.ShowBrokenRules();
//Close the intial Stream
csvFile.Close();
}