本文整理汇总了C#中Alert.ShowBrokenRules方法的典型用法代码示例。如果您正苦于以下问题:C# Alert.ShowBrokenRules方法的具体用法?C# Alert.ShowBrokenRules怎么用?C# Alert.ShowBrokenRules使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Alert
的用法示例。
在下文中一共展示了Alert.ShowBrokenRules方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: lstSwitches_SelectedIndexChanged
protected void lstSwitches_SelectedIndexChanged(object sender, EventArgs e)
{
//This code will autoselect a VoIP Vlan in the drop down if a relation exsists. Select nothing if not.
BrokenRulesDisplay.ResetBrokenRules();
Alert alert = new Alert(BrokenRulesDisplay);
// Get the Stack's properties
DeviceManagementGroup dmg = DeviceManagementGroup.GetByIdentification(int.Parse(lstSwitches.SelectedValue));
// If the Stack has a VoIP VLAN, select it from the DDL.
if (dmg.VoIPVLANID != null)
{
lstVLANs.SelectedValue = dmg.VoIPVLANID.ToString();
}
else
{
//send out a message letting them know that there is no connection.
alert.AddWarning("Connection", @"No VoIP VLAN currently associated with selected switch.");
alert.ShowBrokenRules();
lstVLANs.SelectedIndex = 0;
}
}
示例3: chkItemEdit_CheckedChanged
//.........这里部分代码省略.........
alert.AddError("Bad Fund", "Fund must be a valid 8-digit number.");
}
if (txtAcct2.Text.Trim().Length != 10 || !long.TryParse(txtAcct2.Text.Trim(), out validator) ||
!LineItem.VerifyNumber("COST", txtAcct2.Text.Trim()))
{
error = true;
alert.AddError("Bad Cost Center", "Cost Center must be a valid 10-digit number.");
}
if ((txtAcct3.Text.Trim().Length != 0 && txtAcct3.Text.Trim().Length != 10) ||
(txtAcct3.Text.Trim().Length != 0 && !long.TryParse(txtAcct3.Text.Trim(), out validator)))
{
error = true;
alert.AddError("Bad SIO", "SIO must be a 10-digit number.");
}
}
else if (ddlAccountType.SelectedValue == "2")
{
// real order
long validator;
if (txtAcct1.Text.Trim().Length != 8 || !long.TryParse(txtAcct1.Text.Trim(), out validator) ||
!LineItem.VerifyNumber("FUND", txtAcct1.Text.Trim()))
{
error = true;
alert.AddError("Bad Fund", "Fund must be a valid 8-digit number.");
}
if (txtAcct2.Text.Trim().Length != 10 || !long.TryParse(txtAcct2.Text.Trim(), out validator) ||
!LineItem.VerifyNumber("ORDER", txtAcct2.Text.Trim()))
{
error = true;
alert.AddError("Bad Real Order", "Real Order must be a valid 10-digit number.");
}
}
else if (ddlAccountType.SelectedValue == "3")
{
// wbs element
long validator;
var match = Regex.Match(txtAcct1.Text, @"\bC[.][0-9][0-9][.][0-9][0-9][0-9][0-9][0-9]\b");
if (txtAcct1.Text.Trim().Length != 10 || !match.Success ||
!LineItem.VerifyNumber("WBS", txtAcct1.Text.Trim().Replace(".", string.Empty)))
{
error = true;
alert.AddError("Bad WBS", "WBS must be a valid 7-digit number.");
}
if ((txtAcct2.Text.Trim().Length != 0 && txtAcct2.Text.Trim().Length != 10) ||
(txtAcct2.Text.Trim().Length != 0 && !long.TryParse(txtAcct2.Text.Trim(), out validator)))
{
error = true;
alert.AddError("Bad SIO", "SIO must be a 10-digit number.");
}
}
else if (ddlAccountType.SelectedValue == "4")
{
// business partner number
long validator;
if (txtAcct1.Text.Trim().Length != 7 || !txtAcct1.Text.Trim().StartsWith("3") ||
!long.TryParse(txtAcct1.Text.Trim(), out validator))
{
error = true;
alert.AddError("Bad BPN",
"Business Partner Number must be a 7-digit number starting with '3'.");
}
}
if (!error) // Save the account numbers now.
{
// check if any changes were made. if not, we shouldn't bother saving as that would also overwrite the billing plan (maybe someone decided that needed to be changed)
if (line.AccountTypeID == int.Parse(ddlAccountType.SelectedValue) && (line.AccountNumber1 == txtAcct1.Text.Trim() ||
(line.AccountNumber1 == null && txtAcct1.Text.Trim() == string.Empty)) &&
(line.AccountNumber2 == txtAcct2.Text.Trim() ||
(line.AccountNumber2 == null && txtAcct2.Text.Trim() == string.Empty)) &&
(line.AccountNumber3 == txtAcct3.Text.Trim() ||
(line.AccountNumber3 == null && txtAcct3.Text.Trim() == string.Empty)))
return;
line.AccountTypeID = int.Parse(ddlAccountType.SelectedValue);
line.AccountNumber1 = txtAcct1.Text.Trim();
line.AccountNumber2 = txtAcct2.Text.Trim() != string.Empty ? txtAcct2.Text.Trim() : null;
line.AccountNumber3 = txtAcct3.Text.Trim() != string.Empty ? txtAcct3.Text.Trim() : null;
// Set Billing Plan
LineItem.SetBilling(line);
// Save
ticket.Save();
// Update Labels
updateLiteral_Account(line, litAccountNumbers);
}
else
{
alert.AddWarning("Not saved",
"Account Number changes for the line " + line.Picid +
" were not saved due to errors. Other settings were saved successfully. Please try again using valid information.");
scrollTop();
alert.ShowBrokenRules();
}
}
}
}
示例4: btnEditDueBy_Click
// -- Save Edit Due By Date -- For Ticket Admins ONLY
protected void btnEditDueBy_Click(object sender, EventArgs e)
{
var ticket = getTicket(); // Grab current Ticket Info
showModal_EditDueBy.Value = "true"; // Show Modal
var errorChkModal = new Alert(BrokenRulesDisplayEditDueBy);
BrokenRulesDisplayEditDueBy.ResetBrokenRules(); // Reset Broken Rules
var isValid = true;
if (txtEditDueDate.Text.Trim() == string.Empty) //A date must be entered
{
errorChkModal.AddError("0", "Please enter a date.");
isValid = false;
}
if (txtEditDueTime.Text.Trim() == string.Empty) //A time must be entered
{
errorChkModal.AddError("1", "Please enter a time.");
isValid = false;
}
if ((txtEditDueTime.Text.Trim() != string.Empty || txtEditDueDate.Text.Trim() != string.Empty) &&
DateTime.Parse(txtEditDueDate.Text + ' ' + txtEditDueTime.Text) < DateTime.Now)
{
errorChkModal.AddError("2", "Date and time can not be before " + DateTime.Now + ".");
isValid = false;
}
if (isValid == false)
{
//Set Values to default
var dueDateValues = lblTicketDue.Text.Split(' ');
txtEditDueDate.Text = dueDateValues[0];
txtEditDueTime.Text = dueDateValues[1] + ' ' + dueDateValues[2];
errorChkModal.ShowBrokenRules();
return;
}
if (isValid) // Update new Date/Time
{
var newDueDate = DateTime.Parse(txtEditDueDate.Text + ' ' + txtEditDueTime.Text);
ticket.DueDate = newDueDate;
if (rdoNewDueDateScheduled_YES.Checked)
{
ticket.ScheduledDate = newDueDate;
ticket.PriorityID = 3;
}
else
{
ticket.ScheduledDate = null;
ticket.PriorityID = 1;
}
ticket = ticket.Save();
lblTicketDue.Text = ticket.ScheduledDate == null
? (ticket.DueDate == null ? "N/A" : ((DateTime)ticket.DueDate).ToString("M/d/yyyy h:mm tt"))
: ((DateTime)ticket.ScheduledDate).ToString("M/d/yyyy h:mm tt") + " (s)";
UpdatePriorityLabel(ticket);
showModal_EditDueBy.Value = "false";
}
}
示例5: btnSave_Click
//.........这里部分代码省略.........
intrface.AccountFundCenter = null;
intrface.AccountBusinessPartner = null;
intrface.InterfaceSpeedID = null;
intrface.Save();
break;
}
case 4: // Repair
//No Changes to Billing
break;
default:
continue;
}
}
//If the Billing is Standard ticket goes straight to complete
if (changeToStandard)
{
ticket.StatusID = 5;
ticket.EffectiveDate = DateTime.Now;
}
else if (isStandard)
{
ticket.StatusID = 6;
ticket.EffectiveDate = DateTime.Now;
}
else
{
ticket.StatusID = 5;
ticket.EffectiveDate = DateTime.Now;
}
}
// Save
ticket = ticket.Save();
createdTickets.Add(ticket.Identification);
// Add to Building Outage Notification List
AddToLocationContacts(int.Parse(rowLocationId.Value));
//--- Send Email ---//
TicketsBusiness.Utility.TicketsMailer.SendMail_CreateTicket(ticket, RisqueContext.CurrentUser);
}
}
// Iterate through repair line items if they exist
foreach (DataRow repair in RepairLineItems.Rows)
{ // Ticket for Repair
Ticket ticket = Ticket.NewTicket();
// populate contact data and status
PopulateTicketGeneralData(ticket);
// set as rush priority
ticket.PriorityID = 2;
// add line item
LineItem lineItemPic = ticket.LineItems.AddNew();
// populate data from datatable
lineItemPic.ActionID = (int)repair["ActionID"];
lineItemPic.Picid = repair["PICID"].ToString();
lineItemPic.InterfaceID = (int)repair["InterfaceID"];
lineItemPic.RepairNotes = repair["RepairNotes"].ToString();
// Populate Current Settings to PIC
AddCurrentSettingsToLine(lineItemPic);
// Add Current VLANs
LineItemVLAN.SaveCurrentNativeVlan(Interface.GetByIdentification(lineItemPic.InterfaceID), lineItemPic);
LineItemVLAN.SaveCurrentTaggedVlans(Interface.GetByIdentification(lineItemPic.InterfaceID), lineItemPic);
// Save Repair Notes - To the comments gridview
Comment comment = ticket.Comments.AddNew();
comment.ClientName = RisqueContext.CurrentUser.FullName;
comment.IsInternal = false;
comment.Text = repair["RepairNotes"].ToString();
// Finalize Ticket
ticket = ticket.Save();
createdTickets.Add(ticket.Identification);
//-- add to building outage notification list
AddToLocationContacts(Interface.GetByIdentification(lineItemPic.InterfaceID).Device.Room.LocationID);
//-- send email
TicketsBusiness.Utility.TicketsMailer.SendMail_CreateTicket(ticket, RisqueContext.CurrentUser);
}
var ids = string.Empty;
foreach (int id in createdTickets)
ids += id + ",";
if (createdTickets.Count > 0)
ids = ids.Substring(0, ids.Length - 1);
Response.Redirect("ViewTickets.aspx?created=" + ids, false);
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
else
{
ScrollTop();
alert.ShowBrokenRules();
}
}
示例6: VerifyAddLine
//-- Validate User Input and Values
private bool VerifyAddLine(TicketsBusiness.Action action)
{
// verify data was entered properly
bool canSave = true;
Alert alert = new Alert(AddLineBrokenRules);
if (action.Identification == 1 || action.Identification == 2)
{
// activate / modify rules
// speed is required
if (ddlSpeed.SelectedIndex == 0)
{
canSave = false;
alert.AddError("No Speed", "Speed is a required field.");
}
// at least one vlan is required
if (ddlVLAN.SelectedIndex == 0)
{
canSave = false;
alert.AddError("No VLAN", "VLAN is a required field.");
}
if (pnlTrunk.Visible)
{
bool dupeVlan = false;
foreach (ListItem vlan in lstVLAN.Items)
{
if (vlan.Selected)
{
if (ddlVLAN.SelectedIndex > 0 && vlan.Value == ddlVLAN.SelectedValue)
{
dupeVlan = true;
break;
}
}
}
if (dupeVlan)
{
canSave = false;
alert.AddError("Duplicate VLAN", "The Native VLAN selected cannot also be selected as a Tagged VLAN. Please ensure all VLAN selections are unique.");
}
}
// valid account info is required
if (ddlAccountType.SelectedIndex == 0)
{
canSave = false;
alert.AddError("No AccountType", "Account Type is a required field.");
}
else
{
if (AcctValidation(alert) == false)
{
canSave = false;
}
}
}
if (!canSave)
alert.ShowBrokenRules();
return canSave;
}
示例7: AcctValidation
// Billing and Text Box Rule Validation and Bulk Upload Validation
protected bool AcctValidation(Alert alert)
{
bool canSave = true;
// Verify Account Info
switch (ddlAccountType.SelectedValue)
{
case "1": // Cost Center
{
long validator;
if (txtFund.Text.Trim().Length != 8 || !long.TryParse(txtFund.Text.Trim(), out validator) || !LineItem.VerifyNumber("FUND", txtFund.Text.Trim()))
{
canSave = false;
alert.AddError("Bad Fund", "Fund must be a valid 8-digit number.");
}
if (txtCostCenter.Text.Trim().Length != 10 || !long.TryParse(txtCostCenter.Text.Trim(), out validator) || !LineItem.VerifyNumber("COST", txtCostCenter.Text.Trim()))
{
canSave = false;
alert.AddError("Bad Cost Center", "Cost Center must be a valid 10-digit number.");
}
if ((txtSIO.Text.Trim().Length != 0 && txtSIO.Text.Trim().Length != 10) || (txtSIO.Text.Trim().Length != 0 && !long.TryParse(txtSIO.Text.Trim(), out validator)))
{
canSave = false;
alert.AddError("Bad SIO", "SIO must be a 10-digit number.");
}
break;
}
case "2": // Real Order
{
long validator;
if (txtFund.Text.Trim().Length != 8 || !long.TryParse(txtFund.Text.Trim(), out validator) || !LineItem.VerifyNumber("FUND", txtFund.Text.Trim()))
{
canSave = false;
alert.AddError("Bad Fund", "Fund must be a valid 8-digit number.");
}
if (txtRealOrder.Text.Trim().Length != 10 || !long.TryParse(txtRealOrder.Text.Trim(), out validator) || !LineItem.VerifyNumber("ORDER", txtRealOrder.Text.Trim()))
{
canSave = false;
alert.AddError("Bad Real Order", "Real Order must be a valid 10-digit number.");
}
break;
}
case "3": // WBS Element
{
long validator;
Match match = Regex.Match(txtWBS.Text, @"\bC[.][0-9][0-9][.][0-9][0-9][0-9][0-9][0-9]\b");
if (txtWBS.Text.Trim().Length != 10 || !match.Success || !LineItem.VerifyNumber("WBS", txtWBS.Text.Trim().Replace(".", string.Empty)))
{
canSave = false;
alert.AddError("Bad WBS", "WBS must be a valid 7-digit number.");
}
if ((txtSIO.Text.Trim().Length != 0 && txtSIO.Text.Trim().Length != 10) || (txtSIO.Text.Trim().Length != 0 && !long.TryParse(txtSIO.Text.Trim(), out validator)))
{
canSave = false;
alert.AddError("Bad SIO", "SIO must be a 10-digit number.");
}
break;
}
case "4": // Business Partner Number
{
long validator;
if (txtBPN.Text.Trim().Length != 7 || !txtBPN.Text.Trim().StartsWith("3") || !long.TryParse(txtBPN.Text.Trim(), out validator))
{
canSave = false;
alert.AddError("Bad BPN", "Business Partner Number must be a 7-digit number starting with '3'.");
}
break;
}
default:
{
canSave = false;
alert.AddWarning("No Account", "Select an Account Type");
break;
}
}
if (canSave == false) // Send back to user to fix Account Errors
{
alert.ShowBrokenRules();
return false;
}
else
return true;
}
示例8: 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();
}