Successful
How do I use Successful
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: WorkerInGame.cs
Copy
26 public void OnGUI()
27 {
28 if (GUILayout.Button("Return to Lobby"))
29 {
30 PhotonNetwork.LeaveRoom(); // we will load the menu level when we successfully left the room
31 }
32 }
File name: PingCloudRegions.cs
Copy
43 public override bool Done()
44 {
45 if (this.GotResult || sock == null)
46 {
47 return true;
48 }
49
50 if (sock.Available <= 0)
51 {
52 return false;
53 }
54
55 int read = sock.Receive(PingBytes, SocketFlags.None);
56 //Debug.Log("Got: " + SupportClass.ByteArrayToString(PingBytes));
57 bool replyMatch = PingBytes[PingBytes.Length - 1] == PingId && read == PingLength;
58 if (!replyMatch) Debug.Log("ReplyMatch is false! ");
59
60
61 this.Successful = read == PingBytes.Length && PingBytes[PingBytes.Length - 1] == PingId;
62 this.GotResult = true;
63 return true;
64 }
File name: PingCloudRegions.cs
Copy
118 public IEnumerator PingSocket(Region region)
119 {
120 region.Ping = Attempts*MaxMilliseconsPerPing;
121
122 this.PingsRunning++; // TODO: Add try-catch to make sure the PingsRunning are reduced at the end and that the lib does not crash the app
123 PhotonPing ping;
124 //Debug.Log("PhotonHandler.PingImplementation " + PhotonHandler.PingImplementation);
125 if (PhotonHandler.PingImplementation == typeof(PingNativeDynamic))
126 {
127 Debug.Log("Using constructor for new PingNativeDynamic()"); // it seems on android, the Activator can't find the default Constructor
128 ping = new PingNativeDynamic();
129 }
130 else
131 {
132 ping = (PhotonPing)Activator.CreateInstance(PhotonHandler.PingImplementation);
133 }
134
135 //Debug.Log("Ping is: " + ping + " type " + ping.GetType());
136
137 float rttSum = 0.0f;
138 int replyCount = 0;
139
140
141 // PhotonPing.StartPing() requires a plain IP address without port (on all but Windows 8 platforms).
142 // So: remove port and do the DNS-resolving if needed
143 string cleanIpOfRegion = region.HostAndPort;
144 int indexOfColon = cleanIpOfRegion.LastIndexOf(':');
145 if (indexOfColon > 1)
146 {
147 cleanIpOfRegion = cleanIpOfRegion.Substring(0, indexOfColon);
148 }
149 cleanIpOfRegion = ResolveHost(cleanIpOfRegion);
150 //Debug.Log("Resolved and port-less IP is: " + cleanIpOfRegion);
151
152
153 for (int i = 0; i < Attempts; i++)
154 {
155 bool overtime = false;
156 Stopwatch sw = new Stopwatch();
157 sw.Start();
158
159 try
160 {
161 ping.StartPing(cleanIpOfRegion);
162 }
163 catch (Exception e)
164 {
165 Debug.Log("catched: " + e);
166 this.PingsRunning--;
167 break;
168 }
169
170
171 while (!ping.Done())
172 {
173 if (sw.ElapsedMilliseconds >= MaxMilliseconsPerPing)
174 {
175 overtime = true;
176 break;
177 }
178 yield return 0; // keep this loop tight, to avoid adding local lag to rtt.
179 }
180 int rtt = (int)sw.ElapsedMilliseconds;
181
182
183 if (IgnoreInitialAttempt && i == 0)
184 {
185 // do nothing.
186 }
187 else if (ping.Successful && !overtime)
188 {
189 rttSum += rtt;
190 replyCount++;
191 region.Ping = (int)((rttSum) / replyCount);
192 //Debug.Log("region " + region.Code + " RTT " + region.Ping + " success: " + ping.Successful + " over: " + overtime);
193 }
194
195 yield return new WaitForSeconds(0.1f);
196 }
197
198 this.PingsRunning--;
199
200 //Debug.Log("this.PingsRunning: " + this.PingsRunning + " this debug: " + ping.DebugString);
201 yield return null;
202 }
File name: DeleteMembers.cs
Copy
20 private void button1_Click(object sender, EventArgs e)
21 {
22 try
23 {
24 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");
25 con.Open();
26
27 string str = "DELETE FROM members WHERE m_id = '" + textBox1.Text + "'";
28
29 SqlCommand cmd = new SqlCommand(str, con);
30 cmd.ExecuteNonQuery();
31 con.Close();
32 MessageBox.Show(" Members Record Deleted Successfully");
33
34 using (SqlConnection newcon = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\Sem.4\C# Projects\GymManagementSystem in C#\GymManagementSystem\Gym.mdf;Integrated Security=True;User Instance=True"))
35 {
36 string str1 = "SELECT * from members";
37 SqlCommand cmd1 = new SqlCommand(str1, newcon);
38 SqlDataAdapter da = new SqlDataAdapter(cmd1);
39 DataTable dt = new DataTable();
40 da.Fill(dt);
41 dataGridView1.DataSource = new BindingSource(dt, null);
42
43 }
44 }
45
46 catch (SqlException ex)
47 {
48 MessageBox.Show(ex.Message);
49 MessageBox.Show("Please Enter Employee Id..");
50 }
51 }
File name: Equipment.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
25 try
26 {
27 string str = " INSERT INTO equipment(name,description,used,cost) VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "'); ";
28
29 SqlCommand cmd = new SqlCommand(str, con);
30 cmd.ExecuteNonQuery();
31
32 string str1 = "select max(eqp_id) from equipment;";
33
34 SqlCommand cmd1 = new SqlCommand(str1, con);
35 SqlDataReader dr = cmd1.ExecuteReader();
36 if (dr.Read())
37 {
38 MessageBox.Show("" + textBox1.Text + "'s Equipment Details is Inserted Successfully.. ");
39 this.Hide();
40
41 }
42 this.Close();
43 }
44 catch (SqlException excep)
45 {
46 MessageBox.Show(excep.Message);
47 }
48 con.Close();
49 }
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 }
File name: Register.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 employee(emp_username,name,password,gender,email,mobile,address,date) VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + gender + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "'); ";
36
37 SqlCommand cmd = new SqlCommand(str, con);
38 cmd.ExecuteNonQuery();
39
40 string str1 = "select max(emp_id) from employee ;";
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 Home obj1 = new Home();
49 obj1.ShowDialog();
50 }
51 this.Close();
52 }
53 catch (SqlException excep)
54 {
55 MessageBox.Show(excep.Message);
56 }
57 con.Close();
58 }
File name: PatientCheckOut.cs
Copy
66 private void button1_Click(object sender, EventArgs e)
67 {
68 SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=F:\Sem.4\C# Projects\Trials\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True");
69 con.Open();
70 string gen = string.Empty;
71 if (radioButton1.Checked)
72 {
73 gen = "Male";
74 }
75 else
76 {
77 gen = "Female";
78 }
79 try
80 {
81 string str = "INSERT INTO checkout(name,gen,age,contact,addr,disease,date_in,date_out,build,r_no,r_type,status,med_price,total) VALUES('" + textBox2.Text + "','" + gen + "','" + textBox3.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "','" + textBox9.Text + "','" + textBox10.Text + "','" + textBox11.Text + "','" + textBox12.Text + "','" + textBox14.Text + "','" + textBox13.Text + "','" + textBox15.Text + "'); ";
82
83 SqlCommand cmd = new SqlCommand(str, con);
84 cmd.ExecuteNonQuery();
85 string str1 = "select max(Id) from checkout;";
86
87 SqlCommand cmd1 = new SqlCommand(str1, con);
88 SqlDataReader dr = cmd1.ExecuteReader();
89 if (dr.Read())
90 {
91 MessageBox.Show("Patient Checkout Information Saved Successfully..");
92 textBox2.Text = "";
93 textBox3.Text = "";
94
95 textBox5.Text = "";
96 textBox6.Text = "";
97 textBox7.Text = "";
98 textBox8.Text = "";
99 textBox9.Text = "";
100 textBox10.Text = "";
101 textBox11.Text = "";
102 textBox12.Text = "";
103 textBox13.Text = "";
104 textBox14.Text = "";
105 textBox15.Text = "";
106 }
107 }
108 catch (SqlException excep)
109 {
110 MessageBox.Show(excep.Message);
111 }
112 con.Close();
113 }
File name: PatientInformation.cs
Copy
88 private void button2_Click(object sender, EventArgs e)
89 {
90 SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=F:\Sem.4\C# Projects\Trials\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True");
91 con.Open();
92 string gen = string.Empty;
93 if (radioButton1.Checked)
94 {
95 gen = "Male";
96 }
97 else
98 {
99 gen = "Female";
100 }
101 try
102 {
103 string str = " Update patient set name='" + textBox2.Text + "',gen='" + gen + "',age='" + textBox3.Text + "',date='" + textBox4.Text + "',cont='" + textBox5.Text + "',addr='" + textBox6.Text + "',disease='" + textBox7.Text + "',status='" + textBox8.Text + "',r_type='" + textBox10.Text + "',building='" + textBox9.Text + "',r_no='" + textBox11.Text + "',price='" + textBox12.Text + "' where id='" + textBox1.Text + "'";
104
105 SqlCommand cmd = new SqlCommand(str, con);
106 cmd.ExecuteNonQuery();
107
108 string str1 = "select max(id) from patient;";
109
110 SqlCommand cmd1 = new SqlCommand(str1, con);
111 SqlDataReader dr = cmd1.ExecuteReader();
112 if (dr.Read())
113 {
114 MessageBox.Show("" + textBox2.Text + "'s Details is Updated Successfully.. ", "Important Message");
115 textBox2.Text = "";
116 textBox4.Text = "";
117 textBox5.Text = "";
118 textBox6.Text = "";
119 textBox7.Text = "";
120 using (SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=F:\Sem.4\C# Projects\Trials\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True"))
121 {
122
123 string str2 = "SELECT * FROM patient";
124 SqlCommand cmd2 = new SqlCommand(str2, con1);
125 SqlDataAdapter da = new SqlDataAdapter(cmd2);
126 DataTable dt = new DataTable();
127 da.Fill(dt);
128 dataGridView1.DataSource = new BindingSource(dt, null);
129 }
130 }
131 }
132 catch (SqlException excep)
133 {
134 MessageBox.Show(excep.Message);
135 }
136 con.Close();
137 }
Successful 121 lượt xem
Gõ tìm kiếm nhanh...