Int32
How do I use Int32
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: FormHocPhan.cs
Copy
25 private void btnThem_Click(object sender, EventArgs e)
26 {
27 if (txtMaHP.Text != "")
28 {
29 if (business.Proc_Insert("Insert_HocPhan", txtMaHP.Text))
30 {
31 string sql = "'" + txtMaHP.Text + "','" + txtTenHP.Text + "'," + Convert.ToInt32(txtSoTC.Text) + "," + Convert.ToInt32(txtSoTietTH.Text) + "," + Convert.ToInt32(txtSoTietLT.Text) + "," + Convert.ToInt32(txtPhanTramDQT.Text) + "," + Convert.ToInt32(txtPhanTramDT.Text) + "";
32 business.Insert("HocPhan",sql);
33 FormHocPhan_Load(sender,e);
34 }
35 else
36 {
37 MessageBox.Show("Mã Học Phần đã tồn tại");
38 }
39 }
40 }
File name: FormHocPhan.cs
Copy
53 private void btnSua_Click(object sender, EventArgs e)
54 {
55 string sql = "TenHP='" + txtTenHP.Text + "',SoTC=" + Convert.ToInt32(txtSoTC.Text) + ",SoTietTH=" + Convert.ToInt32(txtSoTietTH.Text) + ",SoTietLT=" + Convert.ToInt32(txtSoTietLT.Text) + ",PhanTramDQT=" + Convert.ToInt32(txtPhanTramDQT.Text) + ",PhanTramDT=" + Convert.ToInt32(txtPhanTramDT.Text) + " where MaHP='"+txtMaHP.Text+"'";
56 business.Update("HocPhan", sql);
57 FormHocPhan_Load(sender, e);
58 }
File name: FormThongKe.cs
Copy
69 private void btnLoc_Click(object sender, EventArgs e)
70 {
71
72 if (cmbThongKeTheo.SelectedIndex != -1)
73 {
74 if (cmbThongKeTheo.SelectedIndex == 0)
75 {
76 if (Convert.ToInt32(cmbMa.SelectedIndex) != -1)
77 {
78 dgvThongKe.DataSource= business.ThongKeLop(cmbMaHK.SelectedValue.ToString(),cmbMa.SelectedValue.ToString(),Convert.ToInt32(cmbXepLoai.SelectedIndex));
79 }
80 }
81 else
82 {
83 if (Convert.ToInt32(cmbMa.SelectedIndex) != -1)
84 {
85 dgvThongKe.DataSource = business.ThongKeKhoiLop(cmbMaHK.SelectedValue.ToString(), cmbMa.SelectedValue.ToString(), Convert.ToInt32(cmbXepLoai.SelectedIndex));
86 }
87 }
88 }
89 }
File name: FormXemDiemLop.cs
Copy
59 private void btnXem_Click(object sender, EventArgs e)
60 {
61 if (chbXemTatCa.Checked == true)
62 {
63 if (Convert.ToInt32(cmbMaLop.SelectedIndex) != -1)
64 {
65 dgvKetQua.DataSource = business.XemDiemLop(cmbMaLop.SelectedValue.ToString());
66 }
67 }
68 else
69 {
70 if (Convert.ToInt32(cmbMaLop.SelectedIndex) != -1 && Convert.ToInt32(cmbMaHK.SelectedIndex) != -1)
71 {
72 dgvKetQua.DataSource = business.XemDiemLop(cmbMaHK.SelectedValue.ToString(), cmbMaLop.SelectedValue.ToString());
73 }
74 }
75 }
File name: NetworkingPeer.cs
Copy
690 private void CheckMasterClient(int leavingPlayerId)
691 {
692 bool currentMasterIsLeaving = this.mMasterClient != null && this.mMasterClient.ID == leavingPlayerId;
693 bool someoneIsLeaving = leavingPlayerId > 0;
694
695 // return early if SOME player (leavingId > 0) is leaving AND it's NOT the current master
696 if (someoneIsLeaving && !currentMasterIsLeaving)
697 {
698 return;
699 }
700
701 // picking the player with lowest ID (longest in game).
702 if (this.mActors.Count <= 1)
703 {
704 this.mMasterClient = this.mLocalActor;
705 }
706 else
707 {
708 // keys in mActors are their actorNumbers
709 int lowestActorNumber = Int32.MaxValue;
710 foreach (int key in this.mActors.Keys)
711 {
712 if (key < lowestActorNumber && key != leavingPlayerId)
713 {
714 lowestActorNumber = key;
715 }
716 }
717
718 this.mMasterClient = this.mActors[lowestActorNumber];
719 }
720
721 // make a callback ONLY when a player/Master left
722 if (someoneIsLeaving)
723 {
724 SendMonoMessage(PhotonNetworkingMessage.OnMasterClientSwitched, this.mMasterClient);
725 }
726 }
File name: NetworkingPeer.cs
Copy
732 private static int ReturnLowestPlayerId(PhotonPlayer[] players, int playerIdToIgnore)
733 {
734 if (players == null || players.Length == 0)
735 {
736 return -1;
737 }
738
739 int lowestActorNumber = Int32.MaxValue;
740 for (int i = 0; i < players.Length; i++)
741 {
742 PhotonPlayer photonPlayer = players[i];
743 if (photonPlayer.ID == playerIdToIgnore)
744 {
745 continue;
746 }
747
748 if (photonPlayer.ID < lowestActorNumber)
749 {
750 lowestActorNumber = photonPlayer.ID;
751 }
752 }
753
754 return lowestActorNumber;
755 }
File name: PingCloudRegions.cs
Copy
88 public static int MaxMilliseconsPerPing = 800; // enter a value you're sure some server can beat (have a lower rtt)
92 {
93 get
94 {
95 Region result = null;
96 int bestRtt = Int32.MaxValue;
97 foreach (Region region in PhotonNetwork.networkingPeer.AvailableRegions)
98 {
99 Debug.Log("BestRegion checks region: " + region);
100 if (region.Ping != 0 && region.Ping < bestRtt)
101 {
102 bestRtt = region.Ping;
103 result = region;
104 }
105 }
106
107 return (Region)result;
108 }
109 }
File name: ImportUtils.cs
Copy
57 public static int GetAttributeAsInt(XElement elem, string attrName)
58 {
59 return Convert.ToInt32(elem.Attribute(attrName).Value);
60 }
File name: NewMember.cs
Copy
25 private void button1_Click(object sender, EventArgs e)
26 {
27 SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\Sem.4\C# Projects\GymManagementSystem in C#\GymManagementSystem\Gym.mdf;Integrated Security=True;User Instance=True");
28 con.Open();
29 string gender = string.Empty;
30 if (radioButton1.Checked)
31 {
32 gender = "Male";
33 }
34 else if (radioButton2.Checked)
35 {
36 gender = "Female";
37 }
38 try
39 {
40 string str = " INSERT INTO members(f_name,l_name,gender,dob,mobile,email,jod,time,address,mem_time) VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + gender + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + comboBox1.Text + "','" + textBox7.Text + "','" + comboBox2.Text + "'); ";
41
42 SqlCommand cmd = new SqlCommand(str, con);
43 cmd.ExecuteNonQuery();
44
45 string str1 = "select max(m_id) from members ;";
46
47 SqlCommand cmd1 = new SqlCommand(str1, con);
48 SqlDataReader dr = cmd1.ExecuteReader();
49 if (dr.Read())
50 {
51 MessageBox.Show("" + textBox1.Text + "'s Details is Inserted Successfully.. " + textBox1.Text + "'s Id is " + dr.GetInt32(0) + ".", "Important Message");
52 this.Hide();
53
54 }
55 this.Close();
56 }
57 catch (SqlException excep)
58 {
59 MessageBox.Show(excep.Message);
60 }
61 con.Close();
62 }
File name: NewStaff.cs
Copy
20 private void button1_Click(object sender, EventArgs e)
21 {
22 SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\Sem.4\C# Projects\GymManagementSystem in C#\GymManagementSystem\Gym.mdf;Integrated Security=True;User Instance=True");
23 con.Open();
24 string gender = string.Empty;
25 if (radioButton1.Checked)
26 {
27 gender = "Male";
28 }
29 else if (radioButton2.Checked)
30 {
31 gender = "Female";
32 }
33 try
34 {
35 string str = " INSERT INTO staff(f_name,l_name,gender,dob,mobile,email,jod,street,city) VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + gender + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" +textBox8.Text + "'); ";
36
37 SqlCommand cmd = new SqlCommand(str, con);
38 cmd.ExecuteNonQuery();
39
40 string str1 = "select max(stf_id) from staff;";
41
42 SqlCommand cmd1 = new SqlCommand(str1, con);
43 SqlDataReader dr = cmd1.ExecuteReader();
44 if (dr.Read())
45 {
46 MessageBox.Show("" + textBox1.Text + "'s Details is Inserted Successfully.. " + textBox1.Text + "'s Id is " + dr.GetInt32(0) + ".", "Important Message");
47 this.Hide();
48
49 }
50 this.Close();
51 }
52 catch (SqlException excep)
53 {
54 MessageBox.Show(excep.Message);
55 }
56 con.Close();
57 }
Int32 120 lượt xem
Gõ tìm kiếm nhanh...