예제 #1
0
        private void pbBack_Click(object sender, EventArgs e)
        {
            FAdminMenu fam = new FAdminMenu();

            fam.Show();
            this.Hide();
        }
예제 #2
0
        private void pbLogin_Click(object sender, EventArgs e)
        {
            int    result = 0;
            string info = "";
            string username, password;

            username = txtUser.Text;
            password = txtPass.Text;
            try
            {
                info = con.openconnection();
                if (info == "OK")
                {
                    string     query = "select count(*) from AccessLogin where Username = @Username and UPassword = @UPassword and isAdmin = '1'";
                    SqlCommand com   = new SqlCommand(query, con.con);
                    com.Parameters.AddWithValue("@Username", username);
                    com.Parameters.AddWithValue("@UPassword", password);
                    SqlDataReader dr = com.ExecuteReader();
                    if (dr.Read())
                    {
                        result = Convert.ToInt32(dr[0]);
                    }
                    dr.Close();
                }
                if (con.closeconnection() == "OK")
                {
                    info = "OK";
                }
                if (result > 0)
                {
                    MessageBox.Show("Welcome, " + username + ". Have a nice day :)", "Login Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    FAdminMenu fcm = new FAdminMenu();
                    fcm.Show();
                    this.Hide();
                    counter = 0;
                }
                else
                {
                    counter += 1;
                    if (counter < 3)
                    {
                        lblError.Visible = true;
                        txtUser.Focus();
                        txtUser.Clear();
                        txtPass.Clear();
                    }
                }
            }
            catch (Exception xe)
            {
                MessageBox.Show(xe.Message);
            }
        }
예제 #3
0
 private void pbAdd_Click(object sender, EventArgs e)
 {
     if (txtIdDoctor.Text == "full")
     {
         MessageBox.Show("Data already meets maximum limit", "Can not store data", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         FAdminMenu fam = new FAdminMenu();
         fam.Show();
         this.Hide();
     }
     else
     {
         if (txtDoctorName.Text == "" || txtPhoneNumber.Text == "" || txtIdSpecialist.Text == "")
         {
             MessageBox.Show("Please fill in the data");
         }
         else if (validategender() != 0)
         {
             MessageBox.Show("Please select gender");
         }
         else if (validaedob() != 0)
         {
             MessageBox.Show("Please select date of birth more than 20 years");
         }
         else
         {
             string datedob = dtp_DOB.Value.ToString("yyyy-MM-dd");
             string gender  = "";
             if (rbMale.Checked)
             {
                 gender = rbMale.Text;
             }
             else if (rbFemale.Checked)
             {
                 gender = rbFemale.Text;
             }
             DialogResult result = MessageBox.Show("Do you want to save record " + txtIdDoctor.Text + "?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
             if (result == DialogResult.Yes)
             {
                 string info = "";
                 try
                 {
                     info = con.openconnection();
                     if (info == "OK")
                     {
                         string     query = "exec pcdDoctor @idspecialist,@doctorname,@doctorgender,@dob,@phone";
                         SqlCommand com   = new SqlCommand(query, con.con);
                         com.Parameters.AddWithValue("@idspecialist", txtIdSpecialist.Text);
                         com.Parameters.AddWithValue("@doctorname", txtDoctorName.Text);
                         com.Parameters.AddWithValue("@doctorgender", gender);
                         com.Parameters.AddWithValue("@dob", datedob);
                         com.Parameters.AddWithValue("@phone", txtPhoneNumber.Text);
                         if (com.ExecuteNonQuery() > 0)
                         {
                             info = "OK";
                             MessageBox.Show("Data saved");
                             txtIdDoctor.Text = autoid();
                             txtDoctorName.Clear();
                             txtIdSpecialist.Clear();
                             dtp_DOB.Value = DateTime.Today.AddYears(-5);
                             txtPhoneNumber.Clear();
                             rbFemale.Checked = false;
                             rbMale.Checked   = false;
                             //txtAddress.Clear();
                             isidgvDoctor();
                             isidgvSpecialist();
                         }
                         else
                         {
                             info = "Gagal";
                         }
                     }
                     if (con.closeconnection() == "OK")
                     {
                         info = "OK";
                     }
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(ex.Message);
                 }
             }
         }
     }
 }