/// <summary> /// 根据用户ID获取邮件地址 /// </summary> /// <param name="userid"></param> /// <returns></returns> public static string GetEmailAddressByUserID(string userid) { string retEmail = ""; string sql = "SELECT [EMAIL] FROM [dbo].[TBDS_STAFFINFO] WHERE [ST_ID]='" + userid + "'"; SqlDataReader dr_email = DBCallCommon.GetDRUsingSqlText(sql); if (dr_email.HasRows) { dr_email.Read(); retEmail = dr_email["EMAIL"].ToString(); } dr_email.Close(); return(retEmail); }
/// <summary> /// 目标源中是否有数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void txtTarget_OnTextChanged(object sender, EventArgs e) { if (txtAfterFX.Text.Trim() != "") { //是否存在数据 string sql = "select count(*) as Num from " + TabelNameTarget + " where BM_ENGID = '" + TaskIDTarget + "' AND (BM_ZONGXU='" + txtAfterFX.Text.Trim() + "' OR BM_ZONGXU LIKE '" + txtAfterFX.Text.Trim() + ".%' )"; SqlDataReader dr_sql = DBCallCommon.GetDRUsingSqlText(sql); dr_sql.Read(); if (Convert.ToInt16(dr_sql["Num"].ToString()) > 0) { lblTip.Text = "已存在(" + dr_sql["Num"].ToString() + ")条,可能无法全部导入"; lblTip.ToolTip = "点击【||导入信息||】查看详细信息!!!"; lblTip.Visible = true; } else { lblTip.Text = ""; lblTip.ToolTip = ""; lblTip.Visible = false; } dr_sql.Close(); //是否存在父级 if (lblTip.Visible == false) { if (txtAfterFX.Text.Trim().Contains('.')) { string xh_fj = txtAfterFX.Text.Trim().Substring(0, txtAfterFX.Text.Trim().LastIndexOf('.')); string sql_fx = "select * from " + TabelNameTarget + " where BM_ENGID like '" + TaskIDTarget + "%' AND BM_ZONGXU='" + xh_fj + "'"; SqlDataReader dr_sql_fx = DBCallCommon.GetDRUsingSqlText(sql_fx); if (!dr_sql_fx.HasRows) { lblTip.Text = "没有父级,无法导入"; lblTip.Visible = true; } else { lblTip.Text = ""; lblTip.Visible = false; } } } } else { lblTip.Text = ""; lblTip.Visible = false; } }
/// <summary> /// 通过查询语句获取第一个值 /// </summary> /// <param name="sql"></param> /// <returns></returns> public static string getFirstCellStringByDR(string sql) { SqlDataReader dr = DBCallCommon.GetDRUsingSqlText(sql); if (dr.Read()) { string r = dr[0] + ""; dr.Close(); return(r); } else { dr.Close(); return(""); } }
protected bool CheckUser() { bool bUser = false; string strText = ""; Encrypt_Decrypt ed = new Encrypt_Decrypt(); string password = ed.MD5Encrypt(PassWord.Text.Trim(), "!@#$%^&*"); strText = "select a.ST_ID,a.ST_NAME,a.ST_PASSWORD,a.ST_DEPID,b.DEP_NAME,a.R_NAME,a.ST_POSITION ,st_allow_in "; strText += "from TBDS_STAFFINFO as a,TBDS_DEPINFO as b where a.ST_DEPID=b.DEP_CODE "; strText += "and (ST_CODE='" + UserName.Text + "' or ST_NAME = '" + UserName.Text + "') "; strText += "and ST_PASSWORD='******' "; SqlDataReader dr = DBCallCommon.GetDRUsingSqlText(strText); if (dr.Read()) { if (dr["ST_ALLOW_IN"].ToString() != "1") { bUser = false; power = "2"; } else { if (UserName.Text.Trim().Equals(dr["ST_NAME"].ToString()) || UserName.Text.Trim().Equals(dr["ST_CODE"].ToString())) { if (password.Equals(dr["ST_PASSWORD"].ToString())) { Session["UserName"] = dr["ST_NAME"].ToString(); Session["UserGroup"] = dr["R_NAME"].ToString(); Session["UserID"] = dr["ST_ID"].ToString(); Session["UserDeptID"] = dr["ST_DEPID"].ToString(); Session["UserDept"] = dr["DEP_NAME"].ToString(); Session["POSITION"] = dr["ST_POSITION"].ToString(); //Session["UserNameCode"] = dr["ST_NAMECODE"].ToString(); bUser = true; } } } } dr.Close(); return(bUser); }
/// <summary> /// 生成记录ID号(类别+日期+序号+版本号,共16位) </summary> /// <param name="type">类别:用以判断对哪个表进行操作</param> /// <param name="existID">已有ID:修改版本号时传值;新建ID时传空值</param> public static string CreateID(string type, string existID) { if (existID.Trim() != "" && existID.Trim().Length != 16) { return("error"); } string oldNO, oldNum, oldEditNum, newNO; //最近ID号、原序号、原版本号、新ID号 string oldYear, oldMonth, oldDay; //最近ID的年、月、日 int newYear, newMonth, newDay; //现在的年、月、日 string newNum, newEditNum; //新序号、版本号 string sqlText; string tableName = ""; switch (type) { case "xm": { tableName = "proj_info"; break; } case "xl": { tableName = "stage_xl"; break; } case "kj": { tableName = "stage_kj"; break; } case "sp": { tableName = "stage_sp"; break; } case "sq": { tableName = "stage_sq"; break; } case "sy": { tableName = "stage_sy"; break; } case "gy": { tableName = "process"; break; } case "sj": { tableName = "design"; break; } case "bm": { tableName = "bom_info"; break; } case "cq": { tableName = "m_confirm_info"; break; } case "sc": { tableName = "stage_sc"; break; } default: return("error"); } oldYear = "2009"; oldMonth = "01"; oldDay = "01"; oldNO = ""; //原ID号 oldNum = "000"; //原序号 oldEditNum = "000"; //原版本号 newNO = type; //从前缀开始拼ID号 newYear = System.DateTime.Now.Year; newMonth = System.DateTime.Now.Month; newDay = System.DateTime.Now.Day; if (newYear.ToString().Length != 4) { return("error"); } if (existID.Trim() == "") { //取最近添加的一条记录 sqlText = "select top 1 id from " + tableName + " order by substring(id,3,14) desc"; SqlDataReader dr = DBCallCommon.GetDRUsingSqlText(sqlText); if (dr.Read()) { oldNO = dr["id"].ToString(); } dr.Close(); } else { oldNO = existID; } if (oldNO != "")//不是增加第一条记录时 { oldYear = oldNO.Substring(2, 4); oldMonth = oldNO.Substring(6, 2); oldDay = oldNO.Substring(8, 2); oldNum = oldNO.Substring(10, 3); oldEditNum = oldNO.Substring(13, 3); } //生成新序号,版本号 if (existID.Trim() != "")//仅生成新版本 { newNO += oldNO.Substring(2, 8); newNum = oldNum; newEditNum = NumToString(Convert.ToInt32(oldEditNum) + 1, 3); } else//生成新ID号 { //同一天增加 if (Convert.ToInt32(oldYear) == newYear && Convert.ToInt32(oldMonth) == newMonth && Convert.ToInt32(oldDay) == newDay) { newNO += oldNO.Substring(2, 8); newNum = NumToString(Convert.ToInt32(oldNum) + 1, 3); } else { newNO += newYear.ToString() + NumToString(newMonth, 2) + NumToString(newDay, 2); newNum = "001"; } newEditNum = "000"; } newNO += newNum + newEditNum; return(newNO); }