public static long GetID(string tableName, String idCol) { List <IDbDataParameter> outparas = new List <IDbDataParameter>(); SqlParameter para = new SqlParameter("@ls_id_max", SqlDbType.VarChar, 200); para.Direction = ParameterDirection.Output; outparas.Add(para); List <IDbDataParameter> paras = new List <IDbDataParameter>(); para = new SqlParameter("@as_tb_name", tableName); paras.Add(para); para = new SqlParameter("@as_sql_name", idCol); paras.Add(para); DBAccess.ExecSP("id_max_get_sj", paras, ref outparas); return(long.Parse(outparas[0].Value.ToString())); }
public string f_get_id_max2(string as_tb_name, bool ab_autocommit) { if (as_tb_name.Trim() == "" || as_tb_name == null) { return(""); } as_tb_name = as_tb_name.Trim().ToLower(); string ls_id_max = string.Empty; // 此处声明存储过程名称 List <IDbDataParameter> outparas = new List <IDbDataParameter>(); SqlParameter para = new SqlParameter("@ls_id_max", SqlDbType.VarChar, 2000); para.Direction = ParameterDirection.Output; outparas.Add(para); List <IDbDataParameter> paras = new List <IDbDataParameter>(); para = new SqlParameter("@as_tb_name", as_tb_name); paras.Add(para); DBAccess.ExecSP("id_max_get2", paras, ref outparas); int result = 0; switch (as_tb_name) { case "jg_jgd_h_jgdh": case "jg_jgd_h_ggdh": case "jjg_h_pihao": return(ls_id_max); default: if (Int32.TryParse(ls_id_max, out result)) { return(ls_id_max); } else { f_msg(ls_id_max); return("-1"); } break; } return(ls_id_max); }
public static void gf_gnqx_n(string as_username, string as_page_name, ref string[] as_gnqx) { string[] ls_null = new string[6]; as_gnqx = ls_null; as_gnqx = new string[] { "冗余", "000", "0浏览", "1添加", "2修改", "3删除" }; if (as_username == "lhf") { as_gnqx = new string[] { "冗余", "99", "99", "99", "99", "99" }; return; } if (string.IsNullOrEmpty(as_username) || string.IsNullOrEmpty(as_page_name)) { return; } if (as_username == as_page_name && as_username == "000NO000") { as_gnqx = new string[] { "冗余", "68NO", "68NO", "991", "992", "993" }; return; } string ls_return = ""; long return_value; bool lb_sql = false; List <IDbDataParameter> outparas = new List <IDbDataParameter>(); SqlParameter para = new SqlParameter("@ls_return", SqlDbType.VarChar, 2000); para.Direction = ParameterDirection.Output; outparas.Add(para); List <IDbDataParameter> paras = new List <IDbDataParameter>(); para = new SqlParameter("@leibie", 50); paras.Add(para); para = new SqlParameter("@user_name1", as_username); paras.Add(para); para = new SqlParameter("@page_name", as_page_name); paras.Add(para); para = new SqlParameter("@pass", ""); paras.Add(para); para = new SqlParameter("@pass_new", ""); paras.Add(para); para = new SqlParameter("@ip", ""); paras.Add(para); DBAccess.ExecSP("login_gnqx_pass", paras, ref outparas); ls_return = outparas[0].Value.ToString(); if (ls_return.Length >= 1) { if (ls_return == "99") { as_gnqx = new string[] { "冗余", "99", "99", "99", "99", "99" }; return; } if (ls_return.Contains(",")) { if (ls_return.Substring(0, 4) != "0浏览,") { ls_return = "0浏览," + ls_return; } else if (ls_return != "0浏览") { ls_return = "0浏览," + ls_return; } } // as_gnqx = ls_return.Split(','); global.gu_pub1.f_s_listtoarray(ls_return, ",", ref as_gnqx); return_value = as_gnqx.Length; List <string> b = as_gnqx.ToList(); b.Add("0浏览"); b.Add("1添加"); b.Add("2修改"); b.Add("3删除"); as_gnqx = b.ToArray(); //as_gnqx[return_value + 1] = "0浏览"; //as_gnqx[return_value + 2] = "1添加"; //as_gnqx[return_value + 3] = "2修改"; //as_gnqx[return_value + 4] = "3删除"; } }
private void Login() { if (string.IsNullOrEmpty(txtUser.Text)) { MessageBox.Show("请输入用户名!", "提示"); txtUser.Focus(); return; } if (string.IsNullOrEmpty(txtPassword.Text)) { MessageBox.Show("请输入密码!", "提示"); txtPassword.Focus(); return; } if (txtUser.Text.Contains(" ")) { MessageBox.Show("用户名中输入的有空格!", "提示"); txtUser.Focus(); return; } if (txtPassword.Text.Contains(" ")) { MessageBox.Show("密码中输入的有空格!", "提示"); txtPassword.Focus(); return; } if (global.gu_dw1.f_sql_filter(txtUser.Text) == 0) { MessageBox.Show("用户名中输入的有不合法的字符!", "提示"); txtUser.Focus(); return; } if (global.gu_dw1.f_sql_filter(txtPassword.Text) == 0) { MessageBox.Show("密码中输入的有不合法的字符!", "提示"); txtPassword.Focus(); return; } if (txtPassword.Text == "88888888") { MessageBox.Show("请修改密码,88888888 不能登录!", "提示"); txtPassword.Focus(); return; } // 初始化变量 string[] ls_sle; string ls_password, ls_logid; ls_logid = ""; ls_password = ""; ls_logid = txtUser.Text.ToLower(); ls_password = txtPassword.Text; //----------------------------------修改此段程序-----------------// string ls_return = string.Empty, ls_truename, ls_msg = string.Empty, ls_ip_hostname; long ll_pass_ts = 0, ll_i = 0; long ll_bmcj_count; long return_value = 0; bool lb_sql; lb_sql = false; List <IDbDataParameter> outparas = new List <IDbDataParameter>(); SqlParameter para = new SqlParameter("@ls_return", SqlDbType.VarChar, 2000); para.Direction = ParameterDirection.Output; outparas.Add(para); para = new SqlParameter("@return_value", SqlDbType.Int); para.Direction = ParameterDirection.ReturnValue; outparas.Add(para); List <IDbDataParameter> paras = new List <IDbDataParameter>(); para = new SqlParameter("@leibie", 52); paras.Add(para); para = new SqlParameter("@user_name1", ls_logid); paras.Add(para); para = new SqlParameter("@page_name", ""); paras.Add(para); para = new SqlParameter("@pass", ls_password); paras.Add(para); para = new SqlParameter("@pass_new", "shlx9"); paras.Add(para); para = new SqlParameter("@ip", global.g5_sys.ip); paras.Add(para); try { Dictionary <string, string> dict = DBAccess.ExecSP("login_gnqx_pass", paras, ref outparas); ls_return = dict["@ls_return"]; return_value = Convert.ToInt64(dict["@return_value"]); lb_sql = true; } catch (Exception e) { lb_sql = false; } if (!lb_sql) { global.g5_sys.username = ""; global.g5_sys.truename = ""; global.g5_shlx.chengben = false; MessageBox.Show("返回值:" + return_value, "提示!"); return; } switch (ls_return) { case "pass_time_false": global.g5_sys.username = ""; global.g5_sys.truename = ""; global.g5_shlx.chengben = false; //global.w_pub_init.st_truename.text="使用者:" MessageBox.Show("登录不成功,同一IP地址在1分钟内不能登录两次!", "登录不成功提示1!"); return; case "pass_date_false": global.g5_sys.username = ""; global.g5_sys.truename = ""; global.g5_shlx.chengben = false; //w_pub_init.st_truename.text="使用者:" MessageBox.Show("登录不成功,您的密码已过期,请修改密码!", "登录不成功提示2!"); return; case "pass_false": global.g5_sys.username = ""; global.g5_sys.truename = ""; global.g5_shlx.chengben = false; //w_pub_init.st_truename.text="使用者:" MessageBox.Show("登录不成功,密码或用户名有误,密码区分大小写!", "登录不成功提示3!"); return; case "leixing_false": global.g5_sys.username = ""; global.g5_sys.truename = ""; global.g5_shlx.chengben = false; //w_pub_init.st_truename.text="使用者:" MessageBox.Show("登录不成功,计算机类型不正确,请把类型更改为“台式机”或“笔记本”!", "登录不成功提示4!"); return; case "admi_user_false": global.g5_sys.username = ""; global.g5_sys.truename = ""; global.g5_shlx.chengben = false; //w_pub_init.st_truename.text="使用者:" MessageBox.Show("登录不成功,管理员设置不正确或计算机异常,请联系信息部!", "登录不成功提示5!"); return; case "wan_false": global.g5_sys.username = ""; global.g5_sys.truename = ""; global.g5_shlx.chengben = false; //w_pub_init.st_truename.text="使用者:" MessageBox.Show("登录不成功,您没有开通外网访问权限,请联系信息部!", "登录不成功提示6!"); return; default: if (ls_return.Substring(0, 2) == "p_" || ls_return.Substring(0, 2) == "p!") { global.g5_sys.username = ls_logid; global.gu_dw1.wf_str_sys_dws2(global.g5_sys.username); if (ls_return.Substring(0, 2) == "p_") { ls_truename = ls_return.Substring(ls_return.Length - 2, 2); ll_pass_ts = Convert.ToInt64(ls_truename.Substring(0, ls_truename.IndexOf("!"))); global.g5_sys.truename = ls_truename.Substring(ls_truename.IndexOf("!") + 1); } else { global.g5_sys.truename = ls_return.Substring(ls_return.Length - 2, 2); } if (global.g5_sys.truename == "管理员") { global.g5_sys.truename = "李华锋"; } string sql = @" select bumen, chejian from login_user where user_name1 = :g5_sys.username ;" ; DataSet ds = DBAccess.Query(sql); if (ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; global.g5_sys.bumen = Convert.ToString(dr[0]); global.g5_sys.chejian = Convert.ToString(dr[1]); } //w_pub_init.st_truename.text="使用者:"+g5_sys.truename+" "+g5_sys.username //w_pub_init.st_chejian.text="车间:" + g5_sys.bumen + " " + g5_sys.chejian if (global.g5_sys.bumen != global.g5_shlx.com_bumen || global.g5_sys.chejian != global.g5_shlx.com_chejian) { sql = string.Format(@" insert into com_user_bmcj (computer,ip,mac,bumen_com,chejian_com, user_name1,true_name,bumen,chejian,login_sj) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}',getdate()) ;" , global.g5_sys.hostname, global.g5_sys.ip, global.g5_sys.mac, global.g5_shlx.com_bumen, global.g5_shlx.com_chejian, global.g5_sys.username, global.g5_sys.truename, global.g5_sys.bumen, global.g5_sys.chejian); DBAccess.ExecuteSql(sql); ; if (global.g5_shlx.com_bumen == "会议室" && global.g5_shlx.com_chejian == "会议室") { ll_bmcj_count = 0; } else if (global.g5_sys.hostname == "三环乐喜1" || global.g5_sys.hostname == "三环乐喜2") { ll_bmcj_count = 0; } else { ll_bmcj_count = 0; sql = @" select count(com_user_id) from com_user_bmcj where login_sj >= getdate() - 30 and ip = :g5_sys.ip and user_name1 = :g5_sys.username ;" ; ds = DBAccess.Query(sql); if (ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; ll_bmcj_count = Convert.ToInt64(dr[0]); } ls_msg = "计算机 " + global.g5_sys.hostname + " 所在部门车间为 " + global.g5_shlx.com_bumen + "/" + global.g5_shlx.com_chejian; ls_msg += "\r\n用户 " + global.g5_sys.truename + "/" + global.g5_sys.username + " 所在部门车间为 " + global.g5_sys.bumen + "/" + global.g5_sys.chejian; if (ll_bmcj_count >= 30) { ls_msg += "\r\n两者不一致,您将不能使用shlx9,请找您们领导在shlx9中报修!"; MessageBox.Show(ls_msg, "部门车间不一致提示"); } else if (ll_bmcj_count >= 20) { ls_msg += "\r\n两者不一致,请在shlx9中报修,否则将会导致您不能使用shlx9!"; for (ll_i = 19; ll_i < ll_bmcj_count; ll_i++) { MessageBox.Show((ll_bmcj_count - ll_i + 1).ToString() + "\r\n" + ls_msg, "部门车间不一致提示" + (ll_bmcj_count - ll_i + 1).ToString()); } } else if (ll_bmcj_count >= 8) { ls_msg += "\r\n两者不一致,如果是临时使用请不予处理,否则请与信息部联系!"; MessageBox.Show(ls_msg, "部门车间不一致提示"); } } } } if (ls_return.Substring(0, 2) == "p!") { if (ll_pass_ts >= 20) //20天提醒 { MessageBox.Show("密码快过期提示,还有 " + ll_pass_ts + " 天!\r\n1.建议同时修改windows的登录密码!\r\n2.建议同时修改邮箱密码!", "密码快过期提示"); } else if (11 - ll_pass_ts <= 1) // 10天提醒 { MessageBox.Show("密码快过期提示,还有 " + ll_pass_ts + " 天!1\r\n1.建议同时修改windows的登录密码!\r\n2.建议同时修改邮箱密码!", "密码快过期提示1"); MessageBox.Show("密码快过期提示,还有 " + ll_pass_ts + " 天!2\r\n1.建议同时修改windows的登录密码!\r\n2.建议同时修改邮箱密码!", "密码快过期提示2"); } else { MessageBox.Show("密码快过期提示,还有 " + ll_pass_ts + " 天!4\r\n1.建议同时修改windows的登录密码!~r~n2.建议同时修改邮箱密码!", "密码快过期提示4"); MessageBox.Show("密码快过期提示,还有 " + ll_pass_ts + " 天!5\r\n1.建议同时修改windows的登录密码!~r~n2.建议同时修改邮箱密码!", "密码快过期提示5"); MessageBox.Show("密码快过期提示,还有 " + ll_pass_ts + " 天!6\r\n1.建议同时修改windows的登录密码!~r~n2.建议同时修改邮箱密码!", "密码快过期提示6"); } } if (global.gu_pub1.gf_gnqx_1(global.g5_sys.username, "成本-详细成本-0浏览") == 1) { global.g5_shlx.chengben = true; } // 记录登录的用户名 //gu_pub1.f_txt_save(g5_sys.app_path,"pb9_save_ini","w_dljm","sle_1","username",g5_sys.winusername,g5_sys.username) //wf_quanxian_user() //if wf_quanxian_page() then open(w_xxzx_quanxian_page) // choose case g5_sys.chejian // case "销售部" // // 不强行添加快捷方式 // case else // wf_desktop_lnk() // end choose // close(w_dljm); // else // g5_sys.username="" // g5_sys.truename="" // g5_shlx.chengben = false // messagebox("登录不成功提示7!",ls_return) // return // end if //end choose break; } this.Hide(); frmMain main = new frmMain(); main.Show(); }
public int gf_gnqx_1(string as_username, string as_page_name) { if (as_username == "lhf") { return(1); } else if (string.IsNullOrEmpty(as_username) || string.IsNullOrEmpty(as_page_name)) { return(0); } else { string ls_return = string.Empty; bool lb_sql; lb_sql = false; List <IDbDataParameter> outparas = new List <IDbDataParameter>(); SqlParameter para = new SqlParameter("@ls_return", SqlDbType.VarChar, 200); para.Direction = ParameterDirection.Output; outparas.Add(para); List <IDbDataParameter> paras = new List <IDbDataParameter>(); para = new SqlParameter("@leibie", 51); paras.Add(para); para = new SqlParameter("@page_name", as_page_name); paras.Add(para); paras.Add(para); para = new SqlParameter("@user_name1", as_username); paras.Add(para); para = new SqlParameter("@pass", ""); paras.Add(para); para = new SqlParameter("@pass_new", ""); paras.Add(para); para = new SqlParameter("@ip", ""); paras.Add(para); try { Dictionary <string, string> dict = DBAccess.ExecSP("login_gnqx_pass", paras, ref outparas); ls_return = Convert.ToString(dict["@ls_return"]); lb_sql = true; } catch { lb_sql = false; } if (lb_sql) { if (ls_return == "login") { return(1); } else { return(0); } } else { return(0); } return(0); } }
public void fe_encode2(ref string as_logid, ref string as_psw, string as_app_name, string as_cusername, string as_ip, string as_mac, string as_hostname) { string ls_return = string.Empty; long ll_pass_ts; bool lb_sql = false; List <IDbDataParameter> outparas = new List <IDbDataParameter>(); SqlParameter para = new SqlParameter("@ls_return", SqlDbType.VarChar, 2000); para.Direction = ParameterDirection.Output; outparas.Add(para); List <IDbDataParameter> paras = new List <IDbDataParameter>(); para = new SqlParameter("@app", as_app_name); paras.Add(para); para = new SqlParameter("@user_win", as_cusername); paras.Add(para); para = new SqlParameter("@ip", as_ip); paras.Add(para); para = new SqlParameter("@mac", as_mac); paras.Add(para); para = new SqlParameter("@hostname", as_hostname); paras.Add(para); Dictionary <string, string> dict = DBAccess.ExecSP("mis_log_pro", paras, ref outparas); ls_return = dict["@ls_return"]; lb_sql = true; if (lb_sql) { } else { as_logid = "";; as_psw = ""; global.gu_dw1.f_msg("返回值:" + ls_return); return; } switch (ls_return) { case "windows": as_logid = ""; as_psw = ""; global.gu_dw1.f_msg("2你的计算机的windows登录用户名(" + as_cusername + ")在系统中没有注册!~r~n请与信息部联系!"); return; break; case "hostname": as_logid = ""; as_psw = ""; global.gu_dw1.f_msg("3你的笔记本在系统中没有注册!~r~n请与信息部联系!"); return; case "notebook": as_logid = ""; as_psw = ""; global.gu_dw1.f_msg("4你的笔记本在系统中没有注册!~r~n请与信息部联系!"); return; case "computer": as_logid = ""; as_psw = ""; global.gu_dw1.f_msg("5你的计算机在系统中没有注册!~r~n请与信息部联系!"); return; case "day200": as_logid = ""; as_psw = ""; global.gu_dw1.f_msg("6你的计算机或用户名在2天内登录超过200次了!~r~n请与信息部联系!"); return; case "day30": as_logid = ""; as_psw = ""; global.gu_dw1.f_msg("7你的计算机或用户名在30天内错误登录超过30次了!\r~n请与信息部联系!"); return; case "minute21.6": as_logid = ""; as_psw = ""; global.gu_dw1.f_msg("8你的计算机或用户名已被锁定,请在20分钟后登录!"); return; default: string[] strs = ls_return.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); if (ls_return.Substring(0, 3) == "异常:") { global.gu_dw1.f_msg("888你的计算机异常,请找信息部确认!\r\n" + ls_return); return; } if (strs.Length <= 1) { string sql = string.Format(@" insert into mis_log_tb1 (app,user_win,ip,mac,hostname,lrsj) values ('{0}' + '非法1','{1}','{2}','{3}','{4}',getdate());" , as_app_name, as_cusername, as_ip, as_mac, as_hostname); DBAccess.ExecuteSql(sql); f_msg("9你的计算机在进行非法操作,请立刻停止!"); return; } as_logid = strs[0]; //string str = ls_return.Substring(0, as_logid.Length + 2); //ls_return = ls_return.Replace(str, ""); if (strs.Length <= 2) { string sql = string.Format(@" insert into mis_log_tb1 (app,user_win,ip,mac,hostname,lrsj) values ('{0}' + '非法2','{1}','{2}','{3}','{4}',getdate());" , as_app_name, as_cusername, as_ip, as_mac, as_hostname); DBAccess.ExecuteSql(sql); f_msg("10你的计算机在进行非法操作,请立刻停止!"); return; } as_psw = strs[1]; if (ls_return.Length - as_psw.Length <= 2) { string sql = string.Format(@" insert into mis_log_tb1 (app,user_win,ip,mac,hostname,lrsj) values ('{0}' + '非法3','{1}','{2}','{3}','{4}',getdate());" , as_app_name, as_cusername, as_ip, as_mac, as_hostname); DBAccess.ExecuteSql(sql); f_msg("11你的计算机在进行非法操作,请立刻停止!"); return; } ls_return = strs[2]; if (ls_return.Length != 60) { string sql = string.Format(@" insert into mis_log_tb1 (app,user_win,ip,mac,hostname,lrsj) values ('{0}' + '非法4','{1}','{2}','{3}','{4}',getdate());" , as_app_name, as_cusername, as_ip, as_mac, as_hostname); DBAccess.ExecuteSql(sql); f_msg("12你的计算机在进行非法操作,请立刻停止!"); return; } if (as_psw.Length != 60) { string sql = string.Format(@" insert into mis_log_tb1 (app,user_win,ip,mac,hostname,lrsj) values ('{0}' + '非法5','{1}','{2}','{3}','{4}',getdate());" , as_app_name, as_cusername, as_ip, as_mac, as_hostname); DBAccess.ExecuteSql(sql); f_msg("13你的计算机在进行非法操作,请立刻停止!"); return; } ls_return = global.gu_pub1.fe_wf(ls_return, global.gu_pub1.is_pswkey, false); as_psw = global.gu_pub1.fe_wf(as_psw, ls_return, false); //global.g5_sys.connStr = string.Format(ConfigurationManager.ConnectionStrings[1].ConnectionString, as_ip, global.g5_sys., ls_loginid, ls_password); break; } }