/// <summary> /// 得到一个实体对象 /// </summary> /// <param name="Id"></param> /// <returns></returns> public static Model.RTKUserInfo GetModel(string UserName) { string strSql = "select * from RTKUserInfo where UserName = '******'"; Model.RTKUserInfo model = new Model.RTKUserInfo(); DataSet ds = DBHelperSQL.GetDataSet(strSql, connectionString); model.UserName = UserName; if (ds.Tables[0].Rows.Count > 0) { model.ID = Convert.ToInt32(ds.Tables[0].Rows[0]["ID"]); model.PassWord = Convert.ToString(ds.Tables[0].Rows[0]["PassWord"]); model.Contact = Convert.ToString(ds.Tables[0].Rows[0]["Contact"]); model.ContactPhone = Convert.ToString(ds.Tables[0].Rows[0]["ContactPhone"]); model.ContactEmail = Convert.ToString(ds.Tables[0].Rows[0]["ContactEmail"]); model.ContactQQ = Convert.ToString(ds.Tables[0].Rows[0]["ContactQQ"]); model.CORSCardNum = Convert.ToString(ds.Tables[0].Rows[0]["CORSCardNum"]); model.ReceiverNum = Convert.ToString(ds.Tables[0].Rows[0]["ReceiverNum"]); model.Company = Convert.ToString(ds.Tables[0].Rows[0]["Company"]); model.RegTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["RegTime"]); model.UserType = Convert.ToInt32(ds.Tables[0].Rows[0]["UserType"]); model.OrderNumber = Convert.ToString(ds.Tables[0].Rows[0]["OrderNumber"]); model.BelongArea = Convert.ToString(ds.Tables[0].Rows[0]["BelongArea"]); model.RegisterUserName = Convert.ToString(ds.Tables[0].Rows[0]["RegisterUserName"]); return(model); } else { return(null); } }
/// <summary> /// 更新一条数据,根据ID /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool Update(Model.RTKUserInfo model) { string strSql = "update RTKUserInfo set UserName=@UserName, PassWord=@PassWord, Contact=@Contact, ContactPhone=@ContactPhone, ContactEmail=@ContactEmail, ContactQQ=@ContactQQ, CORSCardNum=@CORSCardNum, ReceiverNum=@ReceiverNum, Company=@Company, RegTime=@RegTime, UserType=@UserType,OrderNumber=@OrderNumber,BelongArea=@BelongArea,RegisterUserName=@RegisterUserName where ID = " + model.ID.ToString(); SqlParameter UserName = new SqlParameter("UserName", SqlDbType.NVarChar); UserName.Value = model.UserName; SqlParameter PassWord = new SqlParameter("PassWord", SqlDbType.NVarChar); PassWord.Value = model.PassWord; SqlParameter Contact = new SqlParameter("Contact", SqlDbType.NVarChar); Contact.Value = model.Contact; SqlParameter ContactPhone = new SqlParameter("ContactPhone", SqlDbType.NVarChar); ContactPhone.Value = model.ContactPhone; SqlParameter ContactEmail = new SqlParameter("ContactEmail", SqlDbType.NVarChar); ContactEmail.Value = model.ContactEmail; SqlParameter ContactQQ = new SqlParameter("ContactQQ", SqlDbType.NVarChar); ContactQQ.Value = model.ContactQQ; SqlParameter CORSCardNum = new SqlParameter("CORSCardNum", SqlDbType.NVarChar); CORSCardNum.Value = model.CORSCardNum; SqlParameter ReceiverNum = new SqlParameter("ReceiverNum", SqlDbType.NVarChar); ReceiverNum.Value = model.ReceiverNum; SqlParameter Company = new SqlParameter("Company", SqlDbType.NVarChar); Company.Value = model.Company; SqlParameter RegTime = new SqlParameter("RegTime", SqlDbType.DateTime); RegTime.Value = model.RegTime; SqlParameter UserType = new SqlParameter("UserType", SqlDbType.Int); UserType.Value = model.UserType; SqlParameter OrderNumber = new SqlParameter("OrderNumber", SqlDbType.NVarChar); OrderNumber.Value = model.OrderNumber; SqlParameter BelongArea = new SqlParameter("BelongArea", SqlDbType.NVarChar); BelongArea.Value = model.BelongArea; SqlParameter RegisterUserName = new SqlParameter("RegisterUserName", SqlDbType.NVarChar); RegisterUserName.Value = model.RegisterUserName; return(DBHelperSQL.GetNums(strSql, new SqlParameter[] { UserName, PassWord, Contact, ContactPhone, ContactEmail, ContactQQ, CORSCardNum, ReceiverNum, Company, RegTime, UserType, OrderNumber, BelongArea, RegisterUserName }, connectionString) == 1 ? true : false); }
/// <summary> /// 增加一个用户信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool Add(Model.RTKUserInfo model) { string strSql = "insert into RTKUserInfo( UserName, PassWord, Contact, ContactPhone, ContactEmail, ContactQQ, CORSCardNum, ReceiverNum, Company, RegTime, UserType,OrderNumber,BelongArea,RegisterUserName ) values( @UserName, @PassWord, @Contact, @ContactPhone, @ContactEmail, @ContactQQ, @CORSCardNum, @ReceiverNum, @Company, @RegTime, @UserType,@OrderNumber,@BelongArea,@RegisterUserName )"; SqlParameter UserName = new SqlParameter("UserName", SqlDbType.NVarChar); UserName.Value = model.UserName; SqlParameter PassWord = new SqlParameter("PassWord", SqlDbType.NVarChar); PassWord.Value = model.PassWord; SqlParameter Contact = new SqlParameter("Contact", SqlDbType.NVarChar); Contact.Value = model.Contact; SqlParameter ContactPhone = new SqlParameter("ContactPhone", SqlDbType.NVarChar); ContactPhone.Value = model.ContactPhone; SqlParameter ContactEmail = new SqlParameter("ContactEmail", SqlDbType.NVarChar); ContactEmail.Value = model.ContactEmail; SqlParameter ContactQQ = new SqlParameter("ContactQQ", SqlDbType.NVarChar); ContactQQ.Value = model.ContactQQ; SqlParameter CORSCardNum = new SqlParameter("CORSCardNum", SqlDbType.NVarChar); CORSCardNum.Value = model.CORSCardNum; SqlParameter ReceiverNum = new SqlParameter("ReceiverNum", SqlDbType.NVarChar); ReceiverNum.Value = model.ReceiverNum; SqlParameter Company = new SqlParameter("Company", SqlDbType.NVarChar); Company.Value = model.Company; SqlParameter RegTime = new SqlParameter("RegTime", SqlDbType.DateTime); RegTime.Value = model.RegTime; SqlParameter UserType = new SqlParameter("UserType", SqlDbType.Int); UserType.Value = model.UserType; SqlParameter OrderNumber = new SqlParameter("OrderNumber", SqlDbType.NVarChar); OrderNumber.Value = model.OrderNumber; SqlParameter BelongArea = new SqlParameter("BelongArea", SqlDbType.NVarChar); BelongArea.Value = model.BelongArea; SqlParameter RegisterUserName = new SqlParameter("RegisterUserName", SqlDbType.NVarChar); RegisterUserName.Value = model.RegisterUserName; WebLogger.WriteErroLog(CORSCardNum.ToString()); return(DBHelperSQL.GetNums(strSql, new SqlParameter[] { UserName, PassWord, Contact, ContactPhone, ContactEmail, ContactQQ, CORSCardNum, ReceiverNum, Company, RegTime, UserType, OrderNumber, BelongArea, RegisterUserName }, connectionString) == 1 ? true : false); }