Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Clientname = new DataTable();
                Clientname.Columns.Add(new DataColumn("ClientID"));
                Clientname.Columns.Add(new DataColumn("Name"));

                DataRow Clientrow = Clientname.NewRow();

                int    MatchID = Convert.ToInt32(Request.QueryString["MatchID"]);
                string CN      = ConfigurationManager.ConnectionStrings["DBMS"].ConnectionString;
                using (MySqlConnection cn = new MySqlConnection(CN))
                {
                    cn.Open();

                    string           Agent    = "Select Code,Name From AgentMaster where Createdby = '" + Session["SuperAgentCode"] + "'";
                    MySqlCommand     Agentcmd = new MySqlCommand(Agent, cn);
                    MySqlDataAdapter Agentadp = new MySqlDataAdapter(Agentcmd);
                    DataTable        Agentdt  = new DataTable();
                    Agentadp.Fill(Agentdt);
                    for (int a = 0; a < Agentdt.Rows.Count; a++)
                    {
                        string Agentcode = Agentdt.Rows[a]["code"].ToString();
                        string AgentName = Agentdt.Rows[a]["Name"].ToString();


                        string           s        = "Select * From ClientMaster where CreatedBy = '" + Agentcode + "'";
                        MySqlCommand     cmd      = new MySqlCommand(s, cn);
                        MySqlDataAdapter adp      = new MySqlDataAdapter(cmd);
                        DataTable        Clientdt = new DataTable();
                        adp.Fill(Clientdt);


                        for (int j = 0; j < Clientdt.Rows.Count; j++)
                        {
                            int    ClientID = Convert.ToInt32(Clientdt.Rows[j]["ClientID"]);
                            string Name     = "C" + ClientID + Clientdt.Rows[j]["Name"].ToString();

                            Clientrow["ClientID"] = ClientID;
                            Clientrow["Name"]     = Name;
                            Clientname.Rows.Add(Clientrow.ItemArray);
                        }
                        DropDownClient.DataSource     = Clientname;
                        DropDownClient.DataTextField  = "Name";
                        DropDownClient.DataValueField = "ClientID";
                        DropDownClient.DataBind();

                        string           s1   = "Select SessionID,Session From Session where MatchID = '" + MatchID + "' group by Session";
                        MySqlCommand     cmd1 = new MySqlCommand(s1, cn);
                        MySqlDataAdapter adp1 = new MySqlDataAdapter(cmd1);
                        DataTable        dt1  = new DataTable();
                        adp1.Fill(dt1);
                        DropDownSession.DataSource = dt1;
                        DropDownSession.DataBind();
                        DropDownSession.DataTextField  = "Session";
                        DropDownSession.DataValueField = "Session";
                        DropDownSession.DataBind();

                        string           s2   = "select Session.sessionID,Session.session,Session.Runs,Session.Amount,Session.rate,Session.Mode,Session.DateTime,Session.Team,Session.clientID,clientmaster.Name,Clientmaster.createdBy from Session inner join clientmaster on Session.ClientID = clientmaster.ClientID where clientmaster.mode = 'Agent' && clientmaster.CreatedBy = '" + Agentcode + "' && Session.MatchID = '0'";
                        MySqlCommand     cmd2 = new MySqlCommand(s2, cn);
                        MySqlDataAdapter adp2 = new MySqlDataAdapter(cmd2);
                        dt = new DataTable();
                        adp2.Fill(dt);

                        runTable = new DataTable();
                        runTable.Columns.Add(new DataColumn("RUNS"));
                        runTable.Columns.Add(new DataColumn("AMOUNT"));
                        if (dt.Rows.Count > 0)
                        {
                            int runs   = Convert.ToInt16(dt.Rows[0]["Runs"]);
                            int Amount = Convert.ToInt32(dt.Rows[0]["Amount"]);
                            for (int i = runs - 10; i <= runs + 10; i++)
                            {
                                DataRow row = runTable.NewRow();
                                row["RUNS"] = i.ToString();
                                if (i < runs)
                                {
                                    int Amount1 = Amount * -1;
                                    row["Amount"] =
                                        System.Drawing.Color.Red;
                                    row["AMOUNT"] = Amount1;
                                }
                                if (i >= runs)
                                {
                                    int Amount1 = Amount;
                                    row["Amount"] = System.Drawing.Color.Blue;
                                    row["AMOUNT"] = Amount1;
                                }


                                runTable.Rows.Add(row.ItemArray);
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int    MatchID = Convert.ToInt32(Request.QueryString["MatchID"]);
                string CN      = ConfigurationManager.ConnectionStrings["DBMS"].ConnectionString;
                using (MySqlConnection cn = new MySqlConnection(CN))
                {
                    cn.Open();
                    string           Client    = "Select * From ClientMaster";
                    MySqlCommand     Clientcmd = new MySqlCommand(Client, cn);
                    MySqlDataAdapter Clientadp = new MySqlDataAdapter(Clientcmd);
                    DataTable        Clientdt  = new DataTable();
                    Clientadp.Fill(Clientdt);
                    DropDownClient.DataSource     = Clientdt;
                    DropDownClient.DataTextField  = "Name";
                    DropDownClient.DataValueField = "ClientID";
                    DropDownClient.DataBind();

                    string           s1   = "Select SessionID,Session From Session where MatchID = '" + MatchID + "' group by session";
                    MySqlCommand     cmd1 = new MySqlCommand(s1, cn);
                    MySqlDataAdapter adp1 = new MySqlDataAdapter(cmd1);
                    DataTable        dt1  = new DataTable();
                    adp1.Fill(dt1);
                    DropDownSession.DataSource = dt1;
                    DropDownSession.DataBind();
                    DropDownSession.DataTextField  = "Session";
                    DropDownSession.DataValueField = "Session";
                    DropDownSession.DataBind();

                    string           s2   = "select Session.sessionID,Session.session,Session.Runs,Session.Amount,Session.rate,Session.Mode,Session.DateTime,Session.Team,Session.clientID,clientmaster.Name from Session inner join clientmaster on Session.ClientID = clientmaster.ClientID where  Session.MatchID = '0'";
                    MySqlCommand     cmd2 = new MySqlCommand(s2, cn);
                    MySqlDataAdapter adp2 = new MySqlDataAdapter(cmd2);
                    dt = new DataTable();
                    adp2.Fill(dt);

                    runTable = new DataTable();
                    runTable.Columns.Add(new DataColumn("RUNS"));
                    runTable.Columns.Add(new DataColumn("AMOUNT"));
                    if (dt.Rows.Count > 0)
                    {
                        int runs   = Convert.ToInt16(dt.Rows[0]["Runs"]);
                        int Amount = Convert.ToInt32(dt.Rows[0]["Amount"]);
                        for (int i = runs - 10; i <= runs + 10; i++)
                        {
                            DataRow row = runTable.NewRow();
                            row["RUNS"] = i.ToString();
                            if (i < runs)
                            {
                                int Amount1 = Amount * -1;
                                row["Amount"] =
                                    System.Drawing.Color.Red;
                                row["AMOUNT"] = Amount1;
                            }
                            if (i >= runs)
                            {
                                int Amount1 = Amount;
                                row["Amount"] = System.Drawing.Color.Blue;
                                row["AMOUNT"] = Amount1;
                            }


                            runTable.Rows.Add(row.ItemArray);
                        }
                    }
                }
            }
        }