private void TexClear() { TxtNumber.Clear(); TxtUsername.Clear(); txtEmail.Clear(); txtNoPhone.Clear(); txtPassword.Clear(); }
private bool CheckValue() { if (string.IsNullOrEmpty(TxtName.Text)) { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('会议名称不能为空!');", true); TxtName.Focus(); return(false); } if (string.IsNullOrEmpty(TxtTheme.Text)) { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('主题不能为空!');", true); TxtTheme.Focus(); return(false); } if (string.IsNullOrEmpty(TxtStartTime.Text)) { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('开始时间不能为空!');", true); TxtStartTime.Focus(); return(false); } if (string.IsNullOrEmpty(TxtEndTime.Text)) { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('结束时间不能为空!');", true); TxtEndTime.Focus(); return(false); } if (string.IsNullOrEmpty(TxtCity.Text)) { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('所在城市不能为空!');", true); TxtCity.Focus(); return(false); } if (string.IsNullOrEmpty(TxtStreet.Text)) { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('街道不能为空!');", true); TxtStreet.Focus(); return(false); } if (string.IsNullOrEmpty(TxtNumber.Text)) { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('门牌号不能为空!');", true); TxtNumber.Focus(); return(false); } if (string.IsNullOrEmpty(TxtDept.Text)) { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('所属部门不能为空!');", true); TxtDept.Focus(); return(false); } return(true); }
/// <summary>Clears all TextBoxes.</summary> private void Clear() { TxtNumber.Clear(); TxtName.Clear(); TxtHours.Clear(); }
public NewCourseView() { InitializeComponent(); TxtNumber.Focus(); }
//button register private void BtnLogin_Click(object sender, EventArgs e) { //MessageBox.Show(rezult); if (TxtFirstname.Text == "") { MessageBox.Show("Please enter confirm password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); TxtFirstname.Focus(); return; } if (TxtFamilyname.Text == "") { MessageBox.Show("Please enter username", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); TxtFamilyname.Focus(); return; } if (TxtData.Text == "") { MessageBox.Show("Please enter username", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); TxtData.Focus(); return; } if (TxtNumber.Text == "") { MessageBox.Show("Please enter username", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); TxtNumber.Focus(); return; } try { SqlConnection myConnection = default(SqlConnection); myConnection = new SqlConnection(@"Data Source=DESKTOP-NP1RDM2\BAZALUIMARIAN;Initial Catalog=task;Persist Security Info=True;User ID=sa; Password = 0299"); String query = "INSERT INTO dbo.Clientapp (family_name,first_name,clientappdate,number) VALUES (@family_name,@first_name,@clientappdate,@number)"; using (SqlCommand command = new SqlCommand(query, con)) { command.Parameters.AddWithValue("@family_name", TxtFamilyname.Text); command.Parameters.AddWithValue("@first_name", TxtFirstname.Text); command.Parameters.AddWithValue("@clientappdate", TxtData.Text); command.Parameters.AddWithValue("@number", TxtNumber.Text); MessageBox.Show("Register successfully !We will call you back today !", "Register Successfully", MessageBoxButtons.OK, MessageBoxIcon.Error); con.Open(); int result = command.ExecuteNonQuery(); Hide(); // Check Error if (result < 0) { MessageBox.Show("Register Denied", "Register Denied", MessageBoxButtons.OK, MessageBoxIcon.Error); TxtNumber.Clear(); TxtFirstname.Clear(); TxtFamilyname.Clear(); TxtData.Clear(); TxtFamilyname.Focus(); Close(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }