Use
How do I use Use
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: ClassBLL.cs
Copy
191 public int CheckLogin(string name, string pass)
192 {
193 SqlConnection con = da.GetConnect();
194 SqlCommand cmd = new SqlCommand("select *from Users Where Username='"+name+"' and Password='"+pass+"'",con);
195 con.Open();
196 SqlDataReader dr = cmd.ExecuteReader();
197 if (dr.Read())
198 {
199 if (dr[2].ToString() == "admin")
200 {
201 return 1;
202 }
203 else
204 {
205 return 2;
206 }
207 }
208 else
209 {
210 return -1;
211 }
212 }
File name: ClassDAL.cs
Copy
12 public SqlConnection GetConnect()
13 {
14 return new SqlConnection("server=TY-PC;User id=sa;password=04091990;database=CNPM_1");
15 }
File name: FormBaoCao.cs
Copy
40 private void btnLoc_Click(object sender, EventArgs e)
41 {
42 SqlConnection con = dal.GetConnect();
43 con.Open();
44 string sql = "select *from SinhVien where MaLop=@MaLop";
45 SqlDataAdapter da = new SqlDataAdapter(sql, con);
46 da.SelectCommand.Parameters.AddWithValue("@MaLop", cmbMaLop.SelectedValue.ToString());
47 DataTable dt = new DataTable();
48 da.Fill(dt);
49 crBaoCao cr = new crBaoCao();
50 ConnectionInfo crConnectionInfo = new ConnectionInfo();
51 crConnectionInfo.ServerName = "Ty-PC";
52 crConnectionInfo.DatabaseName = "CNPM_1";
53 crConnectionInfo.UserID = "sa";
54 crConnectionInfo.Password = "04091990";
55 TableLogOnInfos crTableLogonInfos = new TableLogOnInfos();
56 foreach (CrystalDecisions.CrystalReports.Engine.Table table in cr.Database.Tables)
57 {
58 TableLogOnInfo crTableLogonInfo = new TableLogOnInfo();
59 crTableLogonInfo.TableName = table.Name;
60 crTableLogonInfo.ConnectionInfo = crConnectionInfo;
61 crTableLogonInfos.Add(crTableLogonInfo);
62 table.ApplyLogOnInfo(crTableLogonInfo);
63
64 }
65 crvHocKyHocPhan.LogOnInfo = crTableLogonInfos;
66 cr.SetDataSource(dt);
67 ParameterValues a = new ParameterValues();
68 ParameterDiscreteValue b = new ParameterDiscreteValue();
69 b.Value = cmbMaLop.SelectedValue.ToString();
70 a.Add(b);
71 cr.DataDefinition.ParameterFields["txtMaLop"].ApplyCurrentValues(a);
72 crvHocKyHocPhan.ReportSource = cr;
73 crvHocKyHocPhan.Show();
74 }
File name: FormPhanQuyen.cs
Copy
20 private void FormPhanQuyen_Load(object sender, EventArgs e)
21 {
22 dgvUsers.DataSource = business.ShowData("Users");
23 }
File name: FormPhanQuyen.cs
Copy
25 private void dgvUsers_RowEnter(object sender, DataGridViewCellEventArgs e)
26 {
27 dong = e.RowIndex;
28 txtTenDangNhap.Text = dgvUsers.Rows[dong].Cells[0].Value.ToString();
29 txtMatKhau.Text = dgvUsers.Rows[dong].Cells[1].Value.ToString();
30 if (dgvUsers.Rows[dong].Cells[2].Value.ToString() == "admin")
31 {
32 cmbQuyen.SelectedIndex = 1;
33 }
34 else
35 {
36 cmbQuyen.SelectedIndex = 0;
37 }
38 }
File name: FormPhanQuyen.cs
Copy
45 private void btnThem_Click(object sender, EventArgs e)
46 {
47
48 if(txtTenDangNhap.Text!="")
49 {
50 if(business.Proc_Insert("Insert_Users",txtTenDangNhap.Text))
51 {
52 string sql = "'" + txtTenDangNhap.Text + "','" + txtMatKhau.Text + "','" + cmbQuyen.SelectedItem.ToString() + "'";
53 business.Insert("Users",sql);
54 FormPhanQuyen_Load(sender, e);
55 }
56 else
57 {
58 MessageBox.Show("Username này đã tồn tại");
59 }
60 }
61 }
File name: FormPhanQuyen.cs
Copy
63 private void btnXoa_Click(object sender, EventArgs e)
64 {
65 DialogResult result;
66 result = MessageBox.Show("Bạn có chắc chắn muốn xóa không ?","Hệ Thống", MessageBoxButtons.YesNo);
67 if (result == DialogResult.Yes)
68 {
69 string sql = "Username='" + txtTenDangNhap.Text + "'";
70 business.Delete("Users", sql);
71 FormPhanQuyen_Load(sender, e);
72 }
73 }
File name: FormPhanQuyen.cs
Copy
75 private void btnSua_Click(object sender, EventArgs e)
76 {
77 string sql = "Password='" + txtMatKhau.Text + "',Quyen='" + cmbQuyen.SelectedItem.ToString() + "' where Username='"+txtTenDangNhap.Text+"'";
78 business.Update("Users",sql);
79 FormPhanQuyen_Load(sender, e);
80 }
File name: MaterialPerOwner.cs
Copy
18 private void Update()
19 {
20 if( this.photonView.ownerId != assignedColorForUserId )
21 {
22 m_Renderer.material = PlayerVariables.GetMaterial( m_Renderer.material, this.photonView.ownerId );
23 this.assignedColorForUserId = this.photonView.ownerId;
24 //Debug.Log("Switched Material to: " + this.assignedColorForUserId + " " + this.renderer.material.GetInstanceID());
25 }
26 }
Download file with original file name:Use
Use 128 lượt xem
Gõ tìm kiếm nhanh...