Example #1
0
        public void LoadAccountInfo()
        {
            pnlAccountInfo.Visible = true;
            pnlButtons.Visible = true;
            pnlNamesMove.Visible = true;
            if ((lstAccounts.SelectedValue != null)&&(lstAccounts.SelectedValue != ""))
            {

                Top25Account account = new Top25Account(int.Parse(lstAccounts.SelectedValue));
                txtAccountName.Text = account.AccountName;
                txtContact.Text = account.Contact;
                txtPhone.Text = account.Phone;
                txtLocations.Text = account.Locations.ToString();
                txtClosedRMR.Text = account.ClosedRMR.ToString("0.##;-0.##;0");
                txtClosedRSS.Text = account.ClosedRSS.ToString("0.##;-0.##;0");
                txtRMR_10.Text = account.RMR_10.ToString("0.##;-0.##;0");
                txtRSS_10.Text = account.RSS_10.ToString("0.##;-0.##;0");
                txtRMR_50.Text = account.RMR_50.ToString("0.##;-0.##;0");
                txtRSS_50.Text = account.RSS_50.ToString("0.##;-0.##;0");
                txtRMR_90.Text = account.RMR_90.ToString("0.##;-0.##;0");
                txtRSS_90.Text = account.RSS_90.ToString("0.##;-0.##;0");
            }
            else
            {
                if(User.IsInRole(Database.EmployeeType.SalesManager.ToString()))
                {
                    // make account info invisible if sales manager
                    pnlAccountInfo.Visible = false;
                    pnlButtons.Visible = false;
                    pnlNamesMove.Visible = false;
                }
                else
                {
                    this.ClearForm();

                }
            }
        }
Example #2
0
        public int SaveAccount(Top25Account account)
        {
            string status = "";
            switch (account.Status)
            {
                case AccountStatus.Approved:
                    status = "A";
                    break;
                case AccountStatus.Pending:
                    status = "P";
                    break;
                case AccountStatus.Updated:
                    status = "U";
                    break;
            }

            SqlParameter[] prams = {this.MakeInParam("@intAccountID", SqlDbType.Int, 4, account.AccountID),
                                       this.MakeInParam("@intEmployeeID", SqlDbType.Int, 4, account.EmployeeID),
                                       this.MakeInParam("@dtmMonth", SqlDbType.DateTime, 8, account.Month),
                                       this.MakeInParam("@strAccountName", SqlDbType.VarChar, account.AccountName.Length, account.AccountName),
                                       this.MakeInParam("@strContact", SqlDbType.VarChar, account.Contact.Length, account.Contact),
                                       this.MakeInParam("@intLocations", SqlDbType.Int, 4, account.Locations),
                                       this.MakeInParam("@strPhone", SqlDbType.VarChar, account.Phone.Length, account.Phone),
                                       this.MakeInParam("@mnyClosedRMR", SqlDbType.Money, 8, account.ClosedRMR),
                                       this.MakeInParam("@mnyClosedRSS", SqlDbType.Money, 8, account.ClosedRSS),
                                       this.MakeInParam("@mnyRMR_10", SqlDbType.Money, 8, account.RMR_10),
                                       this.MakeInParam("@mnyRSS_10", SqlDbType.Money, 8, account.RSS_10),
                                       this.MakeInParam("@mnyRMR_50", SqlDbType.Money, 8, account.RMR_50),
                                       this.MakeInParam("@mnyRSS_50", SqlDbType.Money, 8, account.RSS_50),
                                       this.MakeInParam("@mnyRMR_90", SqlDbType.Money, 8, account.RMR_90),
                                       this.MakeInParam("@mnyRSS_90", SqlDbType.Money, 8, account.RSS_90),
                                       this.MakeInParam("@charStatus", SqlDbType.Char, 1, status),
                                       this.MakeOutParam("@intNewAccountID", SqlDbType.Int, 4)};

            this.RunProc("sp_SaveAccount", prams);

            return (int)prams[1].Value;
        }
Example #3
0
 public void DeleteAccount(Top25Account account)
 {
     SqlParameter[] prams = {this.MakeInParam("@intAccountID", SqlDbType.Int, 4, account.AccountID)};
     this.RunProc("sp_DeleteAccount", prams);
 }
Example #4
0
        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;
            }
        }
Example #5
0
        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();
        }
Example #6
0
 protected void btnMove_Click(object sender, System.EventArgs e)
 {
     if((lstAccounts.SelectedValue != "")&&(int.Parse(lstAccounts.SelectedValue) > 0)
         &&(lstMoveTo.SelectedValue != ""))
     {
         Top25Account account = new Top25Account(int.Parse(lstAccounts.SelectedValue));
         account.Month = Convert.ToDateTime(lstMoveTo.SelectedValue);
         account.Save();
         ClearForm();
         BuildAccountsMenu();
         LoadAccountInfo();
     }
 }