Esempio n. 1
0
    void btnUUpdate_Click(object sender, EventArgs e)
    {
        if (RatingID != 0)
        {
            pConfirm.Visible = true;

            tConfirm.Rows[0].Visible = true;
            tConfirm.Rows[1].Visible = true;
            tConfirm.Rows[2].Visible = true;

            if (ActionID == Actions.Delete || ActionID == Actions.Edit)
            {
                //Fil delete row

                DataTable dtOldRating = Data.GetRatings(RatingID.ToString(), String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, false, 10);

                if (dtOldRating != null && dtOldRating.Rows.Count > 0)
                {
                    DataRow drOldRating = dtOldRating.Rows[0];

                    lblConfirmDAnalystID.Text = drOldRating["AnalystID"].ToString();
                    lblConfirmDStockID.Text   = drOldRating["StockID"].ToString();
                    lblConfirmDSymbol.Text    = drOldRating["Symbol"].ToString();
                    lblConfirmDStockName.Text = drOldRating["StockName"].ToString();
                    lblConfirmDDate.Text      = drOldRating["Date"].ToString();
                    lblConfirmDPersonID.Text  = drOldRating["PersonID"].ToString();
                    lblConfirmDPerson.Text    = drOldRating["PersonName"].ToString();
                    lblConfirmDTermID.Text    = drOldRating["TermID"].ToString();
                    lblConfirmDRating.Text    = drOldRating["Rating"].ToString();
                    lblConfirmDPrice.Text     = drOldRating["Price"].ToString();
                }
            }
            else
            {
                tConfirm.Rows[1].Visible = false;
            }

            if (ActionID != Actions.Delete)
            {
                //Fil insert row
                lblConfirmIAnalystID.Text = txtUAnalystID.Text;
                lblConfirmIStockID.Text   = txtUStockID.Text;
                lblConfirmISymbol.Text    = lblUSymbol.Text;
                lblConfirmIStockName.Text = lblUStock.Text;
                lblConfirmIDate.Text      = txtUDate.Text;
                lblConfirmIPersonID.Text  = txtUPersonID.Text;
                lblConfirmIPerson.Text    = lblUPerson.Text;
                lblConfirmITermID.Text    = lblUTermID.Text;
                lblConfirmIRating.Text    = ddlRating.SelectedItem.ToString();
                lblConfirmIPrice.Text     = "n/a";
            }
            else
            {
                tConfirm.Rows[2].Visible = false;
            }

            //Match rows
            MatchLabels(lblConfirmDAnalystID, lblConfirmIAnalystID);
            MatchLabels(lblConfirmDStockID, lblConfirmIStockID);
            MatchLabels(lblConfirmDSymbol, lblConfirmISymbol);
            MatchLabels(lblConfirmDStockName, lblConfirmIStockName);
            MatchLabels(lblConfirmDDate, lblConfirmIDate);
            MatchLabels(lblConfirmDPersonID, lblConfirmIPersonID);
            MatchLabels(lblConfirmDPerson, lblConfirmIPerson);
            MatchLabels(lblConfirmDTermID, lblConfirmITermID);
            MatchLabels(lblConfirmDRating, lblConfirmIRating);
            MatchLabels(lblConfirmDPrice, lblConfirmIPrice);
        }
    }
Esempio n. 2
0
    protected void ibtnEditRating_Command(object sender, CommandEventArgs e)
    {
        int ratingID;
        int analystID;

        if (Int32.TryParse(e.CommandArgument.ToString(), out ratingID) && Int32.TryParse(e.CommandName, out analystID))
        {
            RatingID = ratingID;

            DataTable dt = null;

            try
            {
                dt = Data.GetRatings(ratingID.ToString(), analystID.ToString(), string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, false, 10);
            }
            catch (Exception ex)
            {
                Data.ShowError(pInfo, ex);
            }

            if (dt != null && dt.Rows.Count > 0)
            {
                ShowEditRating();

                foreach (GridViewRow row in gvRatings.Rows.Count > 0 ? gvRatings.Rows : gvRatingsAllColumns.Rows)
                {
                    if (row.Cells[2].Text.Equals(RatingID.ToString()))
                    {
                        row.Style.Add("background-color", Data.Constants.Colors.YellowCell);
                    }
                    else
                    {
                        row.Style.Remove("background-color");
                    }
                }

                /*
                 * GridViewRow ratingRow =
                 *      (from GridViewRow row in gvRatings.Rows.Count > 0 ? gvRatings.Rows : gvRatingsAllColumns.Rows
                 *       where row.Cells[2].Text.Equals(RatingID.ToString())
                 *       select row).SingleOrDefault();
                 *
                 * ratingRow.Style.Add("background-color", Data.Constants.Colors.YellowCell);
                 */

                //Text may be red if window was closed with error
                txtUAnalystID.Style.Remove("color");
                txtUStockID.Style.Remove("color");
                txtUPersonID.Style.Remove("color");
                txtUDate.Style.Remove("color");

                DataRow dr = dt.Rows[0];

                AnalystAliasID = Convert.ToInt32(dr["AnalystAliasID"]);

                txtUAnalystID.Text = dr["AnalystID"].ToString();
                txtUStockID.Text   = dr["StockID"].ToString();
                txtUPersonID.Text  = dr["PersonID"].ToString();
                txtUDate.Text      = dr["Date"].ToString();
                lblUTermID.Text    = dr["TermID"].ToString();

                lblUAnalyst.Visible  = true;
                ddlUAnalysts.Visible = false;
                lblUAnalyst.Text     = Data.GetAnalystNameByAnalystAliasID(Convert.ToInt32(dr["AnalystAliasID"]));
                lblUStock.Text       = dr["StockName"].ToString();
                lblUSymbol.Text      = dr["Symbol"].ToString();
                lblUPerson.Text      = dr["PersonName"].ToString();
                DateTime           dtDate = Convert.ToDateTime(txtUDate.Text);
                DateTimeFormatInfo gmn    = new DateTimeFormatInfo();
                lblUDate.Text = dtDate.Day.ToString() + " " + gmn.GetMonthName(dtDate.Month) + " " + dtDate.Year.ToString() + " " + dtDate.TimeOfDay.ToString();

                ddlRating.DataSource     = Data.GetAnalystTermsByAnalystAliasID(Convert.ToInt32(dr["AnalystAliasID"]));
                ddlRating.DataTextField  = "RatingName";
                ddlRating.DataValueField = "TermAliasID";
                ddlRating.DataBind();

                ddlRating.SelectedValue = dr["TermAliasID"].ToString();
            }
            else
            {
                Data.ShowError(pInfo, "Error get rating data");
            }
        }
        else
        {
            Data.ShowError(pInfo, "Error get RatingID and AnalystID");
        }
    }