private async void Form1_Load(object sender, EventArgs e) { if (InternetCheck.isInternet()) { GetAllStudent(); } else { MessageBox.Show("Please check your Internet connection !!!", caption: "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.Close(); } }
private async void button1_Click_1(object sender, EventArgs e) { if (NametextBox.Text == string.Empty) { MessageBox.Show("Please Enter all Information", caption: "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (RegistrationtextBox.Text == string.Empty) { MessageBox.Show("Please Enter all Information", caption: "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (MobileNotextBox4.Text == string.Empty) { MessageBox.Show("Please Enter all Information", caption: "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { Student student = new Student(); student.name = NametextBox.Text; student.registrationNO = RegistrationtextBox.Text; student.mobileNo = MobileNotextBox4.Text; student.departmentName = DepartmenttextBox5.Text; student.address = AddresstextBox3.Text; student.Id = Idlabel.Text; IFirebaseConfig firebaseConfig = new FirebaseConfig() { AuthSecret = "0q034wxR0p8grjvFHJtPzXLmMhlTNH3yrgrqlAEf", BasePath = "https://crudforms.firebaseio.com/" }; IFirebaseClient client = new FirebaseClient(firebaseConfig); if (InternetCheck.isInternet()) { if (Save.Text == @"Save") { PushResponse message = await client.PushAsync("StudentList", student); if (message != null) { MessageBox.Show("Student Saved Successfully.", caption: "Save", MessageBoxButtons.OK, MessageBoxIcon.Information); Reset(); GetAllStudent(); } else { MessageBox.Show("Student doesn't saved.", caption: "Information", MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (Save.Text == @"Update") { var message = await client.UpdateAsync("StudentList/" + student.Id, student); if (message != null) { MessageBox.Show("Student Updated Successfully.", caption: "Save", MessageBoxButtons.OK, MessageBoxIcon.Information); Reset(); GetAllStudent(); Save.Text = "Save"; } else { MessageBox.Show("Student doesn't Updated.", caption: "Information", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show("Please check your Internet connection !!!", caption: "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.Close(); } } }