Exemplo n.º 1
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                conn = new SqlConnection {
                    ConnectionString = constr
                };



                conn.Open();
                // string insrtlg = "INSERT INTO LoginTB(Username,Password,Access_Level) VALUES(@usr,@pass,@role)";
                string insrtInPat = "INSERT INTO InPatientReg(Fname,Lname,Birth,Gender,Phone,Address,Occupation,MaritalStatus,Age,Status,AdmissionDate,Symptoms,Departement,AssignedDoc,WardNo,BedNo) VALUES(@FirstName,@LastName,@DOB,@Gender,@PhoneNumber,@Address,@Occupation,@Mstatus,@Age,@Status,@AdminDate,@Sympt,@Dept,@Doc,@WNo,@BNo)";


                SqlCommand cmd1 = new SqlCommand(insrtInPat, conn);

                //Adding Registration Infos

                cmd1.Parameters.AddWithValue("@FirstName", txtFirstName.Text);
                cmd1.Parameters.AddWithValue("@LastName", txtLastName.Text);
                cmd1.Parameters.AddWithValue("@DOB", txtDateOfBirth.Text);
                cmd1.Parameters.AddWithValue("@Gender", txtGender.SelectedItem);
                cmd1.Parameters.AddWithValue("@PhoneNumber", txtPhoneNumber.Text);
                cmd1.Parameters.AddWithValue("@Address", txtAddress.Text);

                cmd1.Parameters.AddWithValue("@Occupation", txtOccupation.Text);
                cmd1.Parameters.AddWithValue("@Mstatus", txtMaritalStatus.SelectedItem);
                cmd1.Parameters.AddWithValue("@Age", txtAge.Text);
                cmd1.Parameters.AddWithValue("@Status", txtStatus.SelectedItem);
                cmd1.Parameters.AddWithValue("@AdminDate", lblCurrentDateTime.Text);
                cmd1.Parameters.AddWithValue("@Sympt", txtSymptoms.Text);
                cmd1.Parameters.AddWithValue("@Dept", txtDepartment.SelectedItem);
                cmd1.Parameters.AddWithValue("@Doc", txtAssignDoctor.Text);
                cmd1.Parameters.AddWithValue("@WNo", txtWardNo.SelectedItem);
                cmd1.Parameters.AddWithValue("@BNo", txtBedNumber.Value);

                cmd1.ExecuteNonQuery();
                conn.Close();
                MessageBox.Show(this, "User successfully inserted into database. ", "Report", MessageBoxButtons.OK, MessageBoxIcon.Information);
                var am = new AdminPage();
                am.ClearAllTextBoxes(this);
            }
            catch (Exception ex)
            {
                lblErrorMess.Text = ex.Message;
            }
        }
 private void ReadLogData(SqlDataReader dr)
 {
     if ((string)dr["Access_Level"] == "Admin")
     {
         var adm = new AdminPage();
         txtUsername.Text = String.Empty;
         txtPassword.Text = String.Empty;
         txtUsername.Focus();
         //GlobalUname.GlobalVar = (string) dr["Access_Level"];
         adm.Show();
         this.Hide();
     }
     else if ((string)dr["Access_Level"] == "Doctor")
     {
         var dp = new DoctorPage();
         txtUsername.Text = string.Empty;
         txtPassword.Text = string.Empty;
         txtUsername.Focus();
         dp.Show();
         this.Hide();
     }
     else if ((string)dr["Access_Level"] == "Manager")
     {
     }
     else if ((string)dr["Access_Level"] == "Nurse")
     {
     }
     else if ((string)dr["Access_Level"] == "Assistant")
     {
         var hm = new Home();
         txtUsername.Text = string.Empty;
         txtPassword.Text = string.Empty;
         txtUsername.Focus();
         hm.Show();
         this.Hide();
     }
 }