Example #1
0
        private void DGV1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex <= -1) return;

            if (DGV1.Rows[e.RowIndex].Cells[e.ColumnIndex] is DataGridViewCheckBoxCell)
            {
            DataGridViewCheckBoxCell checkCell =(DataGridViewCheckBoxCell)DGV1.Rows[e.RowIndex].Cells["Enable"];

            if ((bool) checkCell.Value == true)
            {

                  Client.Csv_Struct _lotsize = new Csv_Struct();
                FOPAIRLEG2 v;
                byte[] buffer = DataPacket.RawSerialize(v=new FOPAIRLEG2()
                {
                    //Tok1B_S
                    PORTFOLIONAME = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["PF"].Value == DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["PF"].Value),
                    Token1 = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["Token1"].Value == DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["Token1"].Value),
                    Token2 = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["Token2"].Value== DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["Token2"].Value),
                    Token3 = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["Token3"].Value== DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["Token3"].Value),
                   Token4 = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["Token4"].Value== DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["Token4"].Value),
                    Token1side = Convert.ToInt16(DGV1.Rows[e.RowIndex].Cells["Tok1B_S"].Value.ToString() == "Buy" ? 1 : 2),
                    Token2side = Convert.ToInt16(DGV1.Rows[e.RowIndex].Cells["Tok2B_S"].Value.ToString() == "Buy" ? 1 : 2),
                    Token3side = Convert.ToInt16(DGV1.Rows[e.RowIndex].Cells["Tok3B_S"].Value.ToString() == "Buy" ? 1 : 2),
                    Token4side = Convert.ToInt16(DGV1.Rows[e.RowIndex].Cells["Tok4B_S"].Value.ToString() == "Buy" ? 1 : 2),
                    CALCTYPE = Convert.ToInt16(DGV1.Rows[e.RowIndex].Cells["Calc_type"].Value.ToString() == "BaseDiff" ? 2 : 1),
                });
                NNFHandler.Instance.Publisher(MessageType.IOCPAIR, buffer);

                int _buycount = 0;
                int _sellcount = 0;

                DataRow[] drr = Global.Instance.OrdetTable.Select("status='Traded'  and TokenNo='" + v.Token1 + "'  ");
                if (drr.Length > 0)
                {
                    var _v = drr.AsEnumerable().Where(a => a.Field<string>("Buy_SellIndicator") == "BUY").ToList();
                    _buycount = _v.Count();
                    var _v1 = drr.AsEnumerable().Where(a => a.Field<string>("Buy_SellIndicator") == "SELL").ToList();
                    _sellcount = _v1.Count();

                }

                //DataRow[] drr1 = Global.Instance.OrdetTable.Select("status='Traded'  and TokenNo='" + v.Token2 + "'  ");
                //if (drr1.Length > 0)
                //{
                //    var _v = drr1.Where(a => a.Field<string>("Buy_SellIndicator") == "BUY").ToList();
                //    _buycount = _buycount+ _v.Count();
                //    var _v1 = drr1.Where(a => a.Field<string>("Buy_SellIndicator") == "SELL").ToList();
                //    _sellcount =_sellcount+ _v1.Count();

                //}
                DGV1.Rows[e.RowIndex].Cells["TRDQTY(B)"].Value = _buycount;

                DGV1.Rows[e.RowIndex].Cells["TRDQTY(S)"].Value = _sellcount;

                //_lotsize.lotsize = CSV_Class.cimlist.Where(q => q.Token ==v.Token1 ).Select(a => a.BoardLotQuantity).First();
                if (Holder._DictLotSize.ContainsKey(v.Token1) == false  && v.Token1 != 0 )
                {
                Holder._DictLotSize.TryAdd(v.Token1, new Csv_Struct()
                {
                    lotsize=CSV_Class.cimlist.Where(q => q.Token ==v.Token1 ).Select(a => a.BoardLotQuantity).First()
                }
                );
                }

                if (Holder._DictLotSize.ContainsKey(v.Token2) == false && v.Token2 != 0)
                {
                    Holder._DictLotSize.TryAdd(v.Token2, new Csv_Struct()
                    {
                        lotsize = CSV_Class.cimlist.Where(q => q.Token == v.Token2).Select(a => a.BoardLotQuantity).First()
                    }
                    );
                }

                if (Holder._DictLotSize.ContainsKey(v.Token3) == false && v.Token3 != 0)
                {
                    Holder._DictLotSize.TryAdd(v.Token3, new Csv_Struct()
                    {
                        lotsize = CSV_Class.cimlist.Where(q => q.Token == v.Token3).Select(a => a.BoardLotQuantity).First()
                    }
                    );
                }

            }
            else
            {
                FOPAIRLEG2 v;
                byte[] buffer = DataPacket.RawSerialize(v=new FOPAIRLEG2()
                {
                    PORTFOLIONAME = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["PF"].Value == DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["PF"].Value),
                    Token1 = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["Token1"].Value == DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["Token1"].Value),
                    Token2 = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["Token2"].Value == DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["Token2"].Value),
                    Token3 = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["Token3"].Value == DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["Token3"].Value),
                    Token4 = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["Token4"].Value == DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["Token4"].Value),
                    Token1side = Convert.ToInt16(DGV1.Rows[e.RowIndex].Cells["Tok1B_S"].Value.ToString() == "Buy" ? 1 : 2),
                    Token2side = Convert.ToInt16(DGV1.Rows[e.RowIndex].Cells["Tok2B_S"].Value.ToString() == "Buy" ? 1 : 2),
                    Token3side = Convert.ToInt16(DGV1.Rows[e.RowIndex].Cells["Tok3B_S"].Value.ToString() == "Buy" ? 1 : 2),
                    Token4side = Convert.ToInt16(DGV1.Rows[e.RowIndex].Cells["Tok4B_S"].Value.ToString() == "Buy" ? 1 : 2),
                    CALCTYPE = Convert.ToInt16(DGV1.Rows[e.RowIndex].Cells["Calc_type"].Value.ToString() == "BaseDiff" ? 2 : 1),
                });
                NNFHandler.Instance.Publisher(MessageType.IOCPAIRUNSUB, buffer);

                if (Holder._DictLotSize.ContainsKey(v.Token1) == false || v.Token1 != 0)
                {
                    Csv_Struct o = new Csv_Struct();
                    Holder._DictLotSize.TryRemove(v.Token1, out o);

                }

                if (Holder._DictLotSize.ContainsKey(v.Token2) == false || v.Token2 != 0)
                {
                    Csv_Struct o = new Csv_Struct();
                    Holder._DictLotSize.TryRemove(v.Token2, out o);
                }
            }

            }
        }
Example #2
0
        private void DGV1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex <= -1) return;
            if (DGV1.Rows[e.RowIndex].Cells[e.ColumnIndex] is DataGridViewCheckBoxCell)
            {
            DataGridViewCheckBoxCell checkCell =(DataGridViewCheckBoxCell)DGV1.Rows[e.RowIndex].Cells["Enable"];
            Client.Csv_Struct _lotsize = new Csv_Struct();
            if ((bool) checkCell.Value == true)
            {
            int val = 0;
            FOPAIRLEG2 v;
            byte[] buffer = DataPacket.RawSerialize(v=new FOPAIRLEG2()
              {
                     //Tok1B_S
                    PORTFOLIONAME = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["PF"].Value == DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["PF"].Value),
                    Token1 = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["Token1"].Value == DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["Token1"].Value),
                    Token2 = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["Token2"].Value== DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["Token2"].Value),
                    Token3 = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["Token3"].Value== DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["Token3"].Value),
                    Token4 = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["Token4"].Value== DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["Token4"].Value),
                    Token1side = Convert.ToInt16(DGV1.Rows[e.RowIndex].Cells["Tok1B_S"].Value.ToString() == "Buy" ? 1 : 2),
                    Token2side = Convert.ToInt16(DGV1.Rows[e.RowIndex].Cells["Tok2B_S"].Value.ToString() == "Buy" ? 1 : 2),
                    Token3side = Convert.ToInt16(DGV1.Rows[e.RowIndex].Cells["Tok3B_S"].Value.ToString() == "Buy" ? 1 : 2),
                    Token4side = Convert.ToInt16(DGV1.Rows[e.RowIndex].Cells["Tok4B_S"].Value.ToString() == "Buy" ? 1 : 2),
                    Token1Ratio = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["ratio1"].Value == DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["ratio1"].Value),
                    Token2Ratio = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["ratio2"].Value == DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["ratio2"].Value),
                    Token3Ratio = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["ratio3"].Value == DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["ratio3"].Value),
                    Token4Ratio = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["ratio4"].Value == DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["ratio4"].Value),

                    CALCTYPE = Convert.ToInt16(DGV1.Rows[e.RowIndex].Cells["Calc_type"].Value.ToString() == "BaseDiff" ? 2 : 1),

                });

                NNFHandler.Instance.Publisher(MessageType.IOCPAIR, buffer);

                int _buycount = 0;
                int _sellcount = 0;
               // int lotSize=0;
                 var v2 = Global.Instance.Ratio.Where(a => a.Key == v.Token1).Select(b => b.Value).ToList();
                                 val =Convert.ToInt32(v2.FirstOrDefault().ToString());
                                 if (Holder._DictLotSize.ContainsKey(v.Token1) && v.Token1 != 0)
                                 {
                                 Holder._DictLotSize[v.Token1] = new Csv_Struct()
                                 {
                                 lotsize = CSV_Class.cimlist.Where(q => q.Token == v.Token1).Select(a => a.BoardLotQuantity).First()
                                 };
                                 }
                                 else if(v.Token1 != 0)
                                 {
                                 Holder._DictLotSize.TryAdd(v.Token1, new Csv_Struct()
                                 {
                                 lotsize = CSV_Class.cimlist.Where(q => q.Token == v.Token1).Select(a => a.BoardLotQuantity).First()
                                 }
                                 );
                                 }
                             _lotsize=Holder._DictLotSize[v.Token1];
                             if (Holder._DictLotSize.ContainsKey(v.Token2) && v.Token2 != 0)
                              {
                               Holder._DictLotSize[v.Token2] = new Csv_Struct()
                              {
                              lotsize = CSV_Class.cimlist.Where(q => q.Token == v.Token2).Select(a => a.BoardLotQuantity).First()
                              };
                              }
                              else if(v.Token2 != 0)
                                {
                                  Holder._DictLotSize.TryAdd(v.Token2, new Csv_Struct()
                                         {
                                             lotsize = CSV_Class.cimlist.Where(q => q.Token == v.Token2).Select(a => a.BoardLotQuantity).First()
                                         }
                                     );
                                     }

                                     if (Holder._DictLotSize.ContainsKey(v.Token3) && v.Token3!= 0)
                                     {
                                         Holder._DictLotSize[v.Token3] = new Csv_Struct()
                                         {
                                             lotsize = CSV_Class.cimlist.Where(q => q.Token == v.Token3).Select(a => a.BoardLotQuantity).First()
                                         };
                                     }
                                     else if(v.Token3 != 0)
                                     {
                                         Holder._DictLotSize.TryAdd(v.Token3, new Csv_Struct()
                                         {
                                             lotsize = CSV_Class.cimlist.Where(q => q.Token == v.Token3).Select(a => a.BoardLotQuantity).First()
                                         }
                                     );
                                     }

            }
            else
            {
                DGV1.Rows[e.RowIndex].Cells["PF"].Style.BackColor = Color.Red;
                FOPAIRLEG2 v;
                byte[] buffer = DataPacket.RawSerialize(v=new FOPAIRLEG2()
                {
                    PORTFOLIONAME = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["PF"].Value == DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["PF"].Value),
                    Token1 = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["Token1"].Value == DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["Token1"].Value),
                    Token2 = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["Token2"].Value == DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["Token2"].Value),
                    Token3 = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["Token3"].Value == DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["Token3"].Value),
                    Token4 = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["Token4"].Value == DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["Token4"].Value),
                    Token1side = Convert.ToInt16(DGV1.Rows[e.RowIndex].Cells["Tok1B_S"].Value.ToString() == "Buy" ? 1 : 2),
                    Token2side = Convert.ToInt16(DGV1.Rows[e.RowIndex].Cells["Tok2B_S"].Value.ToString() == "Buy" ? 1 : 2),
                    Token3side = Convert.ToInt16(DGV1.Rows[e.RowIndex].Cells["Tok3B_S"].Value.ToString() == "Buy" ? 1 : 2),
                    Token4side = Convert.ToInt16(DGV1.Rows[e.RowIndex].Cells["Tok4B_S"].Value.ToString() == "Buy" ? 1 : 2),
                    Token1Ratio = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["ratio1"].Value == DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["ratio1"].Value),
                    Token2Ratio = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["ratio2"].Value == DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["ratio2"].Value),
                    Token3Ratio = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["ratio3"].Value == DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["ratio3"].Value),
                    Token4Ratio = Convert.ToInt32(DGV1.Rows[e.RowIndex].Cells["ratio4"].Value == DBNull.Value ? "0" : DGV1.Rows[e.RowIndex].Cells["ratio4"].Value),
                    CALCTYPE = Convert.ToInt16(DGV1.Rows[e.RowIndex].Cells["Calc_type"].Value.ToString() == "BaseDiff" ? 2 : 1),

                });
                NNFHandler.Instance.Publisher(MessageType.IOCPAIRUNSUB, buffer);

            }

            }
        }