Exemplo n.º 1
0
 private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (MessageBox.Show("คุณต้องการออกจากโปรแกรมหรือไม่", "ยืนยันการออกจากโปรแกรม", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
     {
         e.Cancel = true;
     }
     else
     {
         if (Class.ClsManageUserLogin.current_log != null)
         {
             try
             {
                 using (InhCheckupDataContext cdc = new InhCheckupDataContext())
                 {
                     log_user_login log = cdc.log_user_logins.Where(x => x.lug_id == Class.ClsManageUserLogin.current_log.lug_id).FirstOrDefault();
                     if (log.lug_end_date == null)
                     {
                         log.lug_end_date = Program.GetServerDateTime();
                         cdc.SubmitChanges();
                     }
                 }
             }
             catch
             {
             }
         }
         Program.Logout();
     }
 }
Exemplo n.º 2
0
        private void CheckKickedUser()
        {
            try
            {
                using (InhCheckupDataContext context = new InhCheckupDataContext())
                {
                    log_user_login lug = context.log_user_logins
                                         .Where(x => x.lug_id == _lug_id)
                                         .FirstOrDefault();
                    if (lug.lug_end_date != null)
                    {
                        this.Close();
                        OnKickedUser(false);
                    }
                }
            }
            catch (Exception ex)
            {
                Program.MessageError(this.Name, "CheckKickedUser", ex, false);
            }
            Timer timer = new Timer();

            timer.Enabled  = true;
            timer.Interval = 5000;
            timer.Tick    += new EventHandler(timer_Tick);
            timer.Start();
        }
Exemplo n.º 3
0
 public void showDashBoard(int mrd_id)
 {
     _mrd_id = mrd_id;
     using (InhCheckupDataContext cdc = new InhCheckupDataContext())
     {
         DateTime     dateNow = Program.GetServerDateTime();
         mst_room_dtl mrd     = cdc.mst_room_dtls.Where(x => x.mrd_id == mrd_id).FirstOrDefault();
         lbDesc.Text = "(" + mrd.mrd_room_no + ") " + mrd.mst_room_hdr.mst_hpc_site.mhs_ename + " : " + mrd.mrd_ename;
         log_user_login lug = cdc.log_user_logins.Where(x => x.mrd_id == mrd_id &&
                                                        x.lug_end_date == null &&
                                                        x.lug_start_date.Value.Date == dateNow.Date)
                              .OrderByDescending(x => x.lug_start_date).FirstOrDefault();
         if (lug != null)
         {
             lbDesc.BackColor    = Color.Green;
             lbDocName.BackColor = Color.RoyalBlue;
             mut_id = lug.mut_id;
         }
         else
         {
             lbDesc.BackColor    = Color.Gray;
             lbDocName.BackColor = Color.Gray;
             lbDocName.Text      = string.Empty;
             lbLogTime.Text      = "Log in time : --:--";
             lbLogTime.Click    -= new EventHandler(lbLogTime_Click);
             lbCompletePE.Text   = string.Empty;
             lbCompleteRE.Text   = string.Empty;
             lbWating.Text       = string.Empty;
             gridData.DataSource = new dataCls();
         }
     }
 }
Exemplo n.º 4
0
        public static void ExitRoom()
        {
            if (Program.CurrentRoom != null && Program.CurrentUser != null && Class.ClsManageUserLogin.current_log != null)
            {
                InhCheckupDataContext dbc = new InhCheckupDataContext();
                //log_user_login currentloguserlogin = (from t1 in dbc.log_user_logins
                //                                      where t1.mrd_id == Program.CurrentRoom.mrd_id
                //                                       && t1.mut_id == Program.CurrentUser.mut_id
                //                                       && t1.lug_end_date == null
                //                                      select t1).FirstOrDefault();
                log_user_login currentloguserlogin = dbc.log_user_logins.Where(x => x.lug_id == Class.ClsManageUserLogin.current_log.lug_id).FirstOrDefault();
                if (currentloguserlogin != null)
                {
                    currentloguserlogin.lug_end_date = Program.GetServerDateTime();
                }
                mst_user_type CurrentUser = (from t1 in dbc.mst_user_types where t1.mut_id == Program.CurrentUser.mut_id select t1).FirstOrDefault();
                CurrentUser.mut_login_status = get_mutLoginStatus;
                dbc.SubmitChanges();
                Program.CurrentUser = CurrentUser;

                mst_room_dtl currentroom = (from t1 in dbc.mst_room_dtls where t1.mrd_id == Program.CurrentRoom.mrd_id select t1).FirstOrDefault();
                if (currentroom != null)
                {
                    currentroom.mrd_rm_status = 'E';
                    dbc.SubmitChanges();
                }
            }
            get_mutLoginStatus = '0';
            Class.ClsManageUserLogin.current_log = null;
            Program.CurrentRegis = null;
            Program.CurrentRoom  = null;
            GC.Collect();                  //คำสั่ง Clear Memory ที่เคยเรียก data base มาใช้งาน
            AlertOutDepartment.StopTime(); //ปิดการทำงานการเตือน Out Department
        }
Exemplo n.º 5
0
 public static bool checkAskingLoginRoom(int mut_id, int mhs_id, int mrd_id)
 {
     // return false =แสดงว่ามีการเข้าใช้งานเครื่องอื่นแล้ว : return true=แสดงว่าเป็นเครื่องที่ใช้งานอยู่
     try
     {
         using (InhCheckupDataContext cdc = new InhCheckupDataContext())
         {
             EmrClass.GetDataMasterCls mst   = new EmrClass.GetDataMasterCls();
             List <int?>           mrd_zoneB = mst.Get_MrdZoneB;
             List <log_user_login> log       = cdc.log_user_logins
                                               .Where(x => x.mut_id == mut_id &&
                                                      x.lug_end_date == null &&
                                                      x.mhs_id == mhs_id)
                                               .ToList();
             if (log != null)
             {
                 if (log.Count() > 0)
                 {
                     log_user_login log_same_mrd_id = log.Where(x => x.mrd_id == mrd_id).FirstOrDefault();
                     if (log_same_mrd_id != null)
                     {
                         return(true);
                     }
                     else
                     {
                         if (!mrd_zoneB.Contains(mrd_id))
                         {
                             return(true);
                         }
                         else
                         {
                             log_user_login last_log = log.OrderByDescending(x => x.lug_start_date)
                                                       .FirstOrDefault();
                             if (!mrd_zoneB.Contains(last_log.mrd_id))
                             {
                                 return(true);
                             }
                         }
                     }
                 }
             }
         }
     }
     catch
     {
     }
     return(false);
 }
Exemplo n.º 6
0
 public static void Logout()
 {
     if (Program.CurrentUser != null)
     {
         InhCheckupDataContext dbc = new InhCheckupDataContext();
         log_user_login        currentloguserlogin = (from t1 in dbc.log_user_logins
                                                      where t1.mut_id == Program.CurrentUser.mut_id &&
                                                      t1.lug_end_date == null
                                                      select t1).FirstOrDefault();
         if (currentloguserlogin != null)
         {
             currentloguserlogin.lug_end_date = Program.GetServerDateTime();
         }
         mst_user_type CurrentUser = (from t1 in dbc.mst_user_types where t1.mut_id == Program.CurrentUser.mut_id select t1).FirstOrDefault();
         CurrentUser.mut_login_status = '0';
         dbc.SubmitChanges();
     }
     Program.CurrentUser = null;
 }
Exemplo n.º 7
0
 private void BtnLogin_Click(object sender, EventArgs e)
 {
     if (RDOnQueue.Checked)
     {
         GetTypeQueue = "N";
         if (CBRoom.SelectedValue != null)
         {
             //OldLogin();
             NewLogin();
         }
         else
         {
             //this.DialogResult = System.Windows.Forms.DialogResult.No;
         }
     }
     else
     {
         GetTypeQueue = "O";
         log_user_login newlog = new log_user_login();
         newlog.mut_id         = Program.CurrentUser.mut_id;
         newlog.mhs_id         = Program.CurrentSite.mhs_id;
         newlog.lug_ip_address = Program.GetLocalIP();
         newlog.lug_start_date = Program.GetServerDateTime();
         dbc.log_user_logins.InsertOnSubmit(newlog);
         dbc.SubmitChanges();
         Class.ClsManageUserLogin.current_log = newlog;
         Program.CurrentLogin = newlog;
         mst_user_type CurrentUserlogin = (from t1 in dbc.mst_user_types where t1.mut_id == Program.CurrentUser.mut_id select t1).FirstOrDefault();
         CurrentUserlogin.mut_login_status = '1';
         dbc.SubmitChanges();
         this.DialogResult = System.Windows.Forms.DialogResult.OK;
     }
     //if (CBRoom.SelectedValue != null)
     //{
     //    //OldLogin();
     //    NewLogin();
     //}
     //else
     //{
     //    //this.DialogResult = System.Windows.Forms.DialogResult.No;
     //}
 }
Exemplo n.º 8
0
        public static Boolean Login(string strUsername, int siteID, int roomID)
        {
            InhCheckupDataContext dbc = new InhCheckupDataContext();

            try
            {
                if (Program.CurrentUser != null)
                {//ตรวจสอบ Type หมอ หรือ อื่น เข้าห้องเกินจำนวนที่กำหนดหรือไม่
                    int countRoomLogin = (from t1 in dbc.log_user_logins
                                          where t1.mrd_id == roomID &&
                                          t1.mut_id != CurrentUser.mut_id &&
                                          t1.lug_end_date == null
                                          select t1).Count();
                    mst_room_dtl Currentroomdtl  = (from t1 in dbc.mst_room_dtls where t1.mrd_id == roomID select t1).FirstOrDefault();
                    int          limitUserinRoom = 0;
                    if (Program.CurrentUser.mut_type == 'D')
                    {//เป็นหมอ
                        limitUserinRoom = Convert.ToInt32(Currentroomdtl.mst_room_hdr.mrm_count_doctor);
                    }
                    else
                    {//คนที่ไม่ใช่หมอ if (Program.CurrentUser.mut_type == 'O')
                        limitUserinRoom = Convert.ToInt32(Currentroomdtl.mst_room_hdr.mrm_count_person);
                        //if (Program.CurrentUser.mut_CanSendQueue==true)
                        //{// กรณีเป็น คนสามารถส่งQueue

                        //}
                    }

                    if (countRoomLogin + 1 > limitUserinRoom)
                    {
                        string msgalert = string.Format("ไม่สามารถ Login เข้า HPC Site :[{0}] Room :[{1}] นี้ได้เนื่องจากมีคนเข้ามาใช้เกินจากที่กำหนดไว้",
                                                        Currentroomdtl.mst_room_hdr.mst_hpc_site.mhs_ename,
                                                        Currentroomdtl.mrd_ename);
                        MessageBox.Show(msgalert, "Login Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        Program.CurrentRoom  = null;
                        Program.CurrentRegis = null;
                        return(false);
                    }



                    //if (getLoginStatus(Program.CurrentUser.mut_id) == '1')
                    //{
                    bool Asking = Class.ClsManageUserLogin.checkAskingLoginRoom(roomID);
                    if (Asking)
                    {
                        log_user_login lug      = getNotSignOut(Program.CurrentUser.mut_id).LastOrDefault();
                        string         msgalert = string.Format("Username : [{0}] มีการ Login อยู่ที่ HPC:{1} Room : {2} คุณต้องการ Logout หรือไม่",
                                                                Program.CurrentUser.mut_username,
                                                                getSiteEnameByMrdID(lug.mrd_id),
                                                                getRoomEnameByMrdID(lug.mrd_id));
                        if (MessageBox.Show(msgalert, "Login Alert", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            //// Logout จากห้องเดิม
                            //log_user_login currentloguserlogin = (from t1 in dbc.log_user_logins
                            //                                      where t1.mrd_id == roomID
                            //                                      && t1.mut_id == Program.CurrentUser.mut_id
                            //                                      && t1.lug_end_date == null
                            //                                      select t1).FirstOrDefault();
                            //if (currentloguserlogin != null)
                            //{
                            //    currentloguserlogin.lug_end_date = Program.GetServerDateTime();
                            //}
                            //mst_user_type CurrentUser = (from t1 in dbc.mst_user_types where t1.mut_id == Program.CurrentUser.mut_id select t1).FirstOrDefault();
                            //CurrentUser.mut_login_status = '0';
                            //dbc.SubmitChanges();
                            Class.ClsManageUserLogin.kickLoginOldRoom(Program.CurrentUser.mut_id, roomID);
                        }
                        else
                        {
                            Program.CurrentRoom  = null;
                            Program.CurrentRegis = null;
                            return(false);
                        }
                    }
                    //}

                    mst_room_dtl curRoom = (from t1 in dbc.mst_room_dtls where t1.mrd_id == roomID select t1).FirstOrDefault();
                    curRoom.mrd_rm_status = 'N';
                    dbc.SubmitChanges();
                    Program.CurrentRoom = curRoom;

                    log_user_login newlog = new log_user_login();
                    newlog.mut_id         = Program.CurrentUser.mut_id;
                    newlog.mrd_id         = Program.CurrentRoom.mrd_id;
                    newlog.mhs_id         = Program.CurrentSite.mhs_id;
                    newlog.lug_ip_address = Program.GetLocalIP();
                    newlog.lug_start_date = Program.GetServerDateTime();
                    dbc.log_user_logins.InsertOnSubmit(newlog);
                    dbc.SubmitChanges();
                    Class.ClsManageUserLogin.current_log = newlog;
                    Program.CurrentLogin = newlog;

                    mst_user_type CurrentUserlogin = (from t1 in dbc.mst_user_types where t1.mut_id == Program.CurrentUser.mut_id select t1).FirstOrDefault();
                    CurrentUserlogin.mut_login_status = '1';
                    dbc.SubmitChanges();

                    return(true);
                }
                else
                {
                    Program.CurrentRoom  = null;
                    Program.CurrentLogin = null;
                    MessageBox.Show("ไม่มี Username ที่ระบุไว้โปรดติดต่อเจ้าหน้าที่");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error" + ex.Message, "Error Login", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
Exemplo n.º 9
0
 public static bool checkKickCurrentUser(int mut_id, int mhs_id)
 {
     try
     {
         if (current_log != null)
         {
             using (InhCheckupDataContext cdc = new InhCheckupDataContext())
             {
                 log_user_login _current_log = cdc.log_user_logins.Where(x => x.lug_id == current_log.lug_id).FirstOrDefault();
                 if (_current_log.lug_end_date != null)
                 {
                     return(true);
                 }
                 else
                 {
                     List <log_user_login> log = cdc.log_user_logins
                                                 .Where(x => x.mut_id == mut_id &&
                                                        x.lug_end_date == null &&
                                                        x.mhs_id == mhs_id)
                                                 .ToList();
                     if (log != null)
                     {
                         log_user_login last_log = log.OrderByDescending(x => x.lug_start_date)
                                                   .FirstOrDefault();
                         if (last_log.lug_id != current_log.lug_id)
                         {
                             EmrClass.GetDataMasterCls mst = new EmrClass.GetDataMasterCls();
                             List <int?> mrd_zoneB         = mst.Get_MrdZoneB;
                             if (!mrd_zoneB.Contains(last_log.mrd_id))
                             {
                                 return(true);
                             }
                             else
                             {
                                 bool chkOtherZone = false;
                                 List <log_user_login> order_log = log.Where(x => x.lug_id != last_log.lug_id)
                                                                   .OrderByDescending(x => x.lug_start_date)
                                                                   .ToList();
                                 foreach (log_user_login result in order_log)
                                 {
                                     if (chkOtherZone == false && !mrd_zoneB.Contains(result.mrd_id))
                                     {
                                         chkOtherZone = true;
                                     }
                                     if (result.lug_id == current_log.lug_id)
                                     {
                                         if (chkOtherZone == true)
                                         {
                                             return(true);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     catch
     {
     }
     return(false);
 }