Exemplo n.º 1
0
        /// <summary>
        /// Formats the rows on bind.  Sets visibility, currency, column headings, onclick commands, alignment, width, mouseover
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GridViewDataDivRowBindEvent(object sender, GridViewRowEventArgs e)
        {
            String localCurrency = "";

            if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header)
            {
                //HEADER ROW SPECIFIC
                if (e.Row.RowType == DataControlRowType.Header)
                {
                    if (utility.IsAdminUser)
                    {
                        e.Row.Cells[columnExceptionReasonRO].Attributes.CssStyle.Add("display", "none");
                        e.Row.Cells[columnExceptionReasonRO].Attributes.CssStyle.Add("visibility", "hidden");
                    }
                    else
                    {
                        e.Row.Cells[columnExpandButtonReason].Attributes.CssStyle.Add("display", "none");
                        e.Row.Cells[columnExpandButtonReason].Attributes.CssStyle.Add("visibility", "hidden");
                        e.Row.Cells[columnExceptionReason].Attributes.CssStyle.Add("display", "none");
                        e.Row.Cells[columnExceptionReason].Attributes.CssStyle.Add("visibility", "hidden");
                    }
                    dataGridView.Columns[columnPlaceHolder1].HeaderText  = dataGridView.Columns[columnPlaceHolder1].HeaderText.Replace("COLUMN1", getHeading(1));
                    dataGridView.Columns[columnPlaceHolder2].HeaderText  = dataGridView.Columns[columnPlaceHolder2].HeaderText.Replace("COLUMN2", getHeading(2));
                    dataGridView.Columns[columnPlaceHolder3].HeaderText  = dataGridView.Columns[columnPlaceHolder3].HeaderText.Replace("COLUMN3", getHeading(3));
                    dataGridView.Columns[columnPlaceHolder4].HeaderText  = dataGridView.Columns[columnPlaceHolder4].HeaderText.Replace("COLUMN4", getHeading(4));
                    dataGridView.Columns[columnPlaceHolder5].HeaderText  = dataGridView.Columns[columnPlaceHolder5].HeaderText.Replace("COLUMN5", getHeading(5));
                    dataGridView.Columns[columnPlaceHolder6].HeaderText  = dataGridView.Columns[columnPlaceHolder6].HeaderText.Replace("COLUMN6", getHeading(6));
                    dataGridView.Columns[columnPlaceHolder7].HeaderText  = dataGridView.Columns[columnPlaceHolder7].HeaderText.Replace("COLUMN7", getHeading(7));
                    dataGridView.Columns[columnPlaceHolder8].HeaderText  = dataGridView.Columns[columnPlaceHolder8].HeaderText.Replace("COLUMN8", getHeading(8));
                    dataGridView.Columns[columnPlaceHolder9].HeaderText  = dataGridView.Columns[columnPlaceHolder9].HeaderText.Replace("COLUMN9", getHeading(9));
                    dataGridView.Columns[columnPlaceHolder10].HeaderText = dataGridView.Columns[columnPlaceHolder10].HeaderText.Replace("COLUMN10", getHeading(10));
                    dataGridView.Columns[columnPlaceHolder11].HeaderText = dataGridView.Columns[columnPlaceHolder11].HeaderText.Replace("COLUMN11", getHeading(11));
                    dataGridView.Columns[columnPlaceHolder12].HeaderText = dataGridView.Columns[columnPlaceHolder12].HeaderText.Replace("COLUMN12", getHeading(12));
                    dataGridView.Columns[columnPlaceHolder13].HeaderText = dataGridView.Columns[columnPlaceHolder13].HeaderText.Replace("COLUMN13", getHeading(13));
                }

                //DATAROW SPECIFIC
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    if (utility.IsAdminUser)
                    {
                        e.Row.Cells[columnExceptionReasonRO].Attributes.CssStyle.Add("display", "none");
                        e.Row.Cells[columnExceptionReasonRO].Attributes.CssStyle.Add("visibility", "hidden");
                    }
                    else
                    {
                        e.Row.Cells[columnExpandButtonReason].Attributes.CssStyle.Add("display", "none");
                        e.Row.Cells[columnExpandButtonReason].Attributes.CssStyle.Add("visibility", "hidden");
                        e.Row.Cells[columnExceptionReason].Attributes.CssStyle.Add("display", "none");
                        e.Row.Cells[columnExceptionReason].Attributes.CssStyle.Add("visibility", "hidden");
                    }


                    e.Row.Attributes["onmouseover"] = "javascript:setMouseOverColor(this);";
                    e.Row.Attributes["onmouseout"]  = "javascript:setMouseOutColor(this);";

                    e.Row.Cells[columnPlaceHolder1].Attributes["onclick"]       = ClientScript.GetPostBackClientHyperlink(this.dataGridView, "Select$" + e.Row.RowIndex);
                    e.Row.Cells[columnPlaceHolder2].Attributes["onclick"]       = ClientScript.GetPostBackClientHyperlink(this.dataGridView, "Select$" + e.Row.RowIndex);
                    e.Row.Cells[columnPlaceHolder3].Attributes["onclick"]       = ClientScript.GetPostBackClientHyperlink(this.dataGridView, "Select$" + e.Row.RowIndex);
                    e.Row.Cells[columnPlaceHolder4].Attributes["onclick"]       = ClientScript.GetPostBackClientHyperlink(this.dataGridView, "Select$" + e.Row.RowIndex);
                    e.Row.Cells[columnPlaceHolder6].Attributes["onclick"]       = ClientScript.GetPostBackClientHyperlink(this.dataGridView, "Select$" + e.Row.RowIndex);
                    e.Row.Cells[columnPlaceHolder5].Attributes["onclick"]       = ClientScript.GetPostBackClientHyperlink(this.dataGridView, "Select$" + e.Row.RowIndex);
                    e.Row.Cells[columnPlaceHolder7].Attributes["onclick"]       = ClientScript.GetPostBackClientHyperlink(this.dataGridView, "Select$" + e.Row.RowIndex);
                    e.Row.Cells[columnPlaceHolder8].Attributes["onclick"]       = ClientScript.GetPostBackClientHyperlink(this.dataGridView, "Select$" + e.Row.RowIndex);
                    e.Row.Cells[columnPlaceHolder9].Attributes["onclick"]       = ClientScript.GetPostBackClientHyperlink(this.dataGridView, "Select$" + e.Row.RowIndex);
                    e.Row.Cells[columnPlaceHolder10].Attributes["onclick"]      = ClientScript.GetPostBackClientHyperlink(this.dataGridView, "Select$" + e.Row.RowIndex);
                    e.Row.Cells[columnPlaceHolder11].Attributes["onclick"]      = ClientScript.GetPostBackClientHyperlink(this.dataGridView, "Select$" + e.Row.RowIndex);
                    e.Row.Cells[columnPlaceHolder12].Attributes["onclick"]      = ClientScript.GetPostBackClientHyperlink(this.dataGridView, "Select$" + e.Row.RowIndex);
                    e.Row.Cells[columnPlaceHolder13].Attributes["onclick"]      = ClientScript.GetPostBackClientHyperlink(this.dataGridView, "Select$" + e.Row.RowIndex);
                    e.Row.Cells[columnLocalCurrency].Attributes["onclick"]      = ClientScript.GetPostBackClientHyperlink(this.dataGridView, "Select$" + e.Row.RowIndex);
                    e.Row.Cells[columnException].Attributes["onclick"]          = ClientScript.GetPostBackClientHyperlink(this.dataGridView, "Select$" + e.Row.RowIndex);
                    e.Row.Cells[columnExpandButton].Attributes["onclick"]       = "populateBox('" + ((TextBox)e.Row.Cells[columnNotes].FindControl("NotesTB")).ClientID + "')";
                    e.Row.Cells[columnExpandButtonReason].Attributes["onclick"] = "populateBox('" + ((TextBox)e.Row.Cells[columnExceptionReason].FindControl("ReasonTB")).ClientID + "')";

                    if (!utility.IsAdminUser)
                    {
                        e.Row.Cells[columnExceptionReasonRO].Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.dataGridView, "Select$" + e.Row.RowIndex);
                    }

                    localCurrency = e.Row.Cells[columnLocalCurrency].Text.ToString();

                    int columnPosition;
                    foreach (int i in utility.CurrencyColumnsLocal)
                    {
                        columnPosition = i + 1;
                        if (localCurrency.Equals("USD"))
                        {
                            e.Row.Cells[columnPosition].Text = "$" + e.Row.Cells[columnPosition].Text;
                        }
                        else if (localCurrency.Equals("GBP"))
                        {
                            e.Row.Cells[columnPosition].Text = "£" + e.Row.Cells[columnPosition].Text;
                        }
                        else if (localCurrency.Equals("EUR"))
                        {
                            e.Row.Cells[columnPosition].Text = "€" + e.Row.Cells[columnPosition].Text;
                        }
                        else if (localCurrency.Equals("JPY"))
                        {
                            e.Row.Cells[columnPosition].Text = "¥" + e.Row.Cells[columnPosition].Text;
                        }
                        else
                        {
                            e.Row.Cells[columnPosition].Text = e.Row.Cells[columnPosition].Text + " " + localCurrency;
                        }
                    }

                    foreach (int i in utility.CurrencyColumnsUSD)
                    {
                        columnPosition = i + 1;
                        e.Row.Cells[columnPosition].Text = "$" + e.Row.Cells[columnPosition].Text;
                    }

                    foreach (int i in utility.DateColumns)
                    {
                        columnPosition = i + 1;
                        if (e.Row.Cells[columnPosition].Text.Equals("Jan 01, 1900"))
                        {
                            e.Row.Cells[columnPosition].Text = "-";
                        }
                    }



                    if (((TextBox)e.Row.Cells[columnNotes].FindControl("NotesTB")).Text.Length > 28)
                    {
                        e.Row.Cells[columnNotes].Attributes.Add("onmouseover", "Tip('<b><u>Full Text:</u></b><br/>" + ((TextBox)e.Row.Cells[columnNotes].FindControl("NotesTB")).Text + "', WIDTH, 200)");
                        e.Row.Cells[columnNotes].Attributes.Add("onmouseout", "UnTip()");
                    }



                    if (e.Row.Cells[columnException].Text.ToLower().Equals("true"))
                    {
                        e.Row.Cells[columnException].Text = "Y";
                    }
                    else
                    {
                        e.Row.Cells[columnException].Text = "-";
                    }

                    if (utility.FirstPassThroughResultSet)
                    {
                        utility.FirstPassThroughResultSet = false;
                    }
                }

                //FOR BOTH HEADER AND DATAROWS

                //find columns that were locked previously and keep them locked.
                //find columns that were hidden previously and keep them hidden.
                try
                {
                    //if lockedColumnNumber is zero or greater, then we need to keep things locked.
                    if (int.Parse(lockedColumnNumber.Value.ToString()) > -1)
                    {
                        //only look at columns with a column number <= the locked column (greater columns are unlocked)
                        for (int i = 2; i <= int.Parse(lockedColumnNumber.Value.ToString()); i++)
                        {
                            //if (Request["billtk"].ToString().Equals("All") && i == columnDynamic1)
                            if (i == VariablesBillTracker.COLUMN_PLACEHOLDER_1)
                            {
                                e.Row.Cells[i].CssClass = "locked";
                            }

                            //if (Request["invoiceatty"].ToString().Equals("All") && i == columnDynamic2)
                            if (i == VariablesBillTracker.COLUMN_PLACEHOLDER_2)
                            {
                                e.Row.Cells[i].CssClass = "locked";
                            }

                            //if (Request["billspec"].ToString().Equals("All") && i == columnDynamic3)
                            if (i == VariablesBillTracker.COLUMN_PLACEHOLDER_3)
                            {
                                e.Row.Cells[i].CssClass = "locked";
                            }

                            //if (Request["arrangement"].ToString().Equals("All") && i == columnDynamic4)
                            if (i == VariablesBillTracker.COLUMN_PLACEHOLDER_4)
                            {
                                e.Row.Cells[i].CssClass = "locked";
                            }
                        }
                    }
                }
                catch
                {
                    //catch if lockedColumnNumber is not set
                }



                e.Row.Cells[columnPlaceHolder1].HorizontalAlign  = utility.GetColumnAlignment1();
                e.Row.Cells[columnPlaceHolder2].HorizontalAlign  = utility.GetColumnAlignment2();
                e.Row.Cells[columnPlaceHolder3].HorizontalAlign  = utility.GetColumnAlignment3();
                e.Row.Cells[columnPlaceHolder4].HorizontalAlign  = utility.GetColumnAlignment4();
                e.Row.Cells[columnPlaceHolder5].HorizontalAlign  = utility.GetColumnAlignment5();
                e.Row.Cells[columnPlaceHolder6].HorizontalAlign  = utility.GetColumnAlignment6();
                e.Row.Cells[columnPlaceHolder7].HorizontalAlign  = utility.GetColumnAlignment7();
                e.Row.Cells[columnPlaceHolder8].HorizontalAlign  = utility.GetColumnAlignment8();
                e.Row.Cells[columnPlaceHolder9].HorizontalAlign  = utility.GetColumnAlignment9();
                e.Row.Cells[columnPlaceHolder10].HorizontalAlign = utility.GetColumnAlignment10();
                e.Row.Cells[columnPlaceHolder11].HorizontalAlign = utility.GetColumnAlignment11();
                e.Row.Cells[columnPlaceHolder12].HorizontalAlign = utility.GetColumnAlignment12();
                e.Row.Cells[columnPlaceHolder13].HorizontalAlign = utility.GetColumnAlignment13();

                e.Row.Cells[columnPlaceHolder1].Attributes.Add("width", utility.GetColumnWidth1());
                e.Row.Cells[columnPlaceHolder2].Attributes.Add("width", utility.GetColumnWidth2());
                e.Row.Cells[columnPlaceHolder3].Attributes.Add("width", utility.GetColumnWidth3());
                e.Row.Cells[columnPlaceHolder4].Attributes.Add("width", utility.GetColumnWidth4());
                e.Row.Cells[columnPlaceHolder5].Attributes.Add("width", utility.GetColumnWidth5());
                e.Row.Cells[columnPlaceHolder6].Attributes.Add("width", utility.GetColumnWidth6());
                e.Row.Cells[columnPlaceHolder7].Attributes.Add("width", utility.GetColumnWidth7());
                e.Row.Cells[columnPlaceHolder8].Attributes.Add("width", utility.GetColumnWidth8());
                e.Row.Cells[columnPlaceHolder9].Attributes.Add("width", utility.GetColumnWidth9());
                e.Row.Cells[columnPlaceHolder10].Attributes.Add("width", utility.GetColumnWidth10());
                e.Row.Cells[columnPlaceHolder11].Attributes.Add("width", utility.GetColumnWidth11());
                e.Row.Cells[columnPlaceHolder12].Attributes.Add("width", utility.GetColumnWidth12());
                e.Row.Cells[columnPlaceHolder13].Attributes.Add("width", utility.GetColumnWidth13());

                e.Row.Cells[columnLocalCurrency].Attributes.Add("width", VariablesBillTracker.FIXED_WIDTH_CURRENCY);
                e.Row.Cells[columnDraftSent].Attributes.Add("width", VariablesBillTracker.FIXED_WIDTH_CHECKBOXES);
                e.Row.Cells[columnReadyToBill].Attributes.Add("width", VariablesBillTracker.FIXED_WIDTH_CHECKBOXES);
                e.Row.Cells[columnReversalCode].Attributes.Add("width", VariablesBillTracker.FIXED_WIDTH_REVERSALCODE);
                e.Row.Cells[columnNotes].Attributes.Add("width", VariablesBillTracker.FIXED_WIDTH_NOTES);
                e.Row.Cells[columnException].Attributes.Add("width", VariablesBillTracker.FIXED_WIDTH_EXCEPTION);
                e.Row.Cells[columnExceptionReason].Attributes.Add("width", VariablesBillTracker.FIXED_WIDTH_EXCEPTIONREASON);
                e.Row.Cells[columnExceptionReasonRO].Attributes.Add("width", VariablesBillTracker.FIXED_WIDTH_EXCEPTIONREASON);
                e.Row.Cells[columnExpandButton].Attributes.Add("width", VariablesBillTracker.FIXED_WIDTH_EXPANDBUTTON);
                e.Row.Cells[columnExpandButtonReason].Attributes.Add("width", VariablesBillTracker.FIXED_WIDTH_EXPANDBUTTON);
            }
            else if (e.Row.RowType == DataControlRowType.Pager)
            {
                bearCode.GridViewCustomizePagerRow(dataGridView, e.Row);

                if ((dataGridView.PageIndex + 1) == dataGridView.PageCount)
                {
                    if (dataGridView.Rows.Count < VariablesBillTracker.NUMBER_ROWS_ON_FINAL_PAGE_TO_KEEP_FIXED_PAGERROW)
                    {
                        //This is to remove the fixed footer class when it is the last page
                        e.Row.CssClass = "";
                    }
                }
            }
        }