private void btnCancel_Click(object sender, EventArgs e) { this.Hide(); control frm = new control(); frm.ShowDialog(); }
private void btnLogin_Click(object sender, EventArgs e) { SqlConnection cn = new SqlConnection(@"Server=study-pc\KEROLES; Initial catalog=VECS3; Integrated Security=false; User ID=sa; password=123"); SqlCommand cm; SqlDataAdapter sda = new SqlDataAdapter("select count(*)from admin1 where username ='******' and password='******'", cn); DataTable dt = new DataTable(); sda.Fill(dt); if (dt.Rows[0][0].ToString() == "1") { // MessageBox.Show("Login Success"); this.Hide(); control frm = new control(); frm.ShowDialog(); } else { MessageBox.Show("Please Ckeck Your User Name and Password"); } }
private void btnAdd_Click(object sender, EventArgs e) { try { cmd = new SqlCommand("Insert into devices (type,ip,status,location,name,admin_id,device_num) values ('" + txttype.Text + "','" + txtip.Text + "','" + txtStatus.Text + "','" + txtlocation.Text + "','" + txtname.Text + "','" + txtadmin_id.Text + "','" + txtDevice_num.Text + "')", cn); cn.Open(); cmd.ExecuteNonQuery(); MessageBox.Show("Add Successfuly ", "Add", MessageBoxButtons.OK, MessageBoxIcon.Information); cn.Close(); this.Hide(); control frm = new control(); frm.ShowDialog(); } catch (SqlException ex) { MessageBox.Show("some Errors was occured " + ex.Message); } finally { cn.Close(); } }