예제 #1
0
    protected void avgPriceButton_Click(object sender, EventArgs e)
    {
        try
        {
            StringBuilder sbQueryInsert = new StringBuilder();
            commonGatewayObj.BeginTransaction();


            string    MarketPriceDate     = marketPriceDateTextBox.Text.ToString();
            DataTable dtCompByMarketPrice = new DataTable();
            PfolioBL  pfolioBLObj         = new PfolioBL();
            if (!pfolioBLObj.getCompUpdateStatus(MarketPriceDate))
            {
                //dvGridCSETradeInfo.Visible = false;
                avegLabel.Text = "Save Failed: Market price is not updated";
                avegLabel.Style.Add("color", "red");
            }
            else
            {
                if (!pfolioBLObj.getMPUpdateStatus(marketPriceDateTextBox.Text.ToString(), "AVERAGE"))
                {
                    commonGatewayObj.ExecuteNonQuery("UPDATE COMP SET ADC_RT=ROUND((NVL(AVG_RT,CSE_RT)+NVL(CSE_RT,AVG_RT))/2,2)  WHERE RT_UPD_DT='" + marketPriceDateTextBox.Text.ToString() + "'");
                    sbQueryInsert.Append(" INSERT INTO MARKET_PRICE SELECT COMP_CD,'" + marketPriceDateTextBox.Text.ToString() + "' AS EXPR1, ADC_RT, AVG_RT, CSE_RT, ");
                    sbQueryInsert.Append(" DECODE(CSE_DT, NULL, NULL, '" + marketPriceDateTextBox.Text.ToString() + "') AS EXPR2, DSE_HIGH, DSE_LOW, DSE_OPEN  FROM  COMP WHERE  VALID IS NULL ");
                    commonGatewayObj.ExecuteNonQuery(sbQueryInsert.ToString());

                    commonGatewayObj.CommitTransaction();
                    avegLabel.Text = "Price  Average Successfully";
                    avegLabel.Style.Add("color", "#009933");
                }
                else
                {
                    avegLabel.Text = "Price Already Avaraged On That Date";
                    avegLabel.Style.Add("color", "red");
                }
            }
        }
        catch (Exception ex)
        {
            commonGatewayObj.RollbackTransaction();
            avegLabel.Text = "Price  Average failed Error:" + ex.Message.ToString();
            avegLabel.Style.Add("color", "red");
        }
    }
예제 #2
0
    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 SaveCSEButton_Click(object sender, EventArgs e)
    {
        try
        {
            int       countRows      = 0;
            DataTable dtTradeCustDSE = (DataTable)Session["dtTradeCusDataCSE"];
            if (dtTradeCustDSE.Rows.Count > 0)
            {
                //   dt.Rows[0]["vch_dt"].ToString();
                string    howlaDate = dtTradeCustDSE.Rows[0]["SP_DATE"].ToString();
                DataTable dtMarketPriceByHowladate = new DataTable();
                PfolioBL  pfolioBLObj = new PfolioBL();
                if (!pfolioBLObj.getMPUpdateStatus(howlaDate, "AVERAGE"))
                {
                    dvGridCSETradeInfo.Visible = false;
                    DSETradeCustLabel.Text     = "Save Failed: Market price is not updated";
                    DSETradeCustLabel.Style.Add("color", "red");
                }
                else
                {
                    if (!pfolioBLObj.getHowlaUpdateStatus(HowlaDateTextBox.Text.ToString(), "CSE"))
                    {
                        if (dvGridCSETradeInfo.Visible == true)
                        {
                            Hashtable htTradeCustDSE = new Hashtable();
                            for (int loop = 0; loop < dtTradeCustDSE.Rows.Count; loop++)
                            {
                                htTradeCustDSE.Add("F_CD", dtTradeCustDSE.Rows[loop]["F_CD"]);
                                htTradeCustDSE.Add("COMP_CD", dtTradeCustDSE.Rows[loop]["COMP_CD"]);
                                htTradeCustDSE.Add("SP_DATE", dtTradeCustDSE.Rows[loop]["SP_DATE"]);
                                htTradeCustDSE.Add("BK_REF", dtTradeCustDSE.Rows[loop]["BK_REF"]);

                                htTradeCustDSE.Add("HOWLA_NO", dtTradeCustDSE.Rows[loop]["HOWLA_NO"]);
                                htTradeCustDSE.Add("HOWLA_TP", dtTradeCustDSE.Rows[loop]["HOWLA_TP"]);
                                htTradeCustDSE.Add("IN_OUT", dtTradeCustDSE.Rows[loop]["IN_OUT"]);
                                htTradeCustDSE.Add("SETTLE_DT", dtTradeCustDSE.Rows[loop]["SETTLE_DT"]);


                                htTradeCustDSE.Add("SP_QTY", dtTradeCustDSE.Rows[loop]["SP_QTY"]);
                                htTradeCustDSE.Add("SP_RATE", dtTradeCustDSE.Rows[loop]["SP_RATE"]);
                                htTradeCustDSE.Add("CL_DATE", dtTradeCustDSE.Rows[loop]["CL_DATE"]);
                                htTradeCustDSE.Add("BK_CD", dtTradeCustDSE.Rows[loop]["BK_CD"]);

                                htTradeCustDSE.Add("HOWLA_CHG", dtTradeCustDSE.Rows[loop]["HOWLA_CHG"]);
                                htTradeCustDSE.Add("LAGA_CHG", dtTradeCustDSE.Rows[loop]["LAGA_CHG"]);
                                htTradeCustDSE.Add("VOUCH_NO", dtTradeCustDSE.Rows[loop]["VOUCH_NO"]);
                                htTradeCustDSE.Add("VOUCH_REF", dtTradeCustDSE.Rows[loop]["VOUCH_REF"]);

                                htTradeCustDSE.Add("OP_NAME", dtTradeCustDSE.Rows[loop]["OP_NAME"]);
                                htTradeCustDSE.Add("N_P", dtTradeCustDSE.Rows[loop]["N_P"]);
                                htTradeCustDSE.Add("CUSTOMER", dtTradeCustDSE.Rows[loop]["CUSTOMER"]);

                                commonGatewayObj.Insert(htTradeCustDSE, "HOWLA_CSE");
                                htTradeCustDSE = new Hashtable();
                                countRows++;
                            }
                            commonGatewayObj.CommitTransaction();
                            Session["dtTradeCusDataCSE"] = null;
                            dvGridCSETradeInfo.Visible   = false;
                            CSETradeCustLabel.Text       = " Howla CSE " + countRows.ToString() + " Rows Save Successfully";
                            CSETradeCustLabel.Style.Add("color", "#009933");
                        }
                        else
                        {
                            CSETradeCustLabel.Text = "Save Failed:Please  Press the Show CSE Howla button";
                            CSETradeCustLabel.Style.Add("color", "red");
                        }
                    }
                    else
                    {
                        CSETradeCustLabel.Text = "Save Failed: CSE Howla Already Saved On That Date";
                        CSETradeCustLabel.Style.Add("color", "red");
                    }
                }
            }
        }
        catch (Exception ex)
        {
            commonGatewayObj.RollbackTransaction();
            CSETradeCustLabel.Text = " Howla CSE Save failed Error:" + ex.Message.ToString();
            CSETradeCustLabel.Style.Add("color", "red");
            //throw ex;
        }
    }
    protected void SaveButton_Click(object sender, EventArgs e)
    {
        try
        {
            int countRows = 0;
            commonGatewayObj.BeginTransaction();

            DataTable dtTradeCustDSE = (DataTable)Session["dtTradeCusetDSE"];
            if (dtTradeCustDSE.Rows.Count > 0)
            {
                //   dt.Rows[0]["vch_dt"].ToString();
                string    howlaDate = dtTradeCustDSE.Rows[0]["SP_DATE"].ToString();
                DataTable dtMarketPriceByHowladate = new DataTable();
                PfolioBL  pfolioBLObj = new PfolioBL();
                if (!pfolioBLObj.getMPUpdateStatus(howlaDate, "AVERAGE"))
                {
                    grdShowDSEMP.Visible   = false;
                    DSETradeCustLabel.Text = "Save Failed: Market price is not updated";
                    DSETradeCustLabel.Style.Add("color", "red");
                }
                else
                {
                    if (!pfolioBLObj.getHowlaUpdateStatus(HowlaDateTextBox.Text.ToString(), "DSE"))
                    {
                        if (dvGridDSETradeInfo.Visible == true)
                        {
                            Hashtable htTradeCustDSE = new Hashtable();
                            for (int loop = 0; loop < dtTradeCustDSE.Rows.Count; loop++)
                            {
                                htTradeCustDSE.Add("F_CD", dtTradeCustDSE.Rows[loop]["F_CD"]);
                                htTradeCustDSE.Add("SP_DATE", dtTradeCustDSE.Rows[loop]["SP_DATE"]);
                                htTradeCustDSE.Add("BK_REF", dtTradeCustDSE.Rows[loop]["BK_REF"]);
                                htTradeCustDSE.Add("HOWLA_NO", dtTradeCustDSE.Rows[loop]["HOWLA_NO"]);

                                htTradeCustDSE.Add("HOWLA_TP", dtTradeCustDSE.Rows[loop]["HOWLA_TP"]);
                                htTradeCustDSE.Add("IN_OUT", dtTradeCustDSE.Rows[loop]["IN_OUT"]);
                                htTradeCustDSE.Add("SETTLE_DT", dtTradeCustDSE.Rows[loop]["SETTLE_DT"]);
                                htTradeCustDSE.Add("COMP_CD", dtTradeCustDSE.Rows[loop]["COMP_CD"]);

                                htTradeCustDSE.Add("SP_QTY", dtTradeCustDSE.Rows[loop]["SP_QTY"]);
                                htTradeCustDSE.Add("SP_RATE", dtTradeCustDSE.Rows[loop]["SP_RATE"]);
                                htTradeCustDSE.Add("CL_DATE", dtTradeCustDSE.Rows[loop]["CL_DATE"]);
                                htTradeCustDSE.Add("BK_CD", dtTradeCustDSE.Rows[loop]["BK_CD"]);

                                htTradeCustDSE.Add("HOWLA_CHG", dtTradeCustDSE.Rows[loop]["HOWLA_CHG"]);
                                htTradeCustDSE.Add("LAGA_CHG", dtTradeCustDSE.Rows[loop]["LAGA_CHG"]);
                                htTradeCustDSE.Add("VOUCH_REF", dtTradeCustDSE.Rows[loop]["VOUCH_REF"]);
                                htTradeCustDSE.Add("OP_NAME", dtTradeCustDSE.Rows[loop]["OP_NAME"]);

                                htTradeCustDSE.Add("N_P", dtTradeCustDSE.Rows[loop]["N_P"]);
                                htTradeCustDSE.Add("ISIN_CD", dtTradeCustDSE.Rows[loop]["ISIN_CD"]);
                                htTradeCustDSE.Add("FORGN_FLG", dtTradeCustDSE.Rows[loop]["FORGN_FLG"]);
                                htTradeCustDSE.Add("SPOT_ID", dtTradeCustDSE.Rows[loop]["SPOT_ID"]);

                                htTradeCustDSE.Add("INSTR_GRP", dtTradeCustDSE.Rows[loop]["INSTR_GRP"]);
                                htTradeCustDSE.Add("MARKT_TP", dtTradeCustDSE.Rows[loop]["MARKT_TP"]);
                                htTradeCustDSE.Add("CUSTOMER", dtTradeCustDSE.Rows[loop]["CUSTOMER"]);
                                htTradeCustDSE.Add("BOID", dtTradeCustDSE.Rows[loop]["BOID"]);



                                commonGatewayObj.Insert(htTradeCustDSE, "HOWLA");
                                htTradeCustDSE = new Hashtable();
                                countRows++;
                            }
                            commonGatewayObj.CommitTransaction();
                            dvGridDSETradeInfo.Visible = false;
                            Session["dtTradeCusetDSE"] = null;
                            DSETradeCustLabel.Text     = " Howla DSE " + countRows.ToString() + " Rows Save Successfully";
                            DSETradeCustLabel.Style.Add("color", "#009933");
                        }
                        else
                        {
                            DSETradeCustLabel.Text = "Save Failed: DSE Howla Already Saved On That Date";
                            DSETradeCustLabel.Style.Add("color", "red");
                        }
                    }
                    else
                    {
                        DSETradeCustLabel.Text = "Save Failed:Please  Press the Show DSE Howla button";
                        DSETradeCustLabel.Style.Add("color", "red");
                    }
                }

                //string strQuery = "select TO_CHAR(max(vch_dt),'DD-MON-YYYY')last_tr_dt,TO_CHAR(max(vch_dt) + 1,'DD-MON-YYYY')vch_dt  from fund_trans_hb where f_cd =" + dtFundNameDropDownList.Rows[i]["F_CD"].ToString() +
                //                  " and tran_tp in ('C','S') and stock_ex in ('C','A')";
                //dtMarketPriceByHowladate = commonGatewayObj.Select(strQuery);
            }
        }
        catch (Exception ex)
        {
            commonGatewayObj.RollbackTransaction();
            Session["dtTradeCusetDSE"] = null;
            DSETradeCustLabel.Text     = " Howla DSE Save failed Error:" + ex.Message.ToString();
            DSETradeCustLabel.Style.Add("color", "red");
        }
    }