Advertisement
jlalt

form1 codes

Sep 11th, 2017
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.68 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Data.SqlClient;
  10.  
  11. namespace music
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         SqlDataAdapter da = new SqlDataAdapter();
  16.         DataSet ds = new DataSet();
  17.  
  18.         SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\sazdb.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
  19.         SqlCommand cm = new SqlCommand();
  20.         public Form1()
  21.         {
  22.             InitializeComponent();
  23.         }
  24.  
  25.         private void button1_Click(object sender, EventArgs e)
  26.         {
  27.             con.Open();
  28.             da = new SqlDataAdapter("select * from addmin ", con);
  29.  
  30.             ds.Reset();
  31.             da.Fill(ds, "addmin");
  32.  
  33.             da.SelectCommand = cm;
  34.  
  35.  
  36.             if (textBox3.Text == Convert.ToString(ds.Tables["addmin"].Rows[0][0]) &&
  37.                 textBox4.Text == Convert.ToString(ds.Tables["addmin"].Rows[0][1]))
  38.             {
  39.                 Form objform1 = new main();
  40.  
  41.                 objform1.Show();
  42.  
  43.  
  44.             }
  45.  
  46.             else
  47.             {
  48.                 if (textBox3.Text != Convert.ToString(ds.Tables["addmin"].Rows[0][0]))
  49.                     MessageBox.Show("نام کاربری اشتباه است ");
  50.                 if (textBox4.Text != Convert.ToString(ds.Tables["addmin"].Rows[0][1]))
  51.                     MessageBox.Show("کلمه عبور اشتباه است");
  52.             }
  53.             con.Close();
  54.  
  55.         }
  56.  
  57.         private void button2_Click(object sender, EventArgs e)
  58.         {
  59.             con.Open();
  60.             da = new SqlDataAdapter("select * from honarjoo where code='" + textBox2.Text + "'", con);
  61.             ds.Reset();
  62.             da.Fill(ds, "honarjoo");
  63.  
  64.             da.SelectCommand = cm;
  65.  
  66.  
  67.             if (textBox2.Text == Convert.ToString(ds.Tables["honarjoo"].Rows[0][4]))
  68.             {
  69.                 Form objform1 = new honarjoo();
  70.  
  71.                 objform1.Show();
  72.  
  73.  
  74.             }
  75.  
  76.             else
  77.             {
  78.                 if (textBox2.Text != Convert.ToString(ds.Tables["honarjoo"].Rows[0][4]))
  79.                     MessageBox.Show("رمز اشتباه است ");
  80.  
  81.             }
  82.  
  83.  
  84.  
  85.             con.Close();
  86.         }
  87.  
  88.         private void button3_Click(object sender, EventArgs e)
  89.         {
  90.             if (MessageBox.Show("آیا قصد خروج از برنامه را دارید؟", "", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
  91.                 this.Close();
  92.         }
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement