Exemplo n.º 1
0
        public int MyDatabaseMethod(string strLoginID, string strUserName, string strUserPwd, string strUserSex, string strBirthday, string strDeptID, string strJobID, string strTelephone, string strCertType, string strCertNum, string strLoginIP, int intUserType, int intUserState, int intJudgeUser, int intJudgeTestType, int intRoleMenu, int intCreateUserID, DateTime dtmCreateDate, byte[] imgbin)
        {
            string         strConn = "";
            string         strSql  = "";
            PublicFunction ObjFun  = new PublicFunction();

            strConn = ConfigurationSettings.AppSettings["strConn"];
            SqlConnection ObjConn = new SqlConnection(strConn);

            strSql = "Insert into UserInfo(LoginID,UserName,UserPwd,UserSex,Birthday,DeptID,JobID,Telephone,CertType,CertNum,LoginIP,UserType,UserState,JudgeUser,JudgeTestType,RoleMenu,CreateUserID,CreateDate,UserPhoto) Values (@TmpLoginID,@TmpUserName,@TmpUserPwd,@TmpUserSex,@TmpBirthday,@TmpDeptID,@TmpJobID,@TmpTelephone,@TmpCertType,@TmpCertNum,@TmpLoginIP,@TmpUserType,@TmpUserState,@TmpJudgeUser,@TmpJudgeTestType,@TmpRoleMenu,@TmpCreateUserID,@TmpCreateDate,@TmpUserPhoto)";
            SqlCommand ObjCmd = new SqlCommand(strSql, ObjConn);
            //帐号
            SqlParameter ParamLoginID = new SqlParameter("@TmpLoginID", SqlDbType.VarChar, 20);

            ParamLoginID.Value = strLoginID;
            ObjCmd.Parameters.Add(ParamLoginID);
            //姓名
            SqlParameter ParamUserName = new SqlParameter("@TmpUserName", SqlDbType.VarChar, 20);

            ParamUserName.Value = strUserName;
            ObjCmd.Parameters.Add(ParamUserName);
            //密码
            SqlParameter ParamUserPwd = new SqlParameter("@TmpUserPwd", SqlDbType.VarChar, 20);

            ParamUserPwd.Value = strUserPwd;
            ObjCmd.Parameters.Add(ParamUserPwd);
            //性别
            SqlParameter ParamUserSex = new SqlParameter("@TmpUserSex", SqlDbType.VarChar, 2);

            ParamUserSex.Value = strUserSex;
            ObjCmd.Parameters.Add(ParamUserSex);
            //出生年月
            if (strBirthday != "")
            {
                SqlParameter ParamBirthday = new SqlParameter("@TmpBirthday", SqlDbType.DateTime);
                ParamBirthday.Value = Convert.ToDateTime(strBirthday);
                ObjCmd.Parameters.Add(ParamBirthday);
            }
            else
            {
                SqlParameter ParamBirthday = new SqlParameter("@TmpBirthday", SqlDbType.DateTime);
                ParamBirthday.Value = System.DBNull.Value;
                ObjCmd.Parameters.Add(ParamBirthday);
            }
            //所属部门
            SqlParameter ParamDeptID = new SqlParameter("@TmpDeptID", SqlDbType.Int);

            ParamDeptID.Value = Convert.ToInt32(strDeptID);
            ObjCmd.Parameters.Add(ParamDeptID);
            //职务
            SqlParameter ParamJobID = new SqlParameter("@TmpJobID", SqlDbType.Int);

            ParamJobID.Value = Convert.ToInt32(strJobID);
            ObjCmd.Parameters.Add(ParamJobID);
            //电话
            SqlParameter ParamTelephone = new SqlParameter("@TmpTelephone", SqlDbType.VarChar, 20);

            ParamTelephone.Value = strTelephone;
            ObjCmd.Parameters.Add(ParamTelephone);
            //证件类型
            SqlParameter ParamCertType = new SqlParameter("@TmpCertType", SqlDbType.VarChar, 20);

            ParamCertType.Value = ObjFun.CheckString(strCertType);
            ObjCmd.Parameters.Add(ParamCertType);
            //证件号码
            SqlParameter ParamCertNum = new SqlParameter("@TmpCertNum", SqlDbType.VarChar, 20);

            ParamCertNum.Value = strCertNum;
            ObjCmd.Parameters.Add(ParamCertNum);
            //登录IP
            SqlParameter ParamLoginIP = new SqlParameter("@TmpLoginIP", SqlDbType.VarChar, 20);

            ParamLoginIP.Value = strLoginIP;
            ObjCmd.Parameters.Add(ParamLoginIP);
            //类型
            SqlParameter ParamUserType = new SqlParameter("@TmpUserType", SqlDbType.Int);

            ParamUserType.Value = Convert.ToInt32(intUserType);
            ObjCmd.Parameters.Add(ParamUserType);
            //状态
            SqlParameter ParamUserState = new SqlParameter("@TmpUserState", SqlDbType.Int);

            ParamUserState.Value = Convert.ToInt32(intUserState);
            ObjCmd.Parameters.Add(ParamUserState);
            //评卷帐号
            SqlParameter ParamJudgeUser = new SqlParameter("@TmpJudgeUser", SqlDbType.Int);

            ParamJudgeUser.Value = Convert.ToInt32(intJudgeUser);
            ObjCmd.Parameters.Add(ParamJudgeUser);
            //评卷题型
            SqlParameter ParamJudgeTestType = new SqlParameter("@TmpJudgeTestType", SqlDbType.Int);

            ParamJudgeTestType.Value = Convert.ToInt32(intJudgeTestType);
            ObjCmd.Parameters.Add(ParamJudgeTestType);
            //角色菜单
            SqlParameter ParamRoleMenu = new SqlParameter("@TmpRoleMenu", SqlDbType.Int);

            ParamRoleMenu.Value = Convert.ToInt32(intRoleMenu);
            ObjCmd.Parameters.Add(ParamRoleMenu);
            //创建帐号
            SqlParameter ParamCreateUserID = new SqlParameter("@TmpCreateUserID", SqlDbType.Int);

            ParamCreateUserID.Value = Convert.ToInt32(intCreateUserID);
            ObjCmd.Parameters.Add(ParamCreateUserID);
            //创建时间
            SqlParameter ParamCreateDate = new SqlParameter("@TmpCreateDate", SqlDbType.DateTime);

            ParamCreateDate.Value = dtmCreateDate;
            ObjCmd.Parameters.Add(ParamCreateDate);

            if (imgbin.Length > 0)
            {
                SqlParameter ParamUserPhoto = new SqlParameter("@TmpUserPhoto", SqlDbType.Image);
                ParamUserPhoto.Value = imgbin;
                ObjCmd.Parameters.Add(ParamUserPhoto);
            }
            else
            {
                SqlParameter ParamUserPhoto = new SqlParameter("@TmpUserPhoto", SqlDbType.Image);
                ParamUserPhoto.Value = System.DBNull.Value;
                ObjCmd.Parameters.Add(ParamUserPhoto);
            }

            ObjConn.Open();
            int numRowsAffected = ObjCmd.ExecuteNonQuery();

            ObjConn.Close();
            ObjConn.Dispose();
            return(numRowsAffected);
        }
Exemplo n.º 2
0
        public int MyDatabaseMethod(string strLoginID,string strUserName,string strUserPwd,string strUserSex,string strBirthday,string strDeptID,string strJobID,string strTelephone,string strCertType,string strCertNum,string strLoginIP,int intUserType,int intUserState,int intJudgeUser,int intJudgeTestType,int intRoleMenu,int intCreateUserID,DateTime dtmCreateDate,byte[] imgbin)
        {
            string strConn="";
            string strSql="";
            PublicFunction ObjFun=new PublicFunction();
            strConn=ConfigurationSettings.AppSettings["strConn"];
            SqlConnection ObjConn = new SqlConnection(strConn);
            strSql="Insert into UserInfo(LoginID,UserName,UserPwd,UserSex,Birthday,DeptID,JobID,Telephone,CertType,CertNum,LoginIP,UserType,UserState,JudgeUser,JudgeTestType,RoleMenu,CreateUserID,CreateDate,UserPhoto) Values (@TmpLoginID,@TmpUserName,@TmpUserPwd,@TmpUserSex,@TmpBirthday,@TmpDeptID,@TmpJobID,@TmpTelephone,@TmpCertType,@TmpCertNum,@TmpLoginIP,@TmpUserType,@TmpUserState,@TmpJudgeUser,@TmpJudgeTestType,@TmpRoleMenu,@TmpCreateUserID,@TmpCreateDate,@TmpUserPhoto)";
            SqlCommand ObjCmd=new SqlCommand(strSql,ObjConn);
            //�ʺ�
            SqlParameter ParamLoginID=new SqlParameter("@TmpLoginID",SqlDbType.VarChar,20);
            ParamLoginID.Value = strLoginID;
            ObjCmd.Parameters.Add(ParamLoginID);
            //����
            SqlParameter ParamUserName=new SqlParameter("@TmpUserName",SqlDbType.VarChar,20);
            ParamUserName.Value = strUserName;
            ObjCmd.Parameters.Add(ParamUserName);
            //����
            SqlParameter ParamUserPwd=new SqlParameter("@TmpUserPwd",SqlDbType.VarChar,20);
            ParamUserPwd.Value = strUserPwd;
            ObjCmd.Parameters.Add(ParamUserPwd);
            //�Ա�
            SqlParameter ParamUserSex=new SqlParameter("@TmpUserSex",SqlDbType.VarChar,2);
            ParamUserSex.Value = strUserSex;
            ObjCmd.Parameters.Add(ParamUserSex);
            //��������
            if (strBirthday!="")
            {
                SqlParameter ParamBirthday=new SqlParameter("@TmpBirthday",SqlDbType.DateTime);
                ParamBirthday.Value = Convert.ToDateTime(strBirthday);
                ObjCmd.Parameters.Add(ParamBirthday);
            }
            else
            {
                SqlParameter ParamBirthday=new SqlParameter("@TmpBirthday",SqlDbType.DateTime);
                ParamBirthday.Value = System.DBNull.Value;
                ObjCmd.Parameters.Add(ParamBirthday);
            }
            //�������
            SqlParameter ParamDeptID=new SqlParameter("@TmpDeptID",SqlDbType.Int);
            ParamDeptID.Value = Convert.ToInt32(strDeptID);
            ObjCmd.Parameters.Add(ParamDeptID);
            //ְ��
            SqlParameter ParamJobID=new SqlParameter("@TmpJobID",SqlDbType.Int);
            ParamJobID.Value = Convert.ToInt32(strJobID);
            ObjCmd.Parameters.Add(ParamJobID);
            //�绰
            SqlParameter ParamTelephone=new SqlParameter("@TmpTelephone",SqlDbType.VarChar,20);
            ParamTelephone.Value = strTelephone;
            ObjCmd.Parameters.Add(ParamTelephone);
            //֤������
            SqlParameter ParamCertType=new SqlParameter("@TmpCertType",SqlDbType.VarChar,20);
            ParamCertType.Value = ObjFun.CheckString(strCertType);
            ObjCmd.Parameters.Add(ParamCertType);
            //֤������
            SqlParameter ParamCertNum=new SqlParameter("@TmpCertNum",SqlDbType.VarChar,20);
            ParamCertNum.Value = strCertNum;
            ObjCmd.Parameters.Add(ParamCertNum);
            //��¼IP
            SqlParameter ParamLoginIP=new SqlParameter("@TmpLoginIP",SqlDbType.VarChar,20);
            ParamLoginIP.Value = strLoginIP;
            ObjCmd.Parameters.Add(ParamLoginIP);
            //����
            SqlParameter ParamUserType=new SqlParameter("@TmpUserType",SqlDbType.Int);
            ParamUserType.Value = Convert.ToInt32(intUserType);
            ObjCmd.Parameters.Add(ParamUserType);
            //״̬
            SqlParameter ParamUserState=new SqlParameter("@TmpUserState",SqlDbType.Int);
            ParamUserState.Value = Convert.ToInt32(intUserState);
            ObjCmd.Parameters.Add(ParamUserState);
            //�����ʺ�
            SqlParameter ParamJudgeUser=new SqlParameter("@TmpJudgeUser",SqlDbType.Int);
            ParamJudgeUser.Value = Convert.ToInt32(intJudgeUser);
            ObjCmd.Parameters.Add(ParamJudgeUser);
            //��������
            SqlParameter ParamJudgeTestType=new SqlParameter("@TmpJudgeTestType",SqlDbType.Int);
            ParamJudgeTestType.Value = Convert.ToInt32(intJudgeTestType);
            ObjCmd.Parameters.Add(ParamJudgeTestType);
            //��ɫ�˵�
            SqlParameter ParamRoleMenu=new SqlParameter("@TmpRoleMenu",SqlDbType.Int);
            ParamRoleMenu.Value = Convert.ToInt32(intRoleMenu);
            ObjCmd.Parameters.Add(ParamRoleMenu);
            //�����ʺ�
            SqlParameter ParamCreateUserID=new SqlParameter("@TmpCreateUserID",SqlDbType.Int);
            ParamCreateUserID.Value = Convert.ToInt32(intCreateUserID);
            ObjCmd.Parameters.Add(ParamCreateUserID);
            //����ʱ��
            SqlParameter ParamCreateDate=new SqlParameter("@TmpCreateDate",SqlDbType.DateTime);
            ParamCreateDate.Value = dtmCreateDate;
            ObjCmd.Parameters.Add(ParamCreateDate);

            if (imgbin.Length>0)
            {
                SqlParameter ParamUserPhoto=new SqlParameter("@TmpUserPhoto",SqlDbType.Image);
                ParamUserPhoto.Value = imgbin;
                ObjCmd.Parameters.Add(ParamUserPhoto);
            }
            else
            {
                SqlParameter ParamUserPhoto=new SqlParameter("@TmpUserPhoto",SqlDbType.Image);
                ParamUserPhoto.Value = System.DBNull.Value;
                ObjCmd.Parameters.Add(ParamUserPhoto);
            }

            ObjConn.Open();
            int numRowsAffected=ObjCmd.ExecuteNonQuery();
            ObjConn.Close();
            ObjConn.Dispose();
            return numRowsAffected;
        }