Example #1
0
        protected void btnUsePrice_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();

            ds = portfolioBo.GetGoldPrice(DateTime.Parse(txtPurchaseDate.Text));
            txtPurchasePrice.Text = ds.Tables[0].Rows[0][0].ToString();
            if (!string.IsNullOrEmpty(txtPurchaseDate.Text))
            {
                if (!string.IsNullOrEmpty(txtQuantity.Text))
                {
                    txtPurchaseValue.Text = (Math.Round((double.Parse(txtPurchasePrice.Text) * double.Parse(txtQuantity.Text)), 4)).ToString();
                }

                else
                {
                    txtPurchasePrice.Text = "";
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "Message", "alert('Please enter Quantity');", true);
                }
                //Page.ClientScript.RegisterStartupScript(this.GetType(), "Message", "alert('Please enter Quantity');", true);

                //txtPurchaseValue.Text = " ";
                if (!string.IsNullOrEmpty(txtQuantity.Text))
                {
                    DataSet ds1 = new DataSet();
                    ds1 = portfolioBo.GetGoldPriceCurrent(DateTime.Parse(txtPurchaseDate.Text));
                    //txtCurrentPrice.Text = ds1.Tables[0].Rows[0][0].ToString();
                    //txtCurrentValue.Text = (Math.Round((double.Parse(txtCurrentPrice.Text) * double.Parse(txtQuantity.Text)), 4)).ToString();
                }
                else
                {
                    txtPurchasePrice.Text = "";
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "Message", "alert('Please enter Quantity');", true);
                }
            }
            else
            {
                txtPurchasePrice.Text = "";
                ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "Message", "alert('Please enter Purchase Date');", true);
            }
        }