Exemple #1
0
        public void btn2score_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if ((comboboxvalue.value[0] == "0" && comboboxvalue.value[1] == "0") || (comboboxvalue.value[0] == "1" && comboboxvalue.value[1] == "1"))
                {
                    secondinngcount1 = teamB.Count;
                    secondinngcount2 = teamA.Count;
                }
                else
                {
                    secondinngcount1 = teamA.Count;
                    secondinngcount2 = teamB.Count;
                }

                ScoreCardBLL objscorecardplay = new ScoreCardBLL();

                if (txtbyes2.Text == "" || txtlegbyes2.Text == "" || txtpenalty2.Text == "" || txtrunout2.Text == "")
                {
                    extras2_empty();
                }

                else
                {

                    for (int i = 0; i <= (secondinngcount1 - 1); i++)
                    {

                        if (!DBNull.Value.Equals((dgvbat2.Items[i] as DataRowView).Row.ItemArray[4]) && ((dgvbat2.Items[i] as DataRowView).Row.ItemArray[4]).ToString() != "")
                        {
                            R2 = Convert.ToInt16((dgvbat2.Items[i] as DataRowView).Row.ItemArray[4]);
                            runs2 = objscorecardplay.runs2(R2);
                        }
                    }

                    for (int j = 0; j <= (secondinngcount2 - 1); j++)
                    {
                        if (!DBNull.Value.Equals((dgvbowl2.Items[j] as DataRowView).Row.ItemArray[8]) && ((dgvbowl2.Items[j] as DataRowView).Row.ItemArray[8]).ToString() != "")
                        {
                            W2 = Convert.ToInt16((dgvbowl2.Items[j] as DataRowView).Row.ItemArray[8]);
                            wides2 = objscorecardplay.wides2(W2);
                        }
                    }

                    for (int k = 0; k <= (secondinngcount2 - 1); k++)
                    {
                        if (!DBNull.Value.Equals((dgvbowl2.Items[k] as DataRowView).Row.ItemArray[7]) && ((dgvbowl2.Items[k] as DataRowView).Row.ItemArray[7]).ToString() != "")
                        {
                            N2 = Convert.ToInt16((dgvbowl2.Items[k] as DataRowView).Row.ItemArray[7]);
                            noballs2 = objscorecardplay.noball2(N2);
                        }
                    }

                    for (int m = 0; m <= (secondinngcount2 - 1); m++)
                    {
                        if (!DBNull.Value.Equals((dgvbowl2.Items[m] as DataRowView).Row.ItemArray[6]) && ((dgvbowl2.Items[m] as DataRowView).Row.ItemArray[6]).ToString() != "")
                        {
                            Wkts2 = Convert.ToInt16((dgvbowl2.Items[m] as DataRowView).Row.ItemArray[6]);
                            wickts2 = objscorecardplay.wickets2(Wkts2);
                        }
                    }
                    int runout2 = Convert.ToInt16(txtrunout2.Text);
                    wickts2 = wickts2 + runout2;

                    for (int n = 0; n <= (secondinngcount2 - 1); n++)
                    {
                        if (!DBNull.Value.Equals((dgvbowl2.Items[n] as DataRowView).Row.ItemArray[5]) && ((dgvbowl2.Items[n] as DataRowView).Row.ItemArray[5]).ToString() != "")
                        {
                            BR2 = Convert.ToInt16((dgvbowl2.Items[n] as DataRowView).Row.ItemArray[5]);
                            bruns2 = objscorecardplay.bowlerruns2(BR2);
                        }
                    }

                    for (int ov = 0; ov <= (secondinngcount2 - 1); ov++)
                    {
                        if (!DBNull.Value.Equals((dgvbowl2.Items[ov] as DataRowView).Row.ItemArray[3]) && ((dgvbowl2.Items[ov] as DataRowView).Row.ItemArray[3]).ToString() != "")
                        {
                            O2 = Convert.ToDouble((dgvbowl2.Items[ov] as DataRowView).Row.ItemArray[3]);
                            overs2 = objscorecardplay.overs2(O2);
                        }
                    }

                    txttotalextras2.Text = (wides2 + noballs2 + Convert.ToInt16(txtpenalty2.Text) + Convert.ToInt16(txtbyes2.Text) + Convert.ToInt16(txtlegbyes2.Text)).ToString();
                    txtruns2.Text = (runs2 + wides2 + noballs2 + Convert.ToInt16(txtpenalty2.Text) + Convert.ToInt16(txtbyes2.Text) + Convert.ToInt16(txtlegbyes2.Text)).ToString();
                    txtwickets2.Text = wickts2.ToString();
                    txtovers2.Text = overs2.ToString();

                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void btn2scorefirstinngs_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (chkmatchnotplayed.IsChecked == false)
                {

                    int runs2firstinngs = 0;
                    int wides2firstinngs = 0;
                    int noballs2firstinngs = 0;
                    int wickts2firstinngs = 0;
                    int bruns2firstinngs = 0;
                    double overs2firstinngs = 0;

                    int R2firstinngs = 0;
                    int W2firstinngs = 0;
                    int N2firstinngs = 0;
                    int Wkts2firstinngs = 0;
                    int BR2firstinngs = 0;
                    double O2firstinngs = 0;

                    if ((comboboxvalue.value[0] == "0" && comboboxvalue.value[1] == "0") || (comboboxvalue.value[0] == "1" && comboboxvalue.value[1] == "1"))
                    {
                        firstinng2count1 = teamB.Count;
                        firstinng2count2 = teamA.Count;
                    }
                    else
                    {
                        firstinng2count1 = teamA.Count;
                        firstinng2count2 = teamB.Count;
                    }

                    ScoreCardBLL objscorecardplay = new ScoreCardBLL();

                    if (txtbyes2firstinngs.Text == "" || txtlegbyes2firstinngs.Text == "" || txtpenalty2firstinngs.Text == "" || txtrunout2firstinngs.Text == "")
                    {
                        extras2firstinngs_empty();
                    }

                    else
                    {

                        for (int i = 0; i <= (firstinng2count1 - 1); i++)
                        {

                            if (!DBNull.Value.Equals((dgvbat2firstinngs.Items[i] as DataRowView).Row.ItemArray[4]) && ((dgvbat2firstinngs.Items[i] as DataRowView).Row.ItemArray[4]).ToString() != "")
                            {
                                R2firstinngs = Convert.ToInt16((dgvbat2firstinngs.Items[i] as DataRowView).Row.ItemArray[4]);
                                runs2firstinngs = objscorecardplay.runs2(R2firstinngs);
                            }
                        }

                        for (int j = 0; j <= (firstinng2count2 - 1); j++)
                        {
                            if (!DBNull.Value.Equals((dgvbowl2firstinngs.Items[j] as DataRowView).Row.ItemArray[8]) && ((dgvbowl2firstinngs.Items[j] as DataRowView).Row.ItemArray[8]).ToString() != "")
                            {
                                W2firstinngs = Convert.ToInt16((dgvbowl2firstinngs.Items[j] as DataRowView).Row.ItemArray[8]);
                                wides2firstinngs = objscorecardplay.wides2(W2firstinngs);
                            }
                        }

                        for (int k = 0; k <= (firstinng2count2 - 1); k++)
                        {
                            if (!DBNull.Value.Equals((dgvbowl2firstinngs.Items[k] as DataRowView).Row.ItemArray[7]) && ((dgvbowl2firstinngs.Items[k] as DataRowView).Row.ItemArray[7]).ToString() != "")
                            {
                                N2firstinngs = Convert.ToInt16((dgvbowl2firstinngs.Items[k] as DataRowView).Row.ItemArray[7]);
                                noballs2firstinngs = objscorecardplay.noball2(N2firstinngs);
                            }
                        }

                        for (int m = 0; m <= (firstinng2count2 - 1); m++)
                        {
                            if (!DBNull.Value.Equals((dgvbowl2firstinngs.Items[m] as DataRowView).Row.ItemArray[6]) && ((dgvbowl2firstinngs.Items[m] as DataRowView).Row.ItemArray[6]).ToString() != "")
                            {
                                Wkts2firstinngs = Convert.ToInt16((dgvbowl2firstinngs.Items[m] as DataRowView).Row.ItemArray[6]);
                                wickts2firstinngs = objscorecardplay.wickets2(Wkts2firstinngs);
                            }
                        }

                        int runout1 = Convert.ToInt16(txtrunout2firstinngs.Text);
                        wickts2firstinngs = wickts2firstinngs + runout1;

                        for (int n = 0; n <= (firstinng2count2 - 1); n++)
                        {
                            if (!DBNull.Value.Equals((dgvbowl2firstinngs.Items[n] as DataRowView).Row.ItemArray[5]) && ((dgvbowl2firstinngs.Items[n] as DataRowView).Row.ItemArray[5]).ToString() != "")
                            {
                                BR2firstinngs = Convert.ToInt16((dgvbowl2firstinngs.Items[n] as DataRowView).Row.ItemArray[5]);
                                bruns2firstinngs = objscorecardplay.bowlerruns2(BR2firstinngs);
                            }
                        }

                        for (int ov = 0; ov <= (firstinng2count2 - 1); ov++)
                        {
                            if (!DBNull.Value.Equals((dgvbowl2firstinngs.Items[ov] as DataRowView).Row.ItemArray[3]) && ((dgvbowl2firstinngs.Items[ov] as DataRowView).Row.ItemArray[3]).ToString() != "")
                            {
                                O2firstinngs = Convert.ToDouble((dgvbowl2firstinngs.Items[ov] as DataRowView).Row.ItemArray[3]);
                                overs2firstinngs = objscorecardplay.overs2(O2firstinngs);
                            }
                        }

                        txttotalextras2firstinngs.Text = (wides2firstinngs + noballs2firstinngs + Convert.ToInt16(txtpenalty2firstinngs.Text) + Convert.ToInt16(txtbyes2firstinngs.Text) + Convert.ToInt16(txtlegbyes2firstinngs.Text)).ToString();
                        txtruns2firstinngs.Text = (runs2firstinngs + wides2firstinngs + noballs2firstinngs + Convert.ToInt16(txtpenalty2firstinngs.Text) + Convert.ToInt16(txtbyes2firstinngs.Text) + Convert.ToInt16(txtlegbyes2firstinngs.Text)).ToString();
                        txtwickets2firstinngs.Text = wickts2firstinngs.ToString();
                        txtovers2firstinngs.Text = overs2firstinngs.ToString();

                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }