Registered
How do I use Registered
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: PhotonEditor.cs
Copy
147 {
148 RegisterForPhotonCloud,
149
150 EmailAlreadyRegistered,
151
152 SetupPhotonCloud,
153
154 SetupSelfHosted
155 }
File name: PhotonEditor.cs
Copy
420 protected virtual void OnGuiRegisterCloudApp()
421 {
422 GUI.skin.label.wordWrap = true;
423 if (!this.isSetupWizard)
424 {
425 GUILayout.BeginHorizontal();
426 GUILayout.FlexibleSpace();
427 if (GUILayout.Button(CurrentLang.MainMenuButton, GUILayout.ExpandWidth(false)))
428 {
429 this.SwitchMenuState(GUIState.Main);
430 }
431
432 GUILayout.EndHorizontal();
433
434 GUILayout.Space(15);
435 }
436
437 if (this.photonSetupState == PhotonSetupStates.RegisterForPhotonCloud)
438 {
439 GUI.skin.label.fontStyle = FontStyle.Bold;
440 GUILayout.Label(CurrentLang.ConnectButton);
441 EditorGUILayout.Separator();
442 GUI.skin.label.fontStyle = FontStyle.Normal;
443
444 GUILayout.Label(CurrentLang.UsePhotonLabel);
445 EditorGUILayout.Separator();
446 this.emailAddress = EditorGUILayout.TextField(CurrentLang.EmailLabel, this.emailAddress);
447
448 if (GUILayout.Button(CurrentLang.SendButton))
449 {
450 GUIUtility.keyboardControl = 0;
451 this.RegisterWithEmail(this.emailAddress);
452 }
453
454 GUILayout.Space(20);
455
456
457 GUILayout.Label(CurrentLang.SignedUpAlreadyLabel);
458 if (GUILayout.Button(CurrentLang.SetupButton))
459 {
460 this.photonSetupState = PhotonSetupStates.SetupPhotonCloud;
461 }
462 EditorGUILayout.Separator();
463
464
465 GUILayout.Label(CurrentLang.RegisterByWebsiteLabel);
466 if (GUILayout.Button(CurrentLang.AccountWebsiteButton))
467 {
468 EditorUtility.OpenWithDefaultApp(UrlAccountPage + Uri.EscapeUriString(this.emailAddress));
469 }
470
471 EditorGUILayout.Separator();
472
473 GUILayout.Label(CurrentLang.SelfHostLabel);
474
475 if (GUILayout.Button(CurrentLang.SelfHostSettingsButton))
476 {
477 this.photonSetupState = PhotonSetupStates.SetupSelfHosted;
478 }
479
480 GUILayout.FlexibleSpace();
481
482
483 if (!InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.Android) || !InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.iOS))
484 {
485 GUILayout.Label(CurrentLang.MobileExportNoteLabel);
486 }
487 EditorGUILayout.Separator();
488 }
489 else if (this.photonSetupState == PhotonSetupStates.EmailAlreadyRegistered)
490 {
491 GUI.skin.label.fontStyle = FontStyle.Bold;
492 GUILayout.Label(CurrentLang.OopsLabel);
493 GUI.skin.label.fontStyle = FontStyle.Normal;
494
495 GUILayout.Label(CurrentLang.EmailInUseLabel);
496
497 if (GUILayout.Button(CurrentLang.SeeMyAccountPageButton))
498 {
499 EditorUtility.OpenWithDefaultApp(UrlCloudDashboard + Uri.EscapeUriString(this.emailAddress));
500 }
501
502 EditorGUILayout.Separator();
503
504 GUILayout.Label(CurrentLang.KnownAppIdLabel);
505 GUILayout.BeginHorizontal();
506 if (GUILayout.Button(CurrentLang.CancelButton))
507 {
508 this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud;
509 }
510
511 if (GUILayout.Button(CurrentLang.SetupButton))
512 {
513 this.photonSetupState = PhotonSetupStates.SetupPhotonCloud;
514 }
515
516 GUILayout.EndHorizontal();
517 }
518 else if (this.photonSetupState == PhotonSetupStates.SetupPhotonCloud)
519 {
520 // cloud setup
521 GUI.skin.label.fontStyle = FontStyle.Bold;
522 GUILayout.Label(CurrentLang.PhotonCloudConnect);
523 GUI.skin.label.fontStyle = FontStyle.Normal;
524
525 EditorGUILayout.Separator();
526 this.OnGuiSetupCloudAppId();
527 this.OnGuiCompareAndHelpOptions();
528 }
529 else if (this.photonSetupState == PhotonSetupStates.SetupSelfHosted)
530 {
531 // self-hosting setup
532 GUI.skin.label.fontStyle = FontStyle.Bold;
533 GUILayout.Label(CurrentLang.SetupOwnHostLabel);
534 GUI.skin.label.fontStyle = FontStyle.Normal;
535
536 EditorGUILayout.Separator();
537
538 this.OnGuiSetupSelfhosting();
539 this.OnGuiCompareAndHelpOptions();
540 }
541 }
File name: PhotonEditor.cs
Copy
792 protected virtual void RegisterWithEmail(string email)
793 {
794 EditorUtility.DisplayProgressBar(CurrentLang.ConnectionTitle, CurrentLang.ConnectionInfo, 0.5f);
795 var client = new AccountService();
796 client.RegisterByEmail(email, RegisterOrigin); // this is the synchronous variant using the static RegisterOrigin. "result" is in the client
797
798 EditorUtility.ClearProgressBar();
799 if (client.ReturnCode == 0)
800 {
801 PhotonEditor.Current.UseCloud(client.AppId, 0);
802 PhotonEditor.Save();
803 this.ReApplySettingsToWindow();
804 this.photonSetupState = PhotonSetupStates.SetupPhotonCloud;
805 }
806 else
807 {
808 if (client.Message.Contains(CurrentLang.EmailInUseLabel))
809 {
810 this.photonSetupState = PhotonSetupStates.EmailAlreadyRegistered;
811 }
812 else
813 {
814 EditorUtility.DisplayDialog(CurrentLang.ErrorTextTitle, client.Message, CurrentLang.OkButton);
815 // Debug.Log(client.Exception);
816 this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud;
817 }
818 }
819 }
File name: NetworkingPeer.cs
Copy
2688 public void RegisterPhotonView(PhotonView netView)
2689 {
2690 if (!Application.isPlaying)
2691 {
2692 this.photonViewList = new Dictionary
2693 return;
2694 }
2695
2696 if (netView.viewID == 0)
2697 {
2698 // don't register views with ID 0 (not initialized). they register when a ID is assigned later on
2699 Debug.Log("PhotonView register is ignored, because viewID is 0. No id assigned yet to: " + netView);
2700 return;
2701 }
2702
2703 if (this.photonViewList.ContainsKey(netView.viewID))
2704 {
2705 // if some other view is in the list already, we got a problem. it might be undestructible. print out error
2706 if (netView != photonViewList[netView.viewID])
2707 {
2708 Debug.LogError(string.Format("PhotonView ID duplicate found: {0}. New: {1} old: {2}. Maybe one wasn't destroyed on scene load?! Check for 'DontDestroyOnLoad'. Destroying old entry, adding new.", netView.viewID, netView, photonViewList[netView.viewID]));
2709 }
2710
2711 //this.photonViewList.Remove(netView.viewID); // TODO check if we chould Destroy the GO of this view?!
2712 this.RemoveInstantiatedGO(photonViewList[netView.viewID].gameObject, true);
2713 }
2714
2715 // Debug.Log("adding view to known list: " + netView);
2716 this.photonViewList.Add(netView.viewID, netView);
2717 //Debug.LogError("view being added. " + netView); // Exit Games internal log
2718
2719 if (PhotonNetwork.logLevel >= PhotonLogLevel.Full)
2720 Debug.Log("Registered PhotonView: " + netView.viewID);
2721 }
File name: frmCustomerRegistration.cs
Copy
30 private void Register_Click(object sender, EventArgs e)
31 {
32 if (txtUsername.Text == "")
33 {
34 MessageBox.Show("Please enter username", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
35 txtUsername.Focus();
36 return;
37 }
38
39 if (txtPassword.Text == "")
40 {
41 MessageBox.Show("Please enter password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
42 txtPassword.Focus();
43 return;
44 }
45 if (txtName.Text == "")
46 {
47 MessageBox.Show("Please enter name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
48 txtName.Focus();
49 return;
50 }
51 if (txtContact_no.Text == "")
52 {
53 MessageBox.Show("Please enter contact no.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
54 txtContact_no.Focus();
55 return;
56 }
57 if (txtEmail_Address.Text == "")
58 {
59 MessageBox.Show("Please enter email", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
60 txtEmail_Address.Focus();
61 return;
62 }
63 try
64 {
65 con = new SqlConnection(cs.DBConn);
66 con.Open();
67 string ct = "select username from registration where username=@find";
68
69 cmd = new SqlCommand(ct);
70 cmd.Connection = con;
71 cmd.Parameters.Add(new SqlParameter("@find", System.Data.SqlDbType.NChar, 30, "username"));
72 cmd.Parameters["@find"].Value = txtUsername.Text;
73 rdr = cmd.ExecuteReader();
74
75 if (rdr.Read())
76 {
77 MessageBox.Show("Username Already Exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
78 txtUsername.Text = "";
79 txtUsername.Focus();
80
81
82 if ((rdr != null))
83 {
84 rdr.Close();
85 }
86 return;
87 }
88 con = new SqlConnection(cs.DBConn);
89 con.Open();
90 string ct1 = "select Email from registration where Email='" + txtEmail_Address.Text + "'";
91
92 cmd = new SqlCommand(ct1);
93 cmd.Connection = con;
94 rdr = cmd.ExecuteReader();
95
96 if (rdr.Read())
97 {
98 MessageBox.Show("Email ID Already Exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
99 txtEmail_Address.Text = "";
100 txtEmail_Address.Focus();
101
102
103 if ((rdr != null))
104 {
105 rdr.Close();
106 }
107 return;
108 }
109 con = new SqlConnection(cs.DBConn);
110 con.Open();
111
112 string cb = "insert into Registration(Username,UserType,Password,ContactNo,Email,Name,JoiningDate) VALUES ('" + txtUsername.Text + "','Customer','" + txtPassword.Text + "','" + txtContact_no.Text + "','" + txtEmail_Address.Text + "','" + txtName.Text + "','" + System.DateTime.Now + "')";
113
114 cmd = new SqlCommand(cb);
115 cmd.Connection = con;
116 cmd.ExecuteReader();
117 con.Close();
118 MessageBox.Show("Successfully Registered", "User", MessageBoxButtons.OK, MessageBoxIcon.Information);
119
120 }
121 catch (Exception ex)
122 {
123 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
124 }
125 }
File name: frmMainMenu.cs
Copy
105 private void logOutToolStripMenuItem_Click(object sender, EventArgs e)
106 {
107 this.Hide();
108 frmCategory o1 = new frmCategory();
109 o1.Hide();
110 frmSubCategory o2 = new frmSubCategory();
111 o2.Hide();
112 frmProduct o3 = new frmProduct();
113 o3.Hide();
114 frmRegisteredUsersDetails o4 = new frmRegisteredUsersDetails();
115 o4.Hide();
116 frmRegistration o5 = new frmRegistration();
117 o5.Hide();
118 frmStockRecord o6 = new frmStockRecord();
119 o6.Hide();
120 frmCustomersRecord o7 = new frmCustomersRecord();
121 o7.Hide();
122 frmSuppliersRecord o8 = new frmSuppliersRecord();
123 o8.Hide();
124 frmProductsRecord2 o9 = new frmProductsRecord2();
125 o9.Hide();
126 frmSalesRecord2 o10 = new frmSalesRecord2();
127 o10.Hide();
128 frmLogin frm = new frmLogin();
129 frm.Show();
130 frm.txtUserName.Text = "";
131 frm.txtPassword.Text = "";
132 frm.ProgressBar1.Visible = false;
133 frm.txtUserName.Focus();
134 }
File name: frmRegisteredUsersDetails.cs
Copy
15 public frmRegisteredUsersDetails()
16 {
17 InitializeComponent();
18 }
File name: frmRegisteredUsersDetails.cs
Copy
50 private void frmRegisteredUsersDetails_Load(object sender, EventArgs e)
51 {
52 dataGridView1.DataSource = GetData();
53 }
File name: frmRegistration.cs
Copy
48 private void Register_Click(object sender, EventArgs e)
49 {
50 if (txtUsername.Text == "")
51 {
52 MessageBox.Show("Please enter username", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
53 txtUsername.Focus();
54 return;
55 }
56 if (cmbUserType.Text == "")
57 {
58 MessageBox.Show("Please select user type", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
59 cmbUserType.Focus();
60 return;
61 }
62 if (txtPassword.Text == "")
63 {
64 MessageBox.Show("Please enter password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
65 txtPassword.Focus();
66 return;
67 }
68 if (txtName.Text == "")
69 {
70 MessageBox.Show("Please enter name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
71 txtName.Focus();
72 return;
73 }
74 if (txtContact_no.Text == "")
75 {
76 MessageBox.Show("Please enter contact no.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
77 txtContact_no.Focus();
78 return;
79 }
80 if (txtEmail_Address.Text == "")
81 {
82 MessageBox.Show("Please enter email", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
83 txtEmail_Address.Focus();
84 return;
85 }
86 try
87 {
88 con = new SqlConnection(cs.DBConn);
89 con.Open();
90 string ct = "select username from registration where username=@find";
91
92 cmd = new SqlCommand(ct);
93 cmd.Connection = con;
94 cmd.Parameters.Add(new SqlParameter("@find", System.Data.SqlDbType.NChar, 30, "username"));
95 cmd.Parameters["@find"].Value = txtUsername.Text;
96 rdr = cmd.ExecuteReader();
97
98 if (rdr.Read())
99 {
100 MessageBox.Show("Username Already Exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
101 txtUsername.Text = "";
102 txtUsername.Focus();
103
104
105 if ((rdr != null))
106 {
107 rdr.Close();
108 }
109 return;
110 }
111 con = new SqlConnection(cs.DBConn);
112 con.Open();
113 string ct1 = "select Email from registration where Email='" + txtEmail_Address.Text + "'";
114
115 cmd = new SqlCommand(ct1);
116 cmd.Connection = con;
117 rdr = cmd.ExecuteReader();
118
119 if (rdr.Read())
120 {
121 MessageBox.Show("Email ID Already Exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
122 txtEmail_Address.Text = "";
123 txtEmail_Address.Focus();
124
125
126 if ((rdr != null))
127 {
128 rdr.Close();
129 }
130 return;
131 }
132 con = new SqlConnection(cs.DBConn);
133 con.Open();
134
135 string cb = "insert into Registration(Username,UsertYpe,Password,ContactNo,Email,Name,JoiningDate) VALUES ('" + txtUsername.Text + "','" + cmbUserType.Text + "','" + txtPassword.Text + "','" + txtContact_no.Text + "','" + txtEmail_Address.Text + "','" + txtName.Text + "','" + System.DateTime.Now + "')";
136
137 cmd = new SqlCommand(cb);
138 cmd.Connection = con;
139 cmd.ExecuteReader();
140 con.Close();
141 MessageBox.Show("Successfully Registered", "User", MessageBoxButtons.OK, MessageBoxIcon.Information);
142 Autocomplete();
143 btnRegister.Enabled = false;
144
145 }
146 catch (Exception ex)
147 {
148 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
149 }
150 }
File name: frmRegistration.cs
Copy
226 private void GetDetails_Click(object sender, EventArgs e)
227 {
228 frmRegisteredUsersDetails frm = new frmRegisteredUsersDetails();
229 frm.dataGridView1.DataSource = frm.GetData();
230 frm.Show();
231
232 }
Download file with original file name:Registered
Registered 121 lượt xem
Gõ tìm kiếm nhanh...