private void Txt_Secund_Name_Enter_1(object sender, EventArgs e)
 {
     if (Txt_Secund_Name.Text == "")
     {
         Txt_Secund_Name.ResetText();
     }
 }
        private void BunifuThinButton21_Click(object sender, EventArgs e)
        {
            int x = 0;

            PictureBox[] required_fieldd = new PictureBox[8];
            required_fieldd[0] = Required_field1;
            required_fieldd[1] = Required_field2;
            required_fieldd[2] = Required_field3;
            required_fieldd[3] = Required_field4;
            required_fieldd[4] = Required_field5;
            required_fieldd[5] = Required_field6;
            required_fieldd[6] = Required_field7;
            required_fieldd[7] = Required_field8;
            BunifuMaterialTextbox[] txt = new BunifuMaterialTextbox[6];
            // TextBox[] txt = new TextBox[6];
            txt[0] = Txt_First_Name;
            txt[1] = Txt_Secund_Name;
            txt[2] = Txr_Familly_Name;
            txt[3] = Txt_Age;
            txt[4] = Txt_Phone_No;
            txt[5] = Txt_Date_time;
            for (int i = 0; i <= 7; i++)
            {
                if (i >= 5)
                {
                    if (comboBox1_Type.Text.Length == 0 && i == 5)
                    {
                        Error_icon.Visible         = true;
                        Error.Visible              = true;
                        required_fieldd[i].Visible = true;
                        x++;
                    }
                    if (comboBox2_Type_of_discover.Text.Length == 0 && i == 6)
                    {
                        Error_icon.Visible         = true;
                        Error.Visible              = true;
                        required_fieldd[i].Visible = true;
                        x++;
                    }
                    if (comboBox4_Name_of_Doctor.Text.Length == 0 && i == 7)
                    {
                        Error_icon.Visible         = true;
                        Error.Visible              = true;
                        required_fieldd[i].Visible = true;
                        x++;
                    }
                }
                if (i <= 5)
                {
                    //if (i == 5 && txt[i].Text == "")
                    //{
                    //    Error_icon.Visible = true;
                    //    Error.Visible = true;
                    //    required_fieldd[i + 3].Visible = true;
                    //    x++;

                    //}
                    if (txt[i].Text == "" && i != 5)
                    {
                        Error_icon.Visible         = true;
                        Error.Visible              = true;
                        required_fieldd[i].Visible = true;
                        x++;
                    }
                }
            }
            //   int c = 0;
            if (x == 0)    // save into DataBase
            {
                DialogResult result1 = MessageBox.Show(" حفظ ومتابعه  ",
                                                       " تأكد علي ان  كافة البيانات المريض جميعها صحيحه ",
                                                       MessageBoxButtons.YesNo,
                                                       MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                if (result1 == DialogResult.Yes)
                {
                    DateTime test = new DateTime();
                    test        = DateTime.Now;
                    txt[5].Text = string.Format("{0:dd/M/yyyy  hh:mmtt}", test);
                    SqlConnection connect = new SqlConnection(@"Data Source=PROJECT\MYDATABASE;Initial Catalog=MinaData;Integrated Security=True");
                    string        query   = "INSERT INTO Patient_Table (FirstName,FatherName,FamilyName,Age,Address,PhoneNumber,Sex,Detection,DoctorName,DateBooked,Descption,Price_of_discover,User_Name)VALUES('" + this.Txt_First_Name.Text + "'," +
                                            "'" + this.Txt_Secund_Name.Text + "','" + this.Txr_Familly_Name.Text + "','" + this.Txt_Age.Text + "','" + this.Txt_Address.Text + "','" + this.Txt_Phone_No.Text + "','" + this.comboBox1_Type.Text + "','" + this.comboBox2_Type_of_discover.Text + "','" + this.comboBox4_Name_of_Doctor.Text + "','" + txt[5].Text + "','" + this.richTextBox1_Description.Text + "','" + this.price + "','" + this.user + "');";
                    SqlDataAdapter sda   = new SqlDataAdapter(query, connect);
                    DataTable      table = new DataTable();
                    sda.Fill(table);
                    Txt_First_Name.ResetText();
                    Txt_First_Name.LineIdleColor = Color.Red;
                    Txt_Secund_Name.ResetText();
                    Txt_Secund_Name.LineIdleColor = Color.Red;
                    Txr_Familly_Name.ResetText();
                    Txr_Familly_Name.LineIdleColor = Color.Red;
                    Txt_Age.ResetText();
                    Txt_Age.LineIdleColor = Color.Red;
                    Txt_Address.ResetText();
                    Txt_Phone_No.ResetText();
                    Txt_Phone_No.LineIdleColor      = Color.Red;
                    comboBox1_Type.Text             = "";
                    comboBox2_Type_of_discover.Text = "";
                    comboBox4_Name_of_Doctor.Text   = "";
                    richTextBox1_Description.Clear();
                    Txt_Price.Clear();
                    using (StreamWriter increase_Teller = new StreamWriter(@"C:\Users\menas\source\repos\temple\temple\bin\Debug\data1.txt"))
                    {
                        increase_Teller.Write(s);
                    }
                    MessageBox.Show("تم حفظ البيانات بنجاح", "عمليه ناجحه");

                    query = " select patient_iD from Patient_Table where Patient_iD = (select max(Patient_iD) from Patient_Table);";
                    SqlDataAdapter sdaa = new SqlDataAdapter(query, connect);
                    sdaa.Fill(table);
                    x = Int32.Parse(table.Rows[0][0].ToString()) + 1;
                    txt_id.Clear();
                    textBox1.Text = "00000";
                    txt_id.Text   = x.ToString();
                }
                else
                {
                    return;
                }
            }
        }