/// <summary>
        /// Sets the User's location and access based on what is stored in the database.  See UtilityCashFlow
        /// </summary>
        protected void SetUpUser()
        {
            this.isAdminUser = utility.GetIsAdminUser();
            this.isCMUser    = utility.GetIsCMUser();
            this.isDeptUser  = utility.GetIsDeptUser();
            this.location    = utility.GetLocation();
            this.department  = utility.GetDepartment();

            if (!this.isAdminUser && !this.isCMUser && !this.isDeptUser)
            {
                Response.Redirect(VariablesCashManager.NO_ACCESS_PAGE);
            }

            if (isDeptUser)
            {
                LabelCMPriority.Visible           = false;
                RadioButtonListCMPriority.Visible = false;

                if (this.location.Equals("All"))
                {
                    RadioButtonListLocation.Visible = true;
                    LabelLocation.Visible           = true;
                }
                else if (this.location.Equals("2"))
                {
                    RadioButtonListLocation.Visible = true;
                    LabelLocation.Visible           = true;
                    RadioButtonListLocation.Items.FindByValue("All").Attributes.Add("Style", "display: none");
                    RadioButtonListLocation.Items.FindByValue("1").Attributes.Add("Style", "display: none");
                }
                else
                {
                    LabelLocation.Visible           = false;
                    RadioButtonListLocation.Visible = false;
                }

                LabelPayFlag.Visible           = false;
                RadioButtonListPayFlag.Visible = false;

                LabelPaymentMethod.Visible           = false;
                RadioButtonListPaymentMethod.Visible = false;

                LabelDepartments.Visible       = false;
                CheckBoxDepartmentsAll.Visible = false;
            }

            if (isAdminUser || isCMUser)
            {
                RadioButtonListLocation.Visible = true;
                LabelLocation.Visible           = true;
            }
        }
Пример #2
0
        String userName   = ""; ///<network ID of user

        protected void Page_Load(object sender, EventArgs e)
        {
            this.userName = Page.User.Identity.Name.ToString().Substring(8);
            UtilityCashFlow utility = new UtilityCashFlow(this.userName);

            if (!utility.GetIsAdminUser() && !utility.GetIsCMUser())
            {
                Response.Redirect(VariablesCashManager.NO_ACCESS_PAGE);
            }

            if (!Page.IsPostBack)
            {
                PopulateOfficeLocations();
            }
        }
Пример #3
0
        String userName = ""; ///<network ID of user

        protected void Page_Load(object sender, EventArgs e)
        {
            this.userName = Page.User.Identity.Name.ToString().Substring(8);
            UtilityCashFlow utility = new UtilityCashFlow(this.userName);

            if (!utility.GetIsAdminUser() && !utility.GetIsCMUser())
            {
                Response.Redirect(VariablesCashManager.NO_ACCESS_PAGE);
            }
            
            if (!Page.IsPostBack)
            {
                PopulateOfficeLocations();
            }

        }
Пример #4
0
        String userName = ""; ///<network ID of user

        protected void Page_Load(object sender, EventArgs e)
        {
            this.userName = Page.User.Identity.Name.ToString().Substring(8);
            //this.userName = "******";
            UtilityCashFlow utility = new UtilityCashFlow(this.userName);

            if (!utility.GetIsAdminUser() && !utility.GetIsCMUser())
            {
                Response.Redirect(VariablesCashManager.NO_ACCESS_PAGE);
            }

            if (!Page.IsPostBack)
            {
                LabelMessage.Text = "";
                GetAmountToPay();
            }
        }
        String userName = ""; ///<network ID of user

        protected void Page_Load(object sender, EventArgs e)
        {
            this.userName = Page.User.Identity.Name.ToString().Substring(8);
            //this.userName = "******";
            UtilityCashFlow utility = new UtilityCashFlow(this.userName);

            if ( !utility.GetIsAdminUser() && !utility.GetIsCMUser() )
            {
                Response.Redirect(VariablesCashManager.NO_ACCESS_PAGE);
            }

            if (!Page.IsPostBack)
            {
                LabelMessage.Text = "";
                GetAmountToPay();
            }

        }
         protected void Page_Load(object sender, EventArgs e)
        {
            Page.MaintainScrollPositionOnPostBack = true;
            String userName = Page.User.Identity.Name.ToString().Substring(8); 
            //userName = "******";

            utility = new UtilityCashFlow(userName);

            SetUpUser();

            int totalRows = 0;

            if (Request["loc"] != null)
            {
                utility.SetLocation(Request["loc"].ToString());
            }
            if (Request["dept"] != null)
            {
                utility.SetDepartment(Request["dept"].ToString());
            }

            try
            {
                totalRows = dataGridView.Rows.Count;
            }
            catch (SqlException sqle)
            {
                Logger.QuickLog(errorLogFileName, sqle.Message, "Page_Load()", "int totalRows = dataGridView.Rows.Count");
            }

            if (utility.GetIsDeptUser())
            {
                data.Attributes.Add("class", "cashManagerData cashManagerDataDept");
                options.Attributes.Add("class", "optionsCashManagerDeptUser");
            }
            else if (utility.GetIsCMUser())
            {
                data.Attributes.Add("class", "cashManagerData cashManagerDataCM");
                options.Attributes.Add("class", "optionsCashManagerCMUser");
            }
            else
            {
                data.Attributes.Add("class", "cashManagerData cashManagerDataAdmin");
                options.Attributes.Add("class", "optionsCashManagerAdminUser");
            }
            utility.SetRowChanged(totalRows);
            
            hasPagerRow.Value = "false";

            //Set Tool Tips
            buttonSave.Attributes.Add("onmouseover", "Tip('" + VariablesCashManager.TOOLTIP_SAVE_BUTTON + "')");
            buttonSave.Attributes.Add("onmouseout", "UnTip()");
            exitButton.Attributes.Add("onmouseout", "UnTip()");

            if (utility.GetIsAdminUser() || utility.GetIsCMUser())
            {
                AmountSelectedHidden.Value = Convert.ToString(GetTotalChecked());
                if (Session["amountToPay"] != null)
                {
                    AmountToPay.Value = Session["amountToPay"].ToString();
                }
                else
                {
                    AmountToPay.Value = "0";
                }
            }
            else
            {
                divTotalToPay.Visible = false;
                buttonAdminOptions.Visible = false;
            }

            LabelCurrentPage.Text = "Page " + Convert.ToString(dataGridView.PageIndex + 1) + " of " + dataGridView.PageCount;

            if (!Page.IsPostBack)
            {
                LogUserAccess();
            }

        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.MaintainScrollPositionOnPostBack = true;
            String userName = Page.User.Identity.Name.ToString().Substring(8);

            //userName = "******";

            utility = new UtilityCashFlow(userName);

            SetUpUser();

            int totalRows = 0;

            if (Request["loc"] != null)
            {
                utility.SetLocation(Request["loc"].ToString());
            }
            if (Request["dept"] != null)
            {
                utility.SetDepartment(Request["dept"].ToString());
            }

            try
            {
                totalRows = dataGridView.Rows.Count;
            }
            catch (SqlException sqle)
            {
                Logger.QuickLog(errorLogFileName, sqle.Message, "Page_Load()", "int totalRows = dataGridView.Rows.Count");
            }

            if (utility.GetIsDeptUser())
            {
                data.Attributes.Add("class", "cashManagerData cashManagerDataDept");
                options.Attributes.Add("class", "optionsCashManagerDeptUser");
            }
            else if (utility.GetIsCMUser())
            {
                data.Attributes.Add("class", "cashManagerData cashManagerDataCM");
                options.Attributes.Add("class", "optionsCashManagerCMUser");
            }
            else
            {
                data.Attributes.Add("class", "cashManagerData cashManagerDataAdmin");
                options.Attributes.Add("class", "optionsCashManagerAdminUser");
            }
            utility.SetRowChanged(totalRows);

            hasPagerRow.Value = "false";

            //Set Tool Tips
            buttonSave.Attributes.Add("onmouseover", "Tip('" + VariablesCashManager.TOOLTIP_SAVE_BUTTON + "')");
            buttonSave.Attributes.Add("onmouseout", "UnTip()");
            exitButton.Attributes.Add("onmouseout", "UnTip()");

            if (utility.GetIsAdminUser() || utility.GetIsCMUser())
            {
                AmountSelectedHidden.Value = Convert.ToString(GetTotalChecked());
                if (Session["amountToPay"] != null)
                {
                    AmountToPay.Value = Session["amountToPay"].ToString();
                }
                else
                {
                    AmountToPay.Value = "0";
                }
            }
            else
            {
                divTotalToPay.Visible      = false;
                buttonAdminOptions.Visible = false;
            }

            LabelCurrentPage.Text = "Page " + Convert.ToString(dataGridView.PageIndex + 1) + " of " + dataGridView.PageCount;

            if (!Page.IsPostBack)
            {
                LogUserAccess();
            }
        }
        /// <summary>
        /// Called before the page is rendered.  This is used for the save functionality.
        /// See Code for SQL - this is a large dynamic sql that is built using C#.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_PreRender(object sender, EventArgs e)
        {
            String messageOutput = "";
            bool   updateMessage = false;

            if (Page.IsPostBack)
            {
                String sessionResetCookie = "false";
                if (Session["resetCookie"] != null)
                {
                    sessionResetCookie = Session["resetCookie"].ToString();
                }

                if (sessionResetCookie.Equals("true"))
                {
                    Session["resetCookie"] = "false";
                }

                int totalRows = dataGridView.Rows.Count;

                for (int r = 0; r < totalRows; r++)
                {
                    if (utility.GetRowChanged()[r])
                    {
                        updateMessage = true;

                        GridViewRow thisGridViewRow = dataGridView.Rows[r];

                        String  barcode       = "";
                        String  source        = "";
                        String  invoiceNumber = "";
                        String  invoiceDate   = "";
                        String  vendorNumber  = "";
                        int     payFlag       = 0;
                        decimal amount        = 0;
                        //String cmPriority = "4";
                        //String deptPriority = "4";
                        String cmPriority       = "2";
                        String deptPriority     = "2";
                        String cmNotes          = "";
                        String deptNotes        = "";
                        String payMethod        = "";
                        String updateTimeAtLoad = "";

                        try
                        {
                            barcode          = thisGridViewRow.Cells[columnBarcode].Text == "-" ? "-1" : thisGridViewRow.Cells[columnBarcode].Text;
                            source           = thisGridViewRow.Cells[columnSource].Text;
                            invoiceNumber    = thisGridViewRow.Cells[columnInvoiceNumberHidden].Text.Replace("'", "''").Replace("&nbsp;", "");
                            invoiceDate      = thisGridViewRow.Cells[columnInvoiceDateHidden].Text;
                            vendorNumber     = thisGridViewRow.Cells[columnVendorIdHidden].Text;
                            payFlag          = ((CheckBox)thisGridViewRow.FindControl("review1CB")).Checked == true ? 1 : 0;
                            updateTimeAtLoad = thisGridViewRow.Cells[columnUpdateTimeHidden].Text;

                            try
                            {
                                amount = Convert.ToDecimal(thisGridViewRow.Cells[columnAmountHidden].Text);
                            }
                            catch (FormatException fe)
                            {
                                Logger.QuickLog(VariablesCashManager.ERROR_LOG_FILE_NAME, "Page_PreRender()", fe.Message, "converting amount from text to decimal: " + thisGridViewRow.Cells[columnAmountHidden].Text);
                            }
                            if (utility.GetIsDeptUser())
                            {
                                cmPriority = thisGridViewRow.Cells[columnPriorityCMHidden].Text;
                                payMethod  = thisGridViewRow.Cells[columnPaymentMethodHidden].Text.Replace("&nbsp;", "");
                            }
                            else
                            {
                                cmPriority = ((RadioButtonList)thisGridViewRow.FindControl("cmPriorityRadioButtonList")).SelectedValue;
                                payMethod  = ((DropDownList)thisGridViewRow.FindControl("DropDownListPayMthd")).SelectedValue;
                            }
                            if (utility.GetIsCMUser())
                            {
                                deptPriority = thisGridViewRow.Cells[columnPriorityDeptHidden].Text == "-1" ? "null" : thisGridViewRow.Cells[columnPriorityDeptHidden].Text;
                            }
                            else
                            {
                                deptPriority = ((RadioButtonList)thisGridViewRow.FindControl("deptPriorityRadioButtonList")).SelectedValue;
                            }
                            cmNotes   = ((TextBox)thisGridViewRow.FindControl("cmNotesTB")).Text.Replace("'", "''");
                            deptNotes = ((TextBox)thisGridViewRow.FindControl("deptNotesTB")).Text.Replace("'", "''");
                        }
                        catch (FormatException)
                        {
                            //this is to catch when set to a nonNumber
                            //non numbers are converted to zero
                        }
                        catch (ArgumentOutOfRangeException ae)
                        {
                            //when using paging
                            Logger.QuickLog(errorLogFileName, ae.Message, "Page_PreRender()", "");
                        }

                        SqlConnection con = null;


                        String sqlDateCheck = " SELECT case when updateTime > '" + updateTimeAtLoad + "' then 0 else 1 end as okToSave "
                                              + " FROM BMcBEARCashFlowManager "
                                              + " WHERE barcode = " + barcode
                                              + " AND dataSource = '" + source + "' "
                                              + " AND invoiceNumber = '" + invoiceNumber + "' "
                                              + " AND invoiceDate = '" + invoiceDate + "' "
                                              + " AND vendorNumber = '" + vendorNumber + "' "
                                              + " AND amount = " + amount;


                        String sqlArchive = " INSERT INTO dbo.BMcBEARCashFlowManagerArchive "
                                            + " SELECT ID "
                                            + " ,barcode "
                                            + " ,dataSource "
                                            + " ,invoiceNumber "
                                            + " ,invoiceDate "
                                            + " ,vendorNumber "
                                            + " ,payFlag "
                                            + " ,amount "
                                            + " ,priorityCM "
                                            + " ,priorityDept"
                                            + " ,notesCM "
                                            + " ,notesDept "
                                            + " ,paymentMethod "
                                            + " ,updatedBy "
                                            + " ,updateTime "
                                            + " FROM dbo.BMcBEARCashFlowManager (nolock)"
                                            + " WHERE barcode = " + barcode
                                            + " AND dataSource = '" + source + "' "
                                            + " AND invoiceNumber = '" + invoiceNumber + "' "
                                            + " AND invoiceDate = '" + invoiceDate + "' "
                                            + " AND vendorNumber = '" + vendorNumber + "' "
                                            + " AND amount = " + amount;

                        String sqlSelectCount = " SELECT count(*) as count "
                                                + " FROM dbo.BMcBEARCashFlowManager (nolock) "
                                                + " WHERE barcode = " + barcode
                                                + " AND dataSource = '" + source + "' "
                                                + " AND invoiceNumber = '" + invoiceNumber + "' "
                                                + " AND invoiceDate = '" + invoiceDate + "' "
                                                + " AND vendorNumber = '" + vendorNumber + "' "
                                                + " AND amount = " + amount;

                        String sqlUpdate = " UPDATE BMcBEARCashFlowManager "
                                           + " SET updatedBy = '" + utility.GetUserName() + "' "
                                           + " , updateTime = '" + DateTime.Now + "' ";
                        if (!utility.GetIsDeptUser())
                        {
                            sqlUpdate = sqlUpdate
                                        + " , payFlag = " + payFlag
                                        + " , paymentMethod = '" + payMethod + "' "
                                        + " , notesCM = '" + cmNotes + "' "
                                        + " , priorityCM = " + cmPriority;
                        }
                        if (!utility.GetIsCMUser())
                        {
                            sqlUpdate = sqlUpdate
                                        + " , priorityDept = " + deptPriority
                                        + " , notesDept = '" + deptNotes + "' ";
                        }
                        sqlUpdate = sqlUpdate
                                    + " WHERE barcode = " + barcode
                                    + " AND dataSource = '" + source + "' "
                                    + " AND invoiceNumber = '" + invoiceNumber + "' "
                                    + " AND invoiceDate = '" + invoiceDate + "' "
                                    + " AND vendorNumber = '" + vendorNumber + "' "
                                    + " AND amount = " + amount;

                        String sqlInsert = " INSERT INTO dbo.BMcBEARCashFlowManager ( "
                                           + " barcode, dataSource, invoiceNumber, invoiceDate, vendorNumber, "
                                           + " payFlag, amount, priorityCM, priorityDept, notesCM, notesDept, "
                                           + " paymentMethod, updatedBy, updateTime "
                                           + " ) VALUES ( "
                                           + barcode
                                           + ", '" + source + "' "
                                           + ", '" + invoiceNumber + "' "
                                           + ", '" + invoiceDate + "' "
                                           + ", '" + vendorNumber + "' "
                                           + ", " + payFlag
                                           + ", " + amount;

                        if (cmPriority.Equals("-1"))
                        {
                            sqlInsert = sqlInsert
                                        + ", NULL ";
                        }
                        else
                        {
                            sqlInsert = sqlInsert
                                        + ", " + cmPriority;
                        }
                        sqlInsert = sqlInsert
                                    + ", " + deptPriority
                                    + ", '" + cmNotes + "' "
                                    + ", '" + deptNotes + "' "
                                    + ", '" + payMethod + "' "
                                    + ", '" + utility.GetUserName() + "' "
                                    + ", '" + DateTime.Now + "' "
                                    + " ) ";

                        try
                        {
                            con = new SqlConnection(
                                ConfigurationManager.ConnectionStrings["eliteConnectionString"].ConnectionString);
                            con.Open();
                            SqlCommand command = con.CreateCommand();
                            command.CommandType = CommandType.Text;
                            command.CommandText = sqlArchive;
                            command.ExecuteNonQuery();
                            int recordCount = 0;
                            try
                            {
                                command.CommandText = sqlSelectCount;
                                SqlDataReader readerCount = command.ExecuteReader();
                                if (readerCount.Read())
                                {
                                    recordCount = Convert.ToInt16(readerCount["count"].ToString());
                                }
                                readerCount.Close();
                            }
                            catch (SqlException sqleSelectCount)
                            {
                                Logger.QuickLog(errorLogFileName, sqleSelectCount.Message, "Page_PreRender()", sqlSelectCount);
                            }
                            catch (Exception)
                            {
                            }

                            if (recordCount > 0)
                            {
                                int okToSave = 0;
                                try
                                {
                                    command.CommandText = sqlDateCheck;
                                    SqlDataReader reader = command.ExecuteReader();
                                    if (reader.Read())
                                    {
                                        okToSave = Convert.ToInt16(reader["okToSave"].ToString());
                                    }
                                    reader.Close();
                                }
                                catch (SqlException sqleDateCheck)
                                {
                                    Logger.QuickLog(errorLogFileName, sqleDateCheck.Message, "PagePreRender()", sqlDateCheck);
                                }
                                if (okToSave == 1)
                                {
                                    try
                                    {
                                        command.CommandText = sqlUpdate;
                                        command.ExecuteNonQuery();
                                    }
                                    catch (SqlException sqleUpdate)
                                    {
                                        Logger.QuickLog(errorLogFileName, sqleUpdate.Message, "Page_PreRender()", sqlUpdate);
                                    }
                                }
                                else
                                {
                                    if (messageOutput.Equals(""))
                                    {
                                        messageOutput = "Barcode(s): " + barcode;
                                    }
                                    else
                                    {
                                        messageOutput = messageOutput + ", " + barcode;
                                    }
                                }
                            }
                            else
                            {
                                try
                                {
                                    command.CommandText = sqlInsert;
                                    command.ExecuteNonQuery();
                                }
                                catch (SqlException sqleInsert)
                                {
                                    Logger.QuickLog(errorLogFileName, sqleInsert.Message, "Page_PreRender()", sqlInsert);
                                }
                            }
                        }
                        catch (SqlException sqleArchive)
                        {
                            Logger.QuickLog(errorLogFileName, sqleArchive.Message, "Page_PreRender()", sqlArchive);
                        }
                        finally
                        {
                            if (con != null)
                            {
                                con.Close();
                            }
                        }
                        utility.GetRowChanged()[r] = false;
                    } //end "if (rowChanged[r])"
                }     //end "for (int r = 0; r < totalRows; r++)"
                if (!messageOutput.Equals(""))
                {
                    messageOutput = messageOutput + " Not Saved due to being updated by someone else";
                }

                if (updateMessage)
                {
                    if (messageOutput.Equals(""))
                    {
                        messageOutput         = "All Records Saved";
                        LabelMessage.CssClass = "Green";
                    }
                    else
                    {
                        LabelMessage.CssClass = "Red";
                    }
                    LabelMessage.Text = messageOutput;
                }
                else if (LabelMessage.Text.Equals("All Records Saved"))
                {
                    LabelMessage.Text = "";
                }


                dataGridView.DataBind();
                if (utility.GetIsAdminUser() || utility.GetIsCMUser())
                {
                    AmountSelectedHidden.Value = Convert.ToString(GetTotalChecked());
                }
            } //end if (Page.IsPostBack)
            else
            {
                dataGridView.SelectedIndex = -1;
            }
        } //end Page_PreRender()