protected void btnSubmit_1_Click(object sender, EventArgs e) { customerVo = (CustomerVo)Session["CustomerVo"]; decimal temp; float res; float serviceTax = float.Parse(Session["serviceTax"].ToString()); float stt = float.Parse(Session["STT"].ToString()); ds.Tables.Add(tempDt); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { float brokerage = float.Parse(ds.Tables[0].Rows[i]["Brokerage"].ToString()); res = ((totalProrate) * (brokerage)) / totalBrokerage; ds.Tables[0].Rows[i]["Other Charges"] = res.ToString(); } for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { eqTransactionVo = new EQTransactionVo(); eqTransactionVo.AccountId = 1001; // eqTransactionVo.Brokerage = decimal.Round((decimal)(ds.Tables[0].Rows[i]["Brokerage"].ToString()), 4); eqTransactionVo.Brokerage = float.Parse(ds.Tables[0].Rows[i]["Brokerage"].ToString()); eqTransactionVo.Brokerage = (float)decimal.Round(Convert.ToDecimal(eqTransactionVo.Brokerage), 4); eqTransactionVo.BrokerCode = ds.Tables[0].Rows[i]["Broker"].ToString(); if (ds.Tables[0].Rows[i]["Transaction Type"].ToString() == "Buy") { eqTransactionVo.BuySell = "B"; } else { eqTransactionVo.BuySell = "S"; } eqTransactionVo.CustomerId = int.Parse(customerVo.CustomerId.ToString()); if (ds.Tables[0].Rows[i]["Transaction Mode"].ToString() == "Delivery Trade") { eqTransactionVo.TradeType = "D"; } else { eqTransactionVo.TradeType = "S"; } eqTransactionVo.ServiceTax = serviceTax; eqTransactionVo.EducationCess = (float)((3 / 100) * serviceTax); eqTransactionVo.EducationCess = (float)decimal.Round(Convert.ToDecimal(eqTransactionVo.EducationCess), 4); eqTransactionVo.ScripCode = 100000; eqTransactionVo.Exchange = ds.Tables[0].Rows[i]["Exchange Type"].ToString(); eqTransactionVo.OtherCharges = float.Parse(ds.Tables[0].Rows[i]["Other Charges"].ToString()); eqTransactionVo.OtherCharges = (float)decimal.Round(Convert.ToDecimal(eqTransactionVo.OtherCharges), 4); eqTransactionVo.Quantity = float.Parse(ds.Tables[0].Rows[i]["No Of Shares"].ToString()); eqTransactionVo.Rate = float.Parse(ds.Tables[0].Rows[i]["Rate"].ToString()); eqTransactionVo.Rate = (float)decimal.Round(Convert.ToDecimal(eqTransactionVo.Rate), 4); eqTransactionVo.STT = stt; if (eqTransactionVo.BuySell == "B") { eqTransactionVo.RateInclBrokerage = eqTransactionVo.Rate + eqTransactionVo.Brokerage + eqTransactionVo.ServiceTax + eqTransactionVo.EducationCess + eqTransactionVo.STT + eqTransactionVo.OtherCharges; eqTransactionVo.RateInclBrokerage = (float)decimal.Round(Convert.ToDecimal(eqTransactionVo.RateInclBrokerage), 4); eqTransactionVo.TransactionCode = 1; } else { eqTransactionVo.RateInclBrokerage = eqTransactionVo.Rate - eqTransactionVo.Brokerage - (eqTransactionVo.ServiceTax + eqTransactionVo.EducationCess) - eqTransactionVo.STT - eqTransactionVo.OtherCharges; eqTransactionVo.RateInclBrokerage = (float)decimal.Round(Convert.ToDecimal(eqTransactionVo.RateInclBrokerage), 4); eqTransactionVo.TransactionCode = 2; } //eqTransactionVo.Source = "M"; //eqTransactionVo.SourceDetail = "WERP"; eqTransactionVo.TradeDate = DateTime.Parse(ds.Tables[0].Rows[i]["Trade Date"].ToString()); eqTransactionVo.TradeTotal = eqTransactionVo.RateInclBrokerage * eqTransactionVo.Quantity; eqTransactionVo.TradeTotal = (float)decimal.Round(Convert.ToDecimal(eqTransactionVo.TradeTotal), 4); eqTransactionVo.IsCorpAction = 0; // eqTransactionVo.TransactionId = customerTransactionBo.getId(); customerTransactionBo.AddEquityTransaction(eqTransactionVo, customerVo.UserId); } //foreach (GridViewRow gvr in GridView1.Rows) //{ // //TextBox txtBrokerage1 = (TextBox)gvr.FindControl("Brokerage"); // //float brokerage = float.Parse(txtBrokerage1.Text.ToString()); // // float brokerage = float.Parse(gvr.FindControl("Brokerage").ToString()); // string txt = ((TextBox)gvr.FindControl("Brokerage")).Text.ToString(); // float brokerage = float.Parse(txt); // res = ((totalProrate) * (brokerage)) / totalBrokerage; // TextBox other = (TextBox)gvr.FindControl("Other Charges"); // other.Text = res.ToString(); //} GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); GridView1.Visible = true; }
protected void btnSubmit_Click(object sender, EventArgs e) { decimal temp; DataTable dt; CultureInfo ci = new CultureInfo("en-GB"); try { dt = productEquityBo.GetBrokerCode(portfolioId, ddlTradeAcc.SelectedItem.Text.ToString()); eqTransactionVo.IsSourceManual = 1; if (txtBrokerage.Text != "") { eqTransactionVo.Brokerage = float.Parse(txtBrokerage.Text); } eqTransactionVo.BrokerCode = dt.Rows[0]["XB_BrokerCode"].ToString(); if (ddlTransactionType.SelectedItem.Text.ToString() == "Purchase") { eqTransactionVo.BuySell = "B"; eqTransactionVo.TransactionCode = 1; } if (ddlTransactionType.SelectedItem.Text.ToString() == "Sell") { eqTransactionVo.BuySell = "S"; eqTransactionVo.TransactionCode = 2; } if (ddlTransactionType.SelectedItem.Text.ToString() == "Holdings") { eqTransactionVo.BuySell = "B"; eqTransactionVo.TransactionCode = 13; } eqTransactionVo.CustomerId = customerVo.CustomerId; eqTransactionVo.IsCorpAction = 0; if (rbtnDelivery.Checked) { eqTransactionVo.IsSpeculative = 0; } if (rbtnSpeculation.Checked) { eqTransactionVo.IsSpeculative = 1; } eqTransactionVo.EducationCess = (float)tempEducation; eqTransactionVo.ScripCode = scripCode; if (ddlExchange.SelectedItem.Value.ToString() != "Select an Exchange") { eqTransactionVo.Exchange = ddlExchange.SelectedItem.Value.ToString(); } else { eqTransactionVo.Exchange = "NSE"; } if (txtOtherCharge.Text != "") { eqTransactionVo.OtherCharges = float.Parse(txtOtherCharge.Text); } eqTransactionVo.Quantity = float.Parse(txtNumShares.Text); eqTransactionVo.IsSpeculative = 0; eqTransactionVo.TradeType = "D"; eqTransactionVo.AccountId = int.Parse(ddlTradeAcc.SelectedItem.Value.ToString()); eqTransactionVo.Rate = float.Parse(txtRate.Text); eqTransactionVo.RateInclBrokerage = float.Parse(txtRateIncBrokerage.Text); temp = decimal.Round(Convert.ToDecimal(tempService), 3); if (txtTax.Text != "") { eqTransactionVo.ServiceTax = float.Parse(txtTax.Text); } if (txtSTT.Text != "") { eqTransactionVo.STT = float.Parse(txtSTT.Text); } eqTransactionVo.TradeDate = Convert.ToDateTime(txtTradeDate.Text.Trim(), ci);// DateTime.Parse(txtTradeDate.Text);//ddlDay.SelectedItem.Text.ToString() + "/" + ddlMonth.SelectedItem.Value.ToString() + "/" + ddlYear.SelectedItem.Value.ToString() eqTransactionVo.TradeTotal = float.Parse(txtTotal.Text); eqTransactionVo.TradeNum = 0; if (customerTransactionBo.AddEquityTransaction(eqTransactionVo, customerVo.UserId)) { customerPortfolioBo.UpdateAdviserDailyEODLogRevaluateForTransaction(advisorVo.advisorId, "EQ", eqTransactionVo.TradeDate); } List <EQPortfolioVo> eqPortfolioVoList = new List <EQPortfolioVo>(); Dictionary <string, DateTime> genDict = new Dictionary <string, DateTime>(); DateTime tradeDate = new DateTime(); if (Session["ValuationDate"] != null) { genDict = (Dictionary <string, DateTime>)Session["ValuationDate"]; tradeDate = DateTime.Parse(genDict["EQDate"].ToString()); } if (tradeDate == DateTime.MinValue) { tradeDate = DateTime.Today; } eqPortfolioVoList = customerPortfolioBo.GetCustomerEquityPortfolio(customerVo.CustomerId, portfolioId, tradeDate, txtScrip.Text, ddlTradeAcc.SelectedItem.Value.ToString()); if (eqPortfolioVoList != null && eqPortfolioVoList.Count > 0) { customerPortfolioBo.DeleteEquityNetPosition(eqPortfolioVoList[0].EQCode, eqPortfolioVoList[0].AccountId, tradeDate); customerPortfolioBo.AddEquityNetPosition(eqPortfolioVoList[0], userVo.UserId); } btnSubmit.Enabled = false; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "leftpane", "loadcontrol('EquityTransactionsView','none');", true); } catch (BaseApplicationException Ex) { throw Ex; } catch (Exception Ex) { BaseApplicationException exBase = new BaseApplicationException(Ex.Message, Ex); NameValueCollection FunctionInfo = new NameValueCollection(); FunctionInfo.Add("Method", "EquityManualSingleTransaction.ascx:btnSubmit_Click()"); object[] objects = new object[3]; objects[0] = portfolioId;; objects[1] = eqTransactionVo; objects[2] = customerVo; FunctionInfo = exBase.AddObject(FunctionInfo, objects); exBase.AdditionalInformation = FunctionInfo; ExceptionManager.Publish(exBase); throw exBase; } }
private bool SaveEquityTransaction() { EQTransactionVo eqTransactionVo = new EQTransactionVo(); CustomerTransactionBo customerTransactionBo = new CustomerTransactionBo(); try { // dt = productEquityBo.GetBrokerCode(portfolioId, ddlTradeAcc.SelectedItem.Text.ToString()); eqTransactionVo.IsSourceManual = 1; eqTransactionVo.Brokerage = float.Parse(txtBrokerage.Text); //eqTransactionVo.BrokerCode = dt.Rows[0]["XB_BrokerCode"].ToString(); if (ddlTransactionType.SelectedItem.Text.ToString() == "Purchase") { eqTransactionVo.BuySell = "B"; eqTransactionVo.TransactionCode = 1; } if (ddlTransactionType.SelectedItem.Text.ToString() == "Sell") { eqTransactionVo.BuySell = "S"; eqTransactionVo.TransactionCode = 2; } if (ddlTransactionType.SelectedItem.Text.ToString() == "Holdings") { eqTransactionVo.BuySell = "B"; eqTransactionVo.TransactionCode = 13; } if (txtParentCustomerId.Value != string.Empty) { eqTransactionVo.CustomerId = Convert.ToInt32(txtParentCustomerId.Value); //customerVo.CustomerId; } eqTransactionVo.IsCorpAction = 0; if (rdoDelivery.Checked) { eqTransactionVo.IsSpeculative = 0; } else if (rdoSpeculative.Checked) { eqTransactionVo.IsSpeculative = 1; } //eqTransactionVo.EducationCess = (float)tempEducation; eqTransactionVo.ScripCode = Convert.ToInt32(hidScrip.Value); //eqTransactionVo.Exchange = ddlExchange.SelectedItem.Value.ToString(); if (txtOtherCharges.Text != string.Empty) { eqTransactionVo.OtherCharges = float.Parse(txtOtherCharges.Text); } if (txtQuantity.Text != string.Empty) { eqTransactionVo.Quantity = float.Parse(txtQuantity.Text); } //eqTransactionVo.IsSpeculative = 0; eqTransactionVo.TradeType = "D"; // eqTransactionVo.AccountId = ; if (txtRate.Text != string.Empty) { eqTransactionVo.Rate = float.Parse(txtRate.Text); } //eqTransactionVo.RateInclBrokerage = float.Parse(txtRateIncBrokerage.Text); //temp = decimal.Round(Convert.ToDecimal(tempService), 3); //eqTransactionVo.ServiceTax = (float)temp; if (txtSTT.Text != string.Empty) { eqTransactionVo.STT = float.Parse(txtSTT.Text); } eqTransactionVo.TradeDate = Convert.ToDateTime(txtTransactionDate.Text.Trim());// DateTime.Parse(txtTradeDate.Text);//ddlDay.SelectedItem.Text.ToString() + "/" + ddlMonth.SelectedItem.Value.ToString() + "/" + ddlYear.SelectedItem.Value.ToString() //eqTransactionVo.TradeTotal = float.Parse(txtTotal.Text); if (ddlTradeAccountNos.SelectedValue != "-1") { eqTransactionVo.AccountId = int.Parse(ddlTradeAccountNos.SelectedValue); } //long.Parse(ddlTradeAcc.SelectedItem.Text.ToString()); if (customerTransactionBo.AddEquityTransaction(eqTransactionVo, eqTransactionVo.CustomerId)) { CustomerPortfolioBo customerPortfolioBo = new CustomerPortfolioBo(); AdvisorVo advisorVo = new AdvisorVo(); advisorVo = (AdvisorVo)Session["advisorVo"]; customerPortfolioBo.UpdateAdviserDailyEODLogRevaluateForTransaction(advisorVo.advisorId, "EQ", eqTransactionVo.TradeDate); } //btnSubmit.Enabled = false; } catch (BaseApplicationException Ex) { throw Ex; } catch (Exception Ex) { BaseApplicationException exBase = new BaseApplicationException(Ex.Message, Ex); NameValueCollection FunctionInfo = new NameValueCollection(); FunctionInfo.Add("Method", "EquityManualSingleTransaction.ascx:btnSubmit_Click()"); object[] objects = new object[3]; //objects[0] = portfolioId; ; //objects[1] = eqTransactionVo; //objects[2] = customerVo; FunctionInfo = exBase.AddObject(FunctionInfo, objects); exBase.AdditionalInformation = FunctionInfo; ExceptionManager.Publish(exBase); throw exBase; } return(false); }