private void btnSave_Click(object sender, EventArgs e) { lbAlertMessage.Text = ""; if (GridUsertype.CurrentRow != null) { string UserID = Convert1.ToString(GridUsertype.CurrentRow.Cells[1].Value); string UserName = GridUsertype.CurrentRow.Cells[2].Value.ToString(); var listUserroom = (from t1 in dbc.mst_user_rooms where t1.mut_username == UserName select t1); dbc.mst_user_rooms.DeleteAllOnSubmit(listUserroom); for (int i = 0; i <= dataGridView1.Rows.Count - 1; i++) { if (Convert1.ToBoolean(dataGridView1[0, i].Value) == true) { int mrmid = Utility.GetInteger(dataGridView1[1, i].Value); mst_user_type usermut = (from t1 in dbc.mst_user_types where t1.mut_username == UserName select t1).FirstOrDefault(); mst_user_room newitem = new mst_user_room(); newitem.mst_user_type = usermut; newitem.mut_id = usermut.mut_id; newitem.mut_username = UserName; newitem.mrm_id = mrmid; dbc.mst_user_rooms.InsertOnSubmit(newitem); } } dbc.SubmitChanges(); lbAlertMessage.Text = "Save data completed."; } else { lbAlertMessage.Text = "Please select user for edit."; } }
public static void kickLoginOldRoom(int mut_id, int mrd_id) { using (InhCheckupDataContext cdc = new InhCheckupDataContext()) { var log = cdc.log_user_logins.Where(x => x.mut_id == mut_id && /*x.mrd_id == mrd_id &&*/ x.lug_end_date == null).ToList(); foreach (log_user_login item in log) { item.lug_end_date = Program.GetServerDateTime(); } cdc.SubmitChanges(); List <log_user_login> log_room = cdc.log_user_logins.Where(x => /*x.mrd_id == mrd_id &&*/ x.lug_end_date == null).ToList(); if (log_room == null || log_room.Count() == 0) { List <int?> list_mrd_id = log_room.Select(x => x.mrd_id).ToList(); List <mst_room_dtl> list_room_dtl = cdc.mst_room_dtls.Where(x => list_mrd_id.Contains(x.mrd_id)).ToList(); list_room_dtl.ForEach(x => x.mrd_rm_status = 'E'); //mst_room_dtl mrd = cdc.mst_room_dtls.Where(x => x.mrd_id == mrd_id).FirstOrDefault(); //if (mrd != null) //{ // mrd.mrd_rm_status = 'E'; //} } mst_user_type mut = cdc.mst_user_types.Where(x => x.mut_id == mut_id).FirstOrDefault(); mut.mut_login_status = Program.get_mutLoginStatus; cdc.SubmitChanges(); } }
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 }
public mst_user_type GetUser(string username) { using (InhCheckupDataContext cdc = new InhCheckupDataContext()) { mst_user_type mut = cdc.mst_user_types.Where(x => x.mut_username == username).FirstOrDefault(); return(mut); } }
private void ddlMstSite_SelectedIndexChanged(object sender, EventArgs e) { int site = (int)ddlMstSite.SelectedValue; mst_user_type currentmut = (mst_user_type)mstUserTypebindingSource1.Current; LoadRoom(site, currentmut.mut_id); CheckBox chkHeader = (CheckBox)gvMstRoom.Controls[2]; chkHeader.Checked = false; }
private void BtnLogin_Click(object sender, EventArgs e) { Program.CurrentUser = null; Program.CurrentRoom = null; Program.CurrentLogin = null; Program.CurrentSite = CBSite.SelectedItem as mst_hpc_site; if (string.IsNullOrEmpty(txtusername.Text) || string.IsNullOrEmpty(txtpassword.Text)) { lbAlertMsg.Text = "Please insert username and password."; } else if (Program.CurrentSite == null) { lbAlertMsg.Text = "Please select HPC site."; } else { mst_user_type user = CheckUserCheckup(txtusername.Text, txtpassword.Text); if (user != null) { Program.CurrentUser = user; Program.CurrentSite = CBSite.SelectedItem as mst_hpc_site; this.DialogResult = System.Windows.Forms.DialogResult.OK; try { using (InhCheckupDataContext cdc = new InhCheckupDataContext()) { var u = cdc.mst_user_types.Where(x => x.mut_id == user.mut_id).FirstOrDefault(); u.mut_default_hpc = Program.CurrentSite.mhs_id; cdc.SubmitChanges(); } } catch { } } else { lbAlertMsg.Text = "Username or Password incorrect. Please try again"; } } //if (Program.Login(txtusername.Text.Trim(), txtpassword.Text.Trim(), Convert.ToInt32(CBSite.SelectedValue))) //{ // this.DialogResult = System.Windows.Forms.DialogResult.OK; //} //else //{ // lbAlertMsg.Text = "UserName && Password incorrect. Please try again"; // txtusername.Text = ""; // txtpassword.Text = ""; // txtusername.Focus(); //} }
private void ChStatus_MouseClick(object sender, MouseEventArgs e) { mst_user_type currentmut = (mst_user_type)mstUserTypebindingSource1.Current; if (currentmut != null) { var data = (ChStatus.Checked == true) ? 'A' : 'I'; if (data != currentmut.mut_status) { currentmut.mut_status = data; } } }
private void chkOutCheckup_MouseClick(object sender, MouseEventArgs e) { mst_user_type currentmut = (mst_user_type)mstUserTypebindingSource1.Current; if (currentmut != null) { var data = (chkOutCheckup.Checked == true) ? true : false; if (data != currentmut.mut_out_checkup) { currentmut.mut_out_checkup = data; } } }
private void RDGender_M_MouseClick(object sender, MouseEventArgs e) { mst_user_type currentmut = (mst_user_type)mstUserTypebindingSource1.Current; if (currentmut != null) { var data = Program.GetValueRadioTochar(pnlGender); if (data != currentmut.mut_gender) { currentmut.mut_gender = data; } } }
private void RDuserType_O_MouseClick(object sender, MouseEventArgs e) { mst_user_type currentmut = (mst_user_type)mstUserTypebindingSource1.Current; if (currentmut != null) { var datach = Program.GetValueRadioTochar(pnlmut_type); if (datach != currentmut.mut_type) { currentmut.mut_type = datach; } } }
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; }
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; //} }
private void btnAddNewUser_Click(object sender, EventArgs e) { SetbuttongSave(); mstUserTypebindingSource1.AddNew(); DateTime dtnow = Program.GetServerDateTime(); mst_user_type currentmut = (mst_user_type)mstUserTypebindingSource1.Current; currentmut.mut_login_status = '0';//0 =not Login ,1=login currentmut.mut_update_by = Program.CurrentUser.mut_username; currentmut.mut_update_date = dtnow; currentmut.mut_create_by = Program.CurrentUser.mut_username; currentmut.mut_create_date = dtnow; currentmut.mut_admin = true; currentmut.mut_type = 'N'; currentmut.mut_CanSendQueue = true; currentmut.mut_out_checkup = false; currentmut.mut_gender = 'F'; RDGenderF.Checked = true; RDuserType_N.Select(); gvUserRoom.Rows.Clear(); btnEditUser_Click(sender, e); }
private void ch_isAdmin_MouseClick(object sender, MouseEventArgs e) { if (ch_isAdmin.Checked) { pnlAdminType.Enabled = true; } else { pnlAdminType.Enabled = false; //RDAdmin_UserAdmin.Checked = true; RDAdmin_UserAdmin.Checked = false; } mst_user_type currentmut = (mst_user_type)mstUserTypebindingSource1.Current; if (currentmut != null) { var data = (ch_isAdmin.Checked == true) ? true : false; if (data != currentmut.mut_admin) { currentmut.mut_admin = data; } } }
private mst_user_type CheckUserCheckup(string username, string password) { try { using (InhCheckupDataContext cdc = new InhCheckupDataContext()) { mst_user_type user = cdc.mst_user_types .Where(x => x.mut_username.ToUpper() == username.ToUpper()) .FirstOrDefault(); if (user == null) { return(null); } else if (user.mut_admin_data == true && user.mut_password == password) { return(user); } else { bool checkpass = new APITrakcare.LogonTrakcareCls().CheckTrakcarePassword(username, password); if (checkpass) { return(user); } else { return(null); } } } } catch (Exception ex) { throw ex; } }
private void gvUserRoom_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0 && btnEditUser.Enabled == false) { switch (e.ColumnIndex) { case 3: if (gvUserRoom[3, e.RowIndex].Value != null) { if (gvUserRoom["userRoomID", e.RowIndex].Value == null) { gvUserRoom.Rows.RemoveAt(e.RowIndex); mst_user_type currentmut = (mst_user_type)mstUserTypebindingSource1.Current; LoadRoom((int)ddlMstSite.SelectedValue, currentmut.mut_id); CheckBox chkHeader = (CheckBox)gvMstRoom.Controls[2]; chkHeader.Checked = false; gvUserRoom.SetRuningNumber("no"); } else { gvUserRoom.Rows[e.RowIndex].Visible = false; gvUserRoom.SetRuningNumber("no"); //int removeRowID = (int)gvUserRoom["userRoomID", e.RowIndex].Value; //var objUserRoom = (from row in dbc.mst_user_rooms // where row.row_id == removeRowID // select row).FirstOrDefault(); //dbc.mst_user_rooms.DeleteOnSubmit(objUserRoom); //dbc.SubmitChanges(); //mstUserTypebindingSource1_CurrentChanged(sender, e); //btnEditUser_Click(sender, e); } } break; } } }
private void mstUserTypebindingSource1_CurrentChanged(object sender, EventArgs e) { lbmsgalert.Text = ""; //char? admintype = Program.GetValueRadioTochar(pnlAdminType); //if(admintype== if (dbc.GetChangeSet().Updates.Count > 0 || dbc.GetChangeSet().Inserts.Count > 0) { if (MessageBox.Show("Do you want save change data.", "Confirm Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { SaveData(); } else { btnClaear_cancel_Click(null, null); return; } } mst_user_type currentmut = (mst_user_type)mstUserTypebindingSource1.Current; gvUserRoom.DataBindings.Clear(); if (currentmut != null) { //start date if (currentmut.mut_effective_date != null) { txtEffectDate.Value = Convert.ToDateTime(currentmut.mut_effective_date); } else { txtEffectDate.Value = DateTime.Now; } //end date if (currentmut.mut_expire_date != null) { rdoExpireDt.Checked = true; txtExpireDate.Enabled = true; txtExpireDate.Value = Convert.ToDateTime(currentmut.mut_expire_date); } else { rdoNonExpire.Checked = true; txtExpireDate.Enabled = false; txtExpireDate.Value = DateTime.Now; } //status if (currentmut.mut_status == 'A') { ChStatus.Checked = true; } else { ChStatus.Checked = false; } //Gender Program.SetValueRadioGroup(pnlGender, currentmut.mut_gender); //mutType Program.SetValueRadioGroup(pnlmut_type, currentmut.mut_type); //Admin Type if (currentmut.mut_admin == true) { pnlAdminType.Enabled = true; Program.SetValueRadioGroup(pnlAdminType, currentmut.mut_admin_type); } else { pnlAdminType.Enabled = false; RDAdmin_UserAdmin.Checked = true; RDAdmin_UserAdmin.Checked = false; } // Clearbutton(); LoadRoom(ddlMstSite.SelectedValue == null? 1 : (int)ddlMstSite.SelectedValue, currentmut.mut_id); LoadUserRoom(currentmut.mut_id); } }
private void SaveData() { try { mst_user_type currentmut = (mst_user_type)mstUserTypebindingSource1.Current; if (currentmut != null) { //start date currentmut.mut_effective_date = txtEffectDate.Value; //end date if (rdoExpireDt.Checked) { currentmut.mut_expire_date = txtExpireDate.Value; } //status if (ChStatus.Checked == true) { currentmut.mut_status = 'A'; } else { currentmut.mut_status = 'I'; } //Gender currentmut.mut_gender = Program.GetValueRadioTochar(pnlGender); //mutType currentmut.mut_type = Program.GetValueRadioTochar(pnlmut_type); //Admin Type if (currentmut.mut_admin == true) { currentmut.mut_admin_type = Program.GetValueRadioTochar(pnlAdminType); } else { currentmut.mut_admin_type = null; } } mstUserTypebindingSource1.EndEdit(); dbc.SubmitChanges(); currentmut = (mst_user_type)mstUserTypebindingSource1.Current; for (int i = 0; i < gvUserRoom.Rows.Count; i++) { if (gvUserRoom["userRoomID", i].Value == null) { mst_user_room newRoom = new mst_user_room(); newRoom.mut_id = currentmut.mut_id; newRoom.mrm_id = (int)gvUserRoom["userMrmID", i].Value; newRoom.mut_username = currentmut.mut_username; dbc.mst_user_rooms.InsertOnSubmit(newRoom); } else if (!gvUserRoom.Rows[i].Visible) { int removeRowID = (int)gvUserRoom["userRoomID", i].Value; var objUserRoom = (from row in dbc.mst_user_rooms where row.row_id == removeRowID select row).FirstOrDefault(); dbc.mst_user_rooms.DeleteOnSubmit(objUserRoom); } } dbc.SubmitChanges(); lbmsgalert.Text = "Save data completed."; } catch (Exception ex) { //Program.MessageError(ex.Message); lbmsgalert.Text = "Error:" + ex.Message; } }
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); } }