protected void showDataButton_Click(object sender, EventArgs e) { try { int zeroCompanyCode = 0; string dseMPFile = ConfigReader._TRADE_FILE_LOCATION.ToString(); dseMPFile = dseMPFile + "\\DSE_PRICE" + "\\" + marketPriceDateTextBox.Text.ToString().ToUpper() + "-DSE-MARKET-PRICE.xml"; if (File.Exists(dseMPFile)) { DataSet dataSet = new DataSet(); dataSet.ReadXml(dseMPFile, XmlReadMode.InferSchema); DataTable dtDSE = dataSet.Tables[0]; DataTable dtMP = new DataTable(); dtMP.Columns.Add("ID", typeof(int)); dtMP.Columns.Add("TRADE_CODE", typeof(string)); dtMP.Columns.Add("COMP_CD", typeof(int)); dtMP.Columns.Add("OPEN", typeof(string)); dtMP.Columns.Add("HIGH", typeof(string)); dtMP.Columns.Add("LOW", typeof(string)); dtMP.Columns.Add("CLOSE", typeof(string)); DataRow drMP; int count = 0; int serial = 0; if (dtDSE.Rows.Count > 0) { for (int loop = 0; loop < dtDSE.Rows.Count; loop++) { int companyCode = pfolioBLObj.getCompanyCodeByDSECode(dtDSE.Rows[loop]["SecurityCode"].ToString().ToUpper()); if (companyCode > 0) { drMP = dtMP.NewRow(); serial = serial + 1; drMP["ID"] = serial; drMP["TRADE_CODE"] = dtDSE.Rows[loop]["SecurityCode"].ToString().ToUpper(); drMP["COMP_CD"] = companyCode; drMP["OPEN"] = dtDSE.Rows[loop]["Open"].ToString(); drMP["HIGH"] = dtDSE.Rows[loop]["High"].ToString(); drMP["LOW"] = dtDSE.Rows[loop]["Low"].ToString(); drMP["CLOSE"] = dtDSE.Rows[loop]["Close"].ToString(); dtMP.Rows.Add(drMP); count++; } } } //while (srFileReader.Peek() != -1) //{ // line = srFileReader.ReadLine(); // char[] delimiters = new char[] { ' ' }; // lineContent = line.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); // if (lineContent.Length > 0) // { // int companyCode = pfolioBLObj.getCompanyCodeByDSECode(lineContent[0].ToString().ToUpper()); // if (companyCode == 0) // { // zeroCompanyCode++; // } // drMP = dtMP.NewRow(); // serial = serial + 1; // drMP["ID"] = serial; // drMP["TRADE_CODE"] = lineContent[0].ToString().ToUpper(); // drMP["COMP_CD"] = companyCode; // drMP["OPEN"] = lineContent[1].ToString(); // drMP["HIGH"] = lineContent[2].ToString(); // drMP["LOW"] = lineContent[3].ToString(); // drMP["CLOSE"] = lineContent[4].ToString(); // dtMP.Rows.Add(drMP); // } // count++; //} if (dtMP.Rows.Count > 0) { dvGridDSEMPInfo.Visible = true; grdShowDSEMP.DataSource = dtMP; grdShowDSEMP.DataBind(); Session["dtMPDSE"] = dtMP; if (pfolioBLObj.getMPUpdateStatus(marketPriceDateTextBox.Text.ToString(), "DSE")) { dsePriceLabel.Text = "Price Already Saved On That Date"; dsePriceLabel.Style.Add("color", "#009933"); } else { dsePriceLabel.Text = "Price Should Save On That Date"; dsePriceLabel.Style.Add("color", "red"); } } else { Session["dtMPDSE"] = null; dsePriceLabel.Text = "No DSE Price Found On That Date"; dsePriceLabel.Style.Add("color", "red"); } } } catch (Exception ex) { dvGridDSEMPInfo.Visible = false; dsePriceLabel.Text = "File Read failed Error:" + ex.Message.ToString(); dsePriceLabel.Style.Add("color", "red"); } }
protected void showDataButton_Click(object sender, EventArgs e) { int count = 0; try { string dseCustFile = ConfigReader._TRADE_FILE_LOCATION.ToString(); dseCustFile = dseCustFile + "\\TRADE_CUST_DSE" + "\\" + HowlaDateTextBox.Text.ToString().ToUpper() + "-DSE-ISTBROKER.txt"; if (File.Exists(dseCustFile)) { DataTable dtHowla = getdtTradeCusTable(); DataRow drHowla; StreamReader srFileReader; string line; srFileReader = new StreamReader(dseCustFile); string[] lineContent; int serial = 0; double lagaCharge = 0.00; int tradeQty; double tradePrice = 0.00; string zeroCompCode = ""; while (srFileReader.Peek() != -1) { line = srFileReader.ReadLine(); lineContent = line.Split('~'); if (lineContent.Length > 0) { if (count == 1002) { if (1 == 1) { } } if (pfolioBLObj.getFundCodeByCustomerCode(lineContent[13].ToString()) > 0) { int companyCode = pfolioBLObj.getCompanyCodeByDSECode(lineContent[1].ToString().ToUpper()); if (companyCode == 0) { zeroCompCode = lineContent[1].ToString().ToUpper(); } int fundCode = pfolioBLObj.getFundCodeByCustomerCode(lineContent[13].ToString().ToUpper()); drHowla = dtHowla.NewRow(); serial = serial + 1; drHowla["SI"] = serial; drHowla["F_CD"] = fundCode; drHowla["SP_DATE"] = Convert.ToDateTime(DateTime.ParseExact(lineContent[7].ToString(), "dd-MM-yyyy", null)).ToString("dd-MMM-yyyy"); drHowla["BK_REF"] = lineContent[0].ToString().Trim().ToUpper(); drHowla["HOWLA_NO"] = lineContent[15].ToString().Trim(); drHowla["HOWLA_TP"] = lineContent[11].ToString().Trim().ToUpper(); if (lineContent[4] == "B") { drHowla["IN_OUT"] = "I"; } else if (lineContent[4] == "S") { drHowla["IN_OUT"] = "O"; } drHowla["SETTLE_DT"] = Convert.ToDateTime(DateTime.ParseExact(lineContent[7].ToString(), "dd-MM-yyyy", null)).ToString("dd-MMM-yyyy"); drHowla["COMP_CD"] = companyCode; drHowla["SP_QTY"] = lineContent[5].ToString().Trim(); drHowla["SP_RATE"] = lineContent[6].ToString().Trim().ToUpper(); drHowla["CL_DATE"] = Convert.ToDateTime(ClearingDateTextBox.Text.Trim()).ToString("dd-MMM-yyyy"); drHowla["BK_CD"] = "DSE/129"; drHowla["HOWLA_CHG"] = "2"; tradeQty = Convert.ToInt32(lineContent[5].Trim()); tradePrice = Convert.ToDouble(lineContent[6].Trim()); lagaCharge = 0.0002 * tradeQty * tradePrice; drHowla["LAGA_CHG"] = lagaCharge; drHowla["VOUCH_REF"] = lineContent[3].ToString().ToUpper(); string LoginID = Session["UserID"].ToString(); //drHowla["OP_NAME"] = bcContent.LoginID.ToString(); drHowla["OP_NAME"] = LoginID; drHowla["N_P"] = lineContent[10].ToString().Trim().ToUpper(); drHowla["ISIN_CD"] = lineContent[2].ToString().Trim().ToUpper(); drHowla["FORGN_FLG"] = lineContent[12].ToString().Trim().ToUpper(); drHowla["SPOT_ID"] = lineContent[16].ToString().Trim().ToUpper(); drHowla["INSTR_GRP"] = lineContent[17].ToString().Trim().ToUpper(); drHowla["MARKT_TP"] = lineContent[9].ToString().Trim().ToUpper(); drHowla["CUSTOMER"] = lineContent[13].ToString().Trim().ToUpper(); drHowla["BOID"] = lineContent[14].ToString().Trim().ToUpper(); dtHowla.Rows.Add(drHowla); count++; } } } if (dtHowla.Rows.Count > 0) { if (zeroCompCode == "") { dvGridDSETradeInfo.Visible = true; grdShowDSEMP.DataSource = dtHowla; grdShowDSEMP.DataBind(); Session["dtTradeCusetDSE"] = dtHowla; if (pfolioBLObj.getHowlaUpdateStatus(HowlaDateTextBox.Text.ToString(), "DSE")) { DSETradeCustLabel.Text = "DSE Howla Already Saved On That Date"; DSETradeCustLabel.Style.Add("color", "#009933"); } else { DSETradeCustLabel.Text = "DSE Howla Should Save On That Date"; DSETradeCustLabel.Style.Add("color", "red"); } } else { Session["dtTradeCusetDSE"] = null; dvGridDSETradeInfo.Visible = false; DSETradeCustLabel.Text = "Data Show Failed: Unknown Company DSE Trading Code:" + zeroCompCode; DSETradeCustLabel.Style.Add("color", "red"); } } else { Session["dtTradeCusetDSE"] = null; dvGridDSETradeInfo.Visible = false; DSETradeCustLabel.Text = "No Data Found or File Read Error!!"; DSETradeCustLabel.Style.Add("color", "red"); } } } catch (Exception ex) { int counter = count; dvGridDSETradeInfo.Visible = false; DSETradeCustLabel.Text = "File Read failed Error:" + ex.Message.ToString(); DSETradeCustLabel.Style.Add("color", "red"); } }