//初始化数据库链接基本信息 public HosDateLogic() { db_name = OperatFile.GetIniFileString("DataBase", "his_db_name", "", Application.StartupPath + "\\jianyi.ini"); db_server = OperatFile.GetIniFileString("DataBase", "his_db_server", "", Application.StartupPath + "\\jianyi.ini"); UserID = OperatFile.GetIniFileString("DataBase", "his_UserID", "", Application.StartupPath + "\\jianyi.ini"); Pwd = OperatFile.GetIniFileString("DataBase", "his_Pwd", "", Application.StartupPath + "\\jianyi.ini"); str_conn = "Server=" + db_server + ";Database=" + db_name + ";uid=" + UserID + ";pwd=" + Pwd + ";Connect Timeout=4"; }
//初始化数据库链接基本信息 public TempDateLogic() { //获取dll的实际路径 string _CodeBase = System.Reflection.Assembly.GetExecutingAssembly().CodeBase; _CodeBase = _CodeBase.Substring(8, _CodeBase.Length - 8).Replace("YCF.BLL.DLL", ""); // 8是file:// 的长度 db_name = OperatFile.GetIniFileString("DataBase", "db_name", "", _CodeBase + "DBConfig.ini"); db_server = OperatFile.GetIniFileString("DataBase", "db_server", "", _CodeBase + "DBConfig.ini"); UserID = OperatFile.GetIniFileString("DataBase", "UserID", "", _CodeBase + "DBConfig.ini"); Pwd = OperatFile.GetIniFileString("DataBase", "Pwd", "", _CodeBase + "DBConfig.ini"); str_conn = "Server=" + db_server + ";Database=" + db_name + ";uid=" + UserID + ";pwd=" + Pwd + ";Connect Timeout=4"; }
/// <summary> /// 验证登录方法 /// </summary> private void Login() { String usercode = textBox1.Text.Trim(); String password = textBox2.Text.Trim(); string hospital = this.hospital.Text.Trim(); if (String.IsNullOrEmpty(usercode)) { MessageBox.Show("用户名不能为空!", "系统提示"); textBox1.Focus(); return; } if (String.IsNullOrEmpty(password)) { MessageBox.Show("密码不能为空!", "系统提示"); textBox2.Focus(); return; } //if (string.IsNullOrEmpty(hospital)) //{ // MessageBox.Show("请选择院区!", "系统提示"); // this.hospital.Focus(); // return; //} //连接后台数据库判断本用户是否存在! SYS_USERS users = userbll.Get(usercode); try { if (users == null) { MessageBox.Show("用户名或者密码错误!", "系统提示"); textBox2.Focus(); return; } else { if (password != users.PASSWORD) { MessageBox.Show("用户名或者密码错误!", "系统提示"); textBox2.Focus(); return; } else { globalInfoClass.PassWord = users.PASSWORD; //赋值用户密码 globalInfoClass.UserCode = users.USER_CODE; //赋值用户编码 globalInfoClass.UserName = users.USER_NAME; //赋值用户姓名 globalInfoClass.UserType = users.USER_TYPE; //赋值用户类型,判断权限 globalInfoClass.Pre_Max = (int)users.PRE_MAX; //赋值用户类型,判断权限 globalInfoClass.User_Role = users.ROLE_CODE; //赋值用户类型,判断权限 globalInfoClass.Ward_name = users.WARD_NAME; globalInfoClass.Zhicheng = users.ZHICHENG; globalInfoClass.Zhiwu = users.ZHIWU; //globalInfoClass.Hospital = "礼嘉分院";//this.hospital.Text.Trim(); textBox1.Text = OperatFile.SetIniFileString("HospitalInfo", "hospital_name", hospital, Application.StartupPath + "\\hospitalinfo.ini"); this.DialogResult = DialogResult.OK;//跳转到主窗体控件 this.Close(); } } } catch (Exception ex) { throw ex; } finally { } this.DialogResult = DialogResult.OK;//跳转到主窗体控件 this.Close(); }
public login() { InitializeComponent(); hospital.Text = OperatFile.GetIniFileString("HospitalInfo", "hospital_name", "", Application.StartupPath + "\\hospitalinfo.ini"); textBox1.Select(); }