Example #1
0
        /// <summary>
        /// 用户修改密码
        /// </summary>
        /// <param name="p_strLoginName"></param>
        /// <param name="p_strNewPassword"></param>
        /// <returns></returns>
        public bool ChgPassword(string p_strLoginName, string p_strNewPassword)
        {
            Conn cn   = null;
            bool bRet = false;

            try
            {
                gs.util.DES des    = new gs.util.DES();
                string      strPwd = des.EncryptString(p_strNewPassword, gs.util.StringTool.getPubKey(), gs.util.StringTool.getMixKey());

                cn = new Conn();

                string strSql = "update eg_user set vcPass='******' where vcLoginName='" + p_strLoginName + "'";
                cn.Update(strSql);
                bRet = true;
            }
            catch (Exception ex)
            {
                gs.util.func.Write("ChgPassword is err" + ex.Message);
            }
            finally
            {
                cn.close();
            }
            return(bRet);
        }
Example #2
0
        /// <summary>
        /// 检查是否合法用户
        /// </summary>
        /// <param name="p_strUserName"></param>
        /// <param name="p_strPwd"></param>
        /// <returns></returns>
        public static bool IsValidUser(string p_strUserName, string p_strPwd)
        {
            bool bRet = false;
            Conn cn   = null;

            try
            {
                gs.util.DES des    = new gs.util.DES();
                string      strPwd = des.EncryptString(p_strPwd, gs.util.StringTool.getPubKey(), gs.util.StringTool.getMixKey());

                cn = new Conn();
                string  strSql = "select * from eg_user where vcLoginName='" + p_strUserName + "' and vcPass='******'";
                DataSet ds     = cn.GetDataSet(strSql);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    bRet = true;
                }
            }
            finally
            {
                cn.close();
            }
            return(bRet);
        }
Example #3
0
        /// <summary>
        /// 生成一个新的C客户
        /// </summary>
        /// <param name="p_strXml"></param>
        /// <returns></returns>
        public string NewCUser(string p_strXml)
        {
            string strRet = "";

            NewPara npGet           = new NewPara(p_strXml.Trim());
            string  strMerchId      = npGet.FindTextByPath("//eg/MerchId").Trim();
            string  strUserCode     = npGet.FindTextByPath("//eg/User").Trim();
            string  strUserTitle    = npGet.FindTextByPath("//eg/UserTitle").Trim();
            string  strUserPassWord = npGet.FindTextByPath("//eg/UserPassWord").Trim();

            string strSex      = npGet.FindTextByPath("//eg/Sex").Trim();
            string strBirthday = npGet.FindTextByPath("//eg/Birthday").Trim();
            string strCrosAdr  = npGet.FindTextByPath("//eg/CrosAdr").Trim();
            string strPostCode = npGet.FindTextByPath("//eg/PostCode").Trim();
            string strEmail    = npGet.FindTextByPath("//eg/Email").Trim();
            string strTel      = npGet.FindTextByPath("//eg/Tel").Trim();
            string strUserType = npGet.FindTextByPath("//eg/vcUserType").Trim();

            //NewPara npRet = new NewPara();
            //XmlDocument doc = npRet.getRoot();
            //npRet.AddPara("Flag","OverUserLimted");

            Conn cn = null;

            try
            {
                cn = new Conn();
                cn.beginTrans();

                //得到C客户设置信息
                DataSet dsMerch       = cn.GetDataSet("select * from eg_AgentCUser where numAgentId='" + strMerchId + "'");
                string  strCurAgentId = "";
                string  strUserClass  = "";
                string  strNewUserId  = "";
                if (dsMerch.Tables[0].Rows.Count > 0)
                {
                    strCurAgentId = dsMerch.Tables[0].Rows[0]["numCurAgentId"].ToString().Trim();
                    strUserClass  = dsMerch.Tables[0].Rows[0]["vcUserClass"].ToString().Trim();
                }

                //计算用户名是否合法
                JoinAgent ag              = new JoinAgent();
                bool      bCanAdd         = ag.getAgentOverUsercountLimt(cn, strCurAgentId);  //检测是否超过最大用户数量
                bool      bExistLoginName = isExistUser(cn, strUserCode);

                if (bExistLoginName)
                {                //如果用户名存在
                    strRet = "ReUserName";
                }
                else
                {
                    if (bCanAdd)
                    {
                        gs.util.DES des    = new gs.util.DES();
                        string      strPwd = des.EncryptString(strUserPassWord, gs.util.StringTool.getPubKey(), gs.util.StringTool.getMixKey());

                        strNewUserId = logic.mytool.util.getId(cn, "eg_user");
                        Top3 tp = new Top3(cn);

                        tp.AddRow("numUserId", "i", strNewUserId);
                        tp.AddRow("vcLoginName", "c", strUserCode);
                        tp.AddRow("vcPass", "c", strPwd);
                        tp.AddRow("vcUserTitle", "c", strUserTitle);
                        if (strSex != "")
                        {
                            tp.AddRow("vcSex", "c", "男");
                        }
                        else
                        {
                            tp.AddRow("vcSex", "c", strSex);
                        }
                        tp.AddRow("numRoleId", "i", "0");
                        tp.AddRow("numAgentId", "c", strCurAgentId);
                        tp.AddRow("vcTel", "c", strTel);
                        if (strBirthday != "")
                        {
                            tp.AddRow("vcBirthday", "c", strBirthday);
                        }
                        else
                        {
                            tp.AddRow("vcBirthday", "c", "2000-1-1");
                        }

                        tp.AddRow("vcCrosAdr", "c", strCrosAdr);
                        tp.AddRow("vcPostCode", "c", strPostCode);
                        tp.AddRow("vcEmail", "c", strEmail);
                        tp.AddRow("dtRegTime", "dt", System.DateTime.Now.ToLongTimeString());
                        tp.AddRow("dtLastAcsTime", "dt", System.DateTime.Now.ToLongTimeString());
                        tp.AddRow("numUserStat", "i", "0");
                        if (strUserType != "")
                        {
                            tp.AddRow("vcUserType", "c", strUserType);
                        }
                        else
                        {
                            tp.AddRow("vcUserType", "c", "c");
                        }

                        tp.AddRow("numVal", "d", "0");
                        tp.AddRow("numStat", "i", "0");

                        if (tp.AddNewRec("eg_user"))
                        {
                            string strClassSql = "insert into eg_userCm(numUserId,numCmId) values(" + strNewUserId + ",'" + strUserClass + "')";
                            cn.Update(strClassSql);
                            string strRightSql = "insert into eg_userModu(numUserId,numModuId) select " + strNewUserId + ",numModuId from eg_AgentCUserModus where numAgentId='" + strMerchId + "'";
                            cn.Update(strRightSql);

                            strRet = "AddSucc";
                        }
                        else
                        {
                            strRet = "AddFail";
                        }
                    }
                    else
                    {
                        strRet = "OverUserLimted";
                    }
                }
                cn.commit();
            }
            catch (Exception ex)
            {
                gs.util.func.Write("NewCUser is err" + ex.Message);
                cn.rollback();
            }
            finally
            {
                cn.close();
            }

            return(strRet);
        }