private void btnAddAcc_Click(object sender, EventArgs e)
        {
            frmInfoAcc f = new frmInfoAcc();

            f.ShowDialog();
            if (!string.IsNullOrEmpty(f.ServerType))
            {
                dgvAccount.Rows.Add(f.ServerType, f.Username, f.Password, f.Rate, "Login", null, null, null, f.Domain);
            }

            if (dgvAccount.Rows.Count == 1)
            {
                dgvAccount.Rows[0].Cells[10].Value = true;
                mainRate = Convert.ToInt32(dgvAccount.Rows[0].Cells[3].Value);
            }
        }
Beispiel #2
0
        private void btnAddAcc_Click(object sender, EventArgs e)
        {
            var btn = sender as SimpleButton;

            frmInfoAcc f = new frmInfoAcc();

            f.ShowDialog();
            if (!string.IsNullOrEmpty(f.ServerType))
            {
                DataGridView dgv = btn.Name == "btnAddAcc" ? dgvAccountBuy : dgvAccountSell;

                dgv.Rows.Add(f.ServerType, f.Username, f.Password, f.Rate, "Login", null, null, null, f.Domain, null, null, f.IpFake);

                if ((dgvAccountBuy.Rows.Count == 1 && dgvAccountSell.Rows.Count == 0) || (dgvAccountBuy.Rows.Count == 0 && dgvAccountSell.Rows.Count == 1))
                {
                    dgv.Rows[0].Cells[10].Value = true;
                    mainRate = Convert.ToInt32(dgvAccountBuy.Rows[0].Cells[3].Value);
                }
            }
        }
Beispiel #3
0
        private void dgvAccount_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }

            DataGridView dgv = (DataGridView)sender;

            bool isBuy = dgv.Name == "dgvAccountBuy";

            DataGridViewRow selectedRow = dgv.Rows[e.RowIndex];
            var             serverType  = selectedRow.Cells[0].Value;
            var             user        = selectedRow.Cells[1].Value;
            var             pass        = selectedRow.Cells[2].Value;
            var             rate        = selectedRow.Cells[3].Value;
            var             status      = selectedRow.Cells[4].Value;
            var             domain      = selectedRow.Cells[8].Value;
            var             ip          = selectedRow.Cells[11].Value;

            //dang nhap
            if (e.ColumnIndex == dgv.Columns[4].Index)
            {
                if (status.ToString() == "Login")
                {
                    IEngineBroker engine = null;
                    if (serverType.ToString() == "IBET")
                    {
                        engine = InitLoginIbet(domain.ToString(), user.ToString(), pass.ToString(),
                                               ip, Convert.ToInt32(rate));
                    }
                    else if (serverType.ToString() == "SBO")
                    {
                        engine = InitLoginSbo(domain.ToString(), user.ToString(), pass.ToString(),
                                              ip, Convert.ToInt32(rate));
                    }

                    if (engine != null)
                    {
                        broker.AddNewBetEngine(engine, isBuy);
                        selectedRow.Cells[9].Value = engine.EngineId;

                        selectedRow.Cells[1]                 = new DataGridViewLinkCell();
                        selectedRow.Cells[1].Value           = user.ToString();
                        selectedRow.Cells[4].Style.BackColor = Color.SteelBlue;
                        selectedRow.Cells[4].Value           = "Logout";
                    }
                }
                else
                {
                    ////Logout
                    var engineId = selectedRow.Cells[9].Value.ToString();
                    broker.RemoveBetEngine(engineId, isBuy);

                    UpdateLogText("Thoát tài khoản thành công!");
                    selectedRow.Cells[1]                 = new DataGridViewTextBoxCell();
                    selectedRow.Cells[1].Value           = user.ToString();
                    selectedRow.Cells[4].Style.BackColor = Color.White;
                    selectedRow.Cells[4].Value           = "Login";
                }
            }
            //Delete row
            else if (e.ColumnIndex == dgv.Columns[7].Index)
            {
                if (status.ToString() == "Login")
                {
                    dgv.Rows.RemoveAt(e.RowIndex);
                    UpdateLogText("Xóa tài khoản thành công!");
                }
                else
                {
                    UpdateLogText("Không thể thao tác trên tài khoản đang online!", eLogTextType.Error);
                }
            }
            //Edit row
            else if (e.ColumnIndex == dgv.Columns[6].Index)
            {
                if (status.ToString() == "Login")
                {
                    frmInfoAcc f = new frmInfoAcc(serverType.ToString(), user.ToString(), pass.ToString(), domain.ToString(), rate.ToString(), ip.ToString());
                    f.ShowDialog();
                    if (!string.IsNullOrEmpty(f.ServerType))
                    {
                        selectedRow.Cells[0].Value  = f.ServerType;
                        selectedRow.Cells[1].Value  = f.Username;
                        selectedRow.Cells[2].Value  = f.Password;
                        selectedRow.Cells[3].Value  = f.Rate;
                        selectedRow.Cells[8].Value  = f.Domain;
                        selectedRow.Cells[11].Value = f.IpFake;
                    }
                }
                else
                {
                    UpdateLogText("Không thể thao tác trên tài khoản đang online!", eLogTextType.Error);
                }
            }
            else if (e.ColumnIndex == dgv.Columns[1].Index)
            {
                if (status.ToString() == "Logout")
                {
                    var           engineId = selectedRow.Cells[9].Value.ToString();
                    IEngineBroker engine;
                    if (isBuy)
                    {
                        engine = broker.BetBuyEngines.First(b => b.EngineId == engineId);
                    }
                    else
                    {
                        engine = broker.BetSellEngines.First(b => b.EngineId == engineId);
                    }

                    frmStatement f = new frmStatement(engine, user.ToString());
                    f.Show();
                }
            }
            else if (e.ColumnIndex == dgv.Columns[5].Index)
            {
                if (status.ToString() == "Logout")
                {
                    var           engineId = selectedRow.Cells[9].Value.ToString();
                    IEngineBroker engine;
                    if (isBuy)
                    {
                        engine = broker.BetBuyEngines.First(b => b.EngineId == engineId);
                    }
                    else
                    {
                        engine = broker.BetSellEngines.First(b => b.EngineId == engineId);
                    }

                    var creadit = engine.UpdateAvailabeCredit();
                    UpdateLogText(string.Format("Hạn mức khả dụng tài khoản [{0}] là {1}", user, creadit), eLogTextType.Warning);
                }
                else
                {
                    UpdateLogText("Lỗi tài khoản chưa được đăng nhập.", eLogTextType.Error);
                }
            }
            //Chon ty gia chinh
            else if (e.ColumnIndex == dgv.Columns[10].Index)
            {
                foreach (DataGridViewRow dr in dgvAccountBuy.Rows)
                {
                    dr.Cells[10].Value = false;
                }
                foreach (DataGridViewRow dr in dgvAccountSell.Rows)
                {
                    dr.Cells[10].Value = false;
                }
                selectedRow.Cells[10].Value = true;
                mainRate = Convert.ToInt32(selectedRow.Cells[3].Value);
            }
        }