protected void btnClose_Click(object sender, System.EventArgs e) { if ((lstAccounts.SelectedValue != null)&&(int.Parse(lstAccounts.SelectedValue) > 0)) { Top25Account account = new Top25Account(int.Parse(lstAccounts.SelectedValue)); string NotifyAction = "CLOSED"; Database data = new Database(); data.QueueNotification(account.EmployeeID, account.AccountID, account.AccountName, account.Month, NotifyAction); account.Close(); ClearForm(); BuildAccountsMenu(); BuildMoveMenu(); data.Close(); data.Dispose(); } else { lblMessage.Text = "You must select an account to delete."; lblMessage.Visible = true; return; } }
protected void btnSave_Click(object sender, System.EventArgs e) { Top25Account account; string NotifyAction = ""; if((lstAccounts.SelectedValue != "")&&(int.Parse(lstAccounts.SelectedValue) > 0)) { account = new Top25Account(int.Parse(lstAccounts.SelectedValue)); if(User.IsInRole(Database.EmployeeType.SalesManager.ToString())) { account.Status = AccountStatus.Approved; // managers can ony approve } else { if (account.Status == AccountStatus.Approved) { // if pending, or updated - status does not change account.Status = AccountStatus.Updated; // if approved, changes to updated NotifyAction = "UPDATED"; } } } else if (!User.IsInRole(Database.EmployeeType.SalesManager.ToString())) // managers can not create accounts { if (lstAccounts.Items.Contains(lstAccounts.Items.FindByText(txtAccountName.Text))) // if an account with this name already exists for this month, you can't add it { lblMessage.Text = "Account already exists for this month."; lblMessage.Visible = true; return; } else { account = new Top25Account(); account.EmployeeID = User.EmployeeID; account.Status = AccountStatus.Pending; NotifyAction = "CREATED"; } } else { return; } account.Month = ForecastMonth; account.AccountName = txtAccountName.Text; account.Contact = txtContact.Text; account.Phone = txtPhone.Text; if((txtLocations.Text != null)&&(txtLocations.Text != "")) { account.Locations = int.Parse(txtLocations.Text); } account.ClosedRMR = Utils.GetDecimal(txtClosedRMR.Text); account.ClosedRSS = Utils.GetDecimal(txtClosedRSS.Text); account.RMR_10 = Utils.GetDecimal(txtRMR_10.Text); account.RSS_10 = Utils.GetDecimal(txtRSS_10.Text); account.RMR_50 = Utils.GetDecimal(txtRMR_50.Text); account.RSS_50 = Utils.GetDecimal(txtRSS_50.Text); account.RMR_90 = Utils.GetDecimal(txtRMR_90.Text); account.RSS_90 = Utils.GetDecimal(txtRSS_90.Text); account.Save(); if (NotifyAction != "") { Database data = new Database(); data.QueueNotification(account.EmployeeID, account.AccountID, account.AccountName, account.Month, NotifyAction); notify.SendNotificationQueue(); data.Close(); data.Dispose(); } ClearForm(); BuildEmployeesMenu(); BuildAccountsMenu(); BuildMoveMenu(); LoadAccountInfo(); }