elham deljooei

elham deljooei

  • NA
  • 84
  • 73.2k

How to determine each number of those contorols?

Jan 22 2013 5:39 AM
Hi everyone.
I have 10 Lable and 10 TextBox.
I want to send a number of contorols on the form to sql and sql to do own order base on this number. 
How to determine each number of those contorols?

 private void btnSabtClerkEvaluation_Click(object sender, EventArgs e)
        {
            try
            {
                if (lbl1MadrakeTahsili1.Text.Trim() == string.Empty || lbl2Takhasos2.Text.Trim() == string.Empty || lbl3Khalaghiat3.Text.Trim() == string.Empty || lbl4Nazm4.Text.Trim() == string.Empty || lbl5Raftar5.Text.Trim() == string.Empty ||
                   lbl6Taamol6.Text.Trim() == string.Empty || lbl7Masouliatpaziri7.Text.Trim() == string.Empty || lbl8Arastegi8.Text.Trim() == string.Empty || lbl9MizaneKhata9.Text.Trim() == string.Empty || lbl10SakhtiKar10.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    SqlCommand cmd = new SqlCommand("ClerkEvaluation_Insert", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    for (int i = 0; i <= 10; i++)
                    {

                        cmd.Parameters.AddWithValue("@clrk_Name", txtNameClerkEvaluation.Text);
                        cmd.Parameters.AddWithValue("@clrk_Family", txtFamilyClerkEvaluation.Text);
                        cmd.Parameters.AddWithValue("@clrk_MelliCode", txtMelliCodeClerkEvaluation.Text);

                        cmd.Parameters.AddWithValue("@clrke_Percent", lbl[i].Text);// this name is lbl1. How to give number?
                        cmd.Parameters.AddWithValue("@clrke_Tozihat", txt[i].Text);// This name is lbl2
                        conn.Open();
                        cmd.ExecuteNonQuery();
                        conn.Close();
                    }
                }
            }
}

Answers (10)