private void txtfamily_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { Codemeli.Focus(); } }
private void btnsabt_Click(object sender, EventArgs e) { //try //برای مدیریت خطا //{ OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Application.StartupPath + "\\Database.accdb"); //کدهای اتصال به پایگاه داده ها con.Open(); OleDbCommand com = new OleDbCommand(); //if (naghd.Checked) //{ // noe = "نقد"; //} //else //{ // noe = "چک"; //} if (comboBoxEx1.SelectedIndex == 0) { noe = "نقد"; } else if (comboBoxEx1.SelectedIndex == 1) { noe = "نقد و چک"; } com.CommandText = "insert into table1(name,family,mobile,codemeli,noebime,Price,noepardakht,baghimande) values('" + txtname.Text + "','" + txtfamily.Text + "','" + txtmobile.Text + "','" + Codemeli.Text + "','" + txtnobime.Text + "','" + Price.Text + "','" + noe + "','" + textBox2.Text + "')"; // کد درج در پایگاه داده ها com.Connection = con; com.ExecuteNonQuery(); con.Close(); MessageBox.Show("داده ها با موفقیت ثبت شدند"); txtname.Clear(); //پاک کردن تکست باکس ها txtfamily.Clear(); txtmobile.Clear(); txtnobime.Clear(); Codemeli.Clear(); Price.Clear(); // textBox1.Clear(); textBox2.Clear(); //} //catch //برای مدیریت خطا //{ // MessageBox.Show("خطا در اتصال به بانک اطلاعاتی"); //} }