Esempio n. 1
0
        private void B_login_Click(object sender, EventArgs e)
        {
            SqlConnection  conn = new SqlConnection(@"Data Source=DESKTOP-VAM0JO2\SQLEXPRESS; Initial Catalog=Clinic2018; User ID=tanakorn29; Password=111111");
            SqlDataAdapter sda  = new SqlDataAdapter("select * form login where username= '******' and password= '******'", conn);
            DataTable      dt   = new DataTable();

            sda.Fill(dt);

            //สำรอง2

            /*SqlConnection conn = new SqlConnection(@"Data Source=DESKTOP-VAM0JO2\SQLEXPRESS; Initial Catalog=Clinic2018; User ID=tanakorn29; Password=111111");
             * System.Data.DataSet ds = new System.Data.DataSet();
             * System.Data.Odbc.SqlDataAdapter adapter1 = new System.Data.Odbc.SqlDataAdapter("select * form login where username= '******' and password= '******'", conn);
             * adapter1.Fill(ds);
             * DataTable dt = ds.Tables[0];*/

            if (dt.Rows.Count == 1)
            {
                clinic_main_v2 c1 = new clinic_main_v2();
                c1.Show();
            }
            else
            {
                MessageBox.Show("ตรวจสอบข้อมูลอีกครั้ง");
            }
        }
Esempio n. 2
0
        private void B_login_Click(object sender, EventArgs e)
        {
            try
            {
                SqlConnection conn = new SqlConnection(@"Data Source=DESKTOP-VAM0JO2\SQLEXPRESS; Initial Catalog=Clinic2018; User ID=tanakorn29; Password=111111");
                SqlCommand    cmd  = new SqlCommand("select * from user_control where uct_user=@uct_user and uct_password=@uct_password", conn);
                conn.Open();
                cmd.Parameters.AddWithValue("@uct_user", T_Username.Text);
                cmd.Parameters.AddWithValue("@uct_password", T_Password.Text);
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.HasRows == true)
                {
                    MessageBox.Show("ยินดีต้อนรับ" + " " + T_Username.Text);

                    clinic_login clnlog = new clinic_login();
                    clnlog.Close();
                    Visible = false;

                    clinic_main_v2 m2 = new clinic_main_v2();
                    m2.Show();
                }

                else
                {
                    MessageBox.Show("Check Username and Password agin!!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OKCancel);
            }
        }
Esempio n. 3
0
        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            clinic_login log = new clinic_login();

            log.Show();
            clinic_main_v2 main = new clinic_main_v2();

            main.Close();
            Visible = false;
        }
        private void B_login_Click(object sender, EventArgs e)
        {
            try
            {
                string day = DateTime.Now.ToString("dddd", new CultureInfo("th-TH"));

                double time = Convert.ToDouble(label4.Text);
                if (time <= 12.00)
                {
                    //  MessageBox.Show("เช้า");

                    SqlConnection conn = new SqlConnection(@"Data Source = DESKTOP-J5O17QF\SQLEXPRESS; Initial Catalog = Clinic2018; MultipleActiveResultSets = true; User ID = sa; Password = 1234");
                    SqlCommand    cmd  = new SqlCommand("select employee_ru.emp_ru_name,position.pos_name,time_attendance.remark from employee_ru inner join user_control on user_control.emp_ru_id = employee_ru.emp_ru_id inner join position on position.pos_id = employee_ru.pos_id inner join time_attendance on time_attendance.emp_ru_id = employee_ru.emp_ru_id  where uct_user=@uct_user and uct_password=@uct_password ORDER BY id_time DESC", conn);
                    SqlCommand    cmd1 = new SqlCommand("select employee_doctor.emp_doc_name,schedule_work_doctor.swd_day_work ,schedule_work_doctor.room_id,time_attendance.remark from employee_doctor inner join user_control on user_control.emp_doc_id = employee_doctor.emp_doc_id inner join schedule_work_doctor on schedule_work_doctor.emp_doc_id = employee_doctor.emp_doc_id  inner join time_attendance on time_attendance.emp_doc_id = employee_doctor.emp_doc_id where uct_user=@uct_user and uct_password=@uct_password and swd_day_work = '" + day + "' and swd_timezone = 'เช้า' ORDER BY id_time DESC", conn);
                    conn.Open();


                    cmd.Parameters.AddWithValue("@uct_user", T_Username.Text);
                    cmd.Parameters.AddWithValue("@uct_password", T_Password.Text);
                    cmd1.Parameters.AddWithValue("@uct_user", T_Username.Text);
                    cmd1.Parameters.AddWithValue("@uct_password", T_Password.Text);

                    SqlDataReader dr  = cmd.ExecuteReader();
                    SqlDataReader dr1 = cmd1.ExecuteReader();

                    if (dr.HasRows == true)
                    {
                        if (dr.Read())
                        {
                            string position    = dr["pos_name"].ToString();
                            string time_remark = dr["remark"].ToString();
                            if (time_remark == "เข้างาน")
                            {
                                if (position == "เวชระเบียน")
                                {
                                    MessageBox.Show("ยินดีต้อนรับ" + dr["emp_ru_name"].ToString());

                                    clinic_main_v2 m1 = new clinic_main_v2();
                                    m1.Show();
                                    clinic_login clnlog = new clinic_login();
                                    clnlog.Close();
                                    Visible = false;
                                }
                                else if (position == "พยาบาล")
                                {
                                    MessageBox.Show("ยินดีต้อนรับ" + dr["emp_ru_name"].ToString());

                                    clinic_nurse m2 = new clinic_nurse();
                                    m2.Show();
                                    clinic_login clnlog = new clinic_login();
                                    clnlog.Close();
                                    Visible = false;
                                }
                                else if (position == "หัวหน้า")
                                {
                                    MessageBox.Show("ยินดีต้อนรับ" + dr["emp_ru_name"].ToString());

                                    Clinic_boss m3 = new Clinic_boss();
                                    m3.Show();
                                    clinic_login clnlog = new clinic_login();
                                    clnlog.Close();
                                    Visible = false;
                                }
                                else if (position == "เภสัชกรณ์")
                                {
                                    MessageBox.Show("ยินดีต้อนรับ" + dr["emp_ru_name"].ToString());

                                    clinic_pharmacist m4 = new clinic_pharmacist();
                                    m4.Show();
                                    clinic_login clnlog = new clinic_login();
                                    clnlog.Close();
                                    Visible = false;
                                }
                            }
                            else
                            {
                                MessageBox.Show("คุณยังไม่ได้เข้างาน");
                            }
                        }
                    }
                    else if (dr1.HasRows == true)
                    {
                        if (dr1.Read())
                        {
                            string time_remark = dr1["remark"].ToString();
                            if (time_remark == "เข้างาน")
                            {
                                if (dr1["room_id"].ToString() == "1")
                                {
                                    MessageBox.Show("ยินดีต้อนรับ" + dr1["emp_doc_name"].ToString());

                                    Clinic_doctor doc1 = new Clinic_doctor();
                                    doc1.Show();
                                    clinic_login clnlog = new clinic_login();
                                    clnlog.Close();
                                    Visible = false;
                                }

                                else if (dr1["room_id"].ToString() == "2")
                                {
                                    MessageBox.Show("ยินดีต้อนรับ" + dr1["emp_doc_name"].ToString());

                                    Clinic_doctor2 doc1 = new Clinic_doctor2();
                                    doc1.Show();
                                    clinic_login clnlog = new clinic_login();
                                    clnlog.Close();
                                    Visible = false;
                                }

                                else if (dr1["room_id"].ToString() == "3")
                                {
                                    clinic_doctor3 doc1 = new clinic_doctor3();
                                    doc1.Show();
                                    clinic_login clnlog = new clinic_login();
                                    clnlog.Close();
                                    Visible = false;
                                }

                                else
                                {
                                    MessageBox.Show("ยังไม่ได้ลงตารางปฏิบัติงาน");
                                }
                            }
                            else
                            {
                                MessageBox.Show("ยังไม่ได้เข้างาน");
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Check Username and Password agin!!");
                    }
                }
                else if (time >= 12.01)
                {
                    // MessageBox.Show("บ่าย");

                    SqlConnection conn = new SqlConnection(@"Data Source = DESKTOP-J5O17QF\SQLEXPRESS; Initial Catalog = Clinic2018; MultipleActiveResultSets=true; User ID = sa; Password = 1234");
                    SqlCommand    cmd  = new SqlCommand("select employee_ru.emp_ru_name,position.pos_name,time_attendance.remark from employee_ru inner join user_control on user_control.emp_ru_id = employee_ru.emp_ru_id inner join position on position.pos_id = employee_ru.pos_id inner join time_attendance on time_attendance.emp_ru_id = employee_ru.emp_ru_id  where uct_user=@uct_user and uct_password=@uct_password ORDER BY id_time DESC", conn);
                    SqlCommand    cmd1 = new SqlCommand("select employee_doctor.emp_doc_name,schedule_work_doctor.swd_day_work ,schedule_work_doctor.room_id,time_attendance.remark from employee_doctor inner join user_control on user_control.emp_doc_id = employee_doctor.emp_doc_id inner join schedule_work_doctor on schedule_work_doctor.emp_doc_id = employee_doctor.emp_doc_id  inner join time_attendance on time_attendance.emp_doc_id = employee_doctor.emp_doc_id where uct_user=@uct_user and uct_password=@uct_password and swd_day_work = '" + day + "' and swd_timezone = 'บ่าย' ORDER BY id_time DESC", conn);
                    conn.Open();


                    cmd.Parameters.AddWithValue("@uct_user", T_Username.Text);
                    cmd.Parameters.AddWithValue("@uct_password", T_Password.Text);
                    cmd1.Parameters.AddWithValue("@uct_user", T_Username.Text);
                    cmd1.Parameters.AddWithValue("@uct_password", T_Password.Text);

                    SqlDataReader dr  = cmd.ExecuteReader();
                    SqlDataReader dr1 = cmd1.ExecuteReader();

                    if (dr.HasRows == true)
                    {
                        if (dr.Read())
                        {
                            string position    = dr["pos_name"].ToString();
                            string time_remark = dr["remark"].ToString();
                            if (time_remark == "เข้างาน")
                            {
                                if (position == "เวชระเบียน")
                                {
                                    MessageBox.Show("ยินดีต้อนรับ" + dr["emp_ru_name"].ToString());

                                    clinic_main_v2 m1 = new clinic_main_v2();
                                    m1.Show();
                                    clinic_login clnlog = new clinic_login();
                                    clnlog.Close();
                                    Visible = false;
                                }
                                else if (position == "พยาบาล")
                                {
                                    MessageBox.Show("ยินดีต้อนรับ" + dr["emp_ru_name"].ToString());

                                    clinic_nurse m2 = new clinic_nurse();
                                    m2.Show();
                                    clinic_login clnlog = new clinic_login();
                                    clnlog.Close();
                                    Visible = false;
                                }
                                else if (position == "หัวหน้า")
                                {
                                    MessageBox.Show("ยินดีต้อนรับ" + dr["emp_ru_name"].ToString());

                                    Clinic_boss m3 = new Clinic_boss();
                                    m3.Show();
                                    clinic_login clnlog = new clinic_login();
                                    clnlog.Close();
                                    Visible = false;
                                }
                                else if (position == "เภสัชกรณ์")
                                {
                                    MessageBox.Show("ยินดีต้อนรับ" + dr["emp_ru_name"].ToString());

                                    clinic_pharmacist m4 = new clinic_pharmacist();
                                    m4.Show();
                                    clinic_login clnlog = new clinic_login();
                                    clnlog.Close();
                                    Visible = false;
                                }
                            }
                            else
                            {
                                MessageBox.Show("คุณยังไม่ได้เข้างาน");
                            }
                        }
                    }
                    else if (dr1.HasRows == true)
                    {
                        if (dr1.Read())
                        {
                            string time_remark = dr1["remark"].ToString();
                            if (time_remark == "เข้างาน")
                            {
                                if (dr1["room_id"].ToString() == "1")
                                {
                                    MessageBox.Show("ยินดีต้อนรับ" + dr1["emp_doc_name"].ToString());

                                    Clinic_doctor doc1 = new Clinic_doctor();
                                    doc1.Show();
                                    clinic_login clnlog = new clinic_login();
                                    clnlog.Close();
                                    Visible = false;
                                }

                                else if (dr1["room_id"].ToString() == "2")
                                {
                                    MessageBox.Show("ยินดีต้อนรับ" + dr1["emp_doc_name"].ToString());

                                    Clinic_doctor2 doc1 = new Clinic_doctor2();
                                    doc1.Show();
                                    clinic_login clnlog = new clinic_login();
                                    clnlog.Close();
                                    Visible = false;
                                }

                                else if (dr1["room_id"].ToString() == "3")
                                {
                                    clinic_doctor3 doc1 = new clinic_doctor3();
                                    doc1.Show();
                                    clinic_login clnlog = new clinic_login();
                                    clnlog.Close();
                                    Visible = false;
                                }

                                else
                                {
                                    MessageBox.Show("ยังไม่ได้ลงตารางปฏิบัติงาน");
                                }
                            }
                            else
                            {
                                MessageBox.Show("ยังไม่ได้เข้างาน");
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Check Username and Password agin!!");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OKCancel);
            }
        }