|
|
- using System;
- using System.Data;
- using System.Text;
- using System.Data.SqlClient;
-
- namespace Basic.DAL
- {
- /// <summary>
- /// ���ݷ��ʲ�address
- /// </summary>
- public partial class address
- {
- /// <summary>
- /// ����һ������
- /// </summary>
- public int Add(Basic.Model.address model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("insert into tb_address(");
- strSql.Append("user_id,name,sheng,shi,xian,ssx,xaddress,mobile,phone,email,status,dname,dxaddress,dmobile)");
- strSql.Append(" values (");
- strSql.Append("@user_id,@name,@sheng,@shi,@xian,@ssx,@xaddress,@mobile,@phone,@email,@status,@dname,@dxaddress,@dmobile)");
- strSql.Append(";select @@IDENTITY");
-
- SqlParameter[] parameters = {
- new SqlParameter("@user_id", SqlDbType.Int,10),
- new SqlParameter("@name", SqlDbType.NVarChar,50),
- new SqlParameter("@sheng", SqlDbType.NVarChar,50),
- new SqlParameter("@shi", SqlDbType.NVarChar,50),
- new SqlParameter("@xian", SqlDbType.NVarChar,50),
- new SqlParameter("@ssx", SqlDbType.NVarChar,255),
- new SqlParameter("@xaddress", SqlDbType.NVarChar,255),
- new SqlParameter("@mobile", SqlDbType.NVarChar,50),
- new SqlParameter("@phone", SqlDbType.NVarChar,50),
- new SqlParameter("@email", SqlDbType.NVarChar,100),
- new SqlParameter("@status", SqlDbType.Int,10),
- new SqlParameter("@dname", SqlDbType.NVarChar,50),
- new SqlParameter("@dxaddress", SqlDbType.NVarChar,255),
- new SqlParameter("@dmobile", SqlDbType.NVarChar,50)};
- parameters[0].Value = model.user_id;
- parameters[1].Value = model.name;
- parameters[2].Value = model.sheng;
- parameters[3].Value = model.shi;
- parameters[4].Value = model.xian;
- parameters[5].Value = model.ssx;
- parameters[6].Value = model.xaddress;
- parameters[7].Value = model.mobile;
- parameters[8].Value = model.phone;
- parameters[9].Value = model.email;
- parameters[10].Value = model.status;
- parameters[11].Value = model.dname;
- parameters[12].Value = model.dxaddress;
- parameters[13].Value = model.dmobile;
-
-
- object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
- if (obj == null)
- {
- return 0;
- }
- else
- {
- return Convert.ToInt32(obj);
- }
- }
-
- /// <summary>
- /// ����һ������
- /// </summary>
- public bool Update(Basic.Model.address model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("update tb_address set ");
- strSql.Append("user_id=@user_id,");
- strSql.Append("name=@name,");
- strSql.Append("sheng=@sheng,");
- strSql.Append("shi=@shi,");
- strSql.Append("xian=@xian,");
- strSql.Append("ssx=@ssx,");
- strSql.Append("xaddress=@xaddress,");
- strSql.Append("mobile=@mobile,");
- strSql.Append("phone=@phone,");
- strSql.Append("email=@email,");
- strSql.Append("status=@status,");
- strSql.Append("dname=@dname,");
- strSql.Append("dxaddress=@dxaddress,");
- strSql.Append("dmobile=@dmobile");
- strSql.Append(" where id=@id");
- SqlParameter[] parameters = {
- new SqlParameter("@user_id", SqlDbType.Int,10),
- new SqlParameter("@name", SqlDbType.NVarChar,50),
- new SqlParameter("@sheng", SqlDbType.NVarChar,50),
- new SqlParameter("@shi", SqlDbType.NVarChar,50),
- new SqlParameter("@xian", SqlDbType.NVarChar,50),
- new SqlParameter("@ssx", SqlDbType.NVarChar,255),
- new SqlParameter("@xaddress", SqlDbType.NVarChar,255),
- new SqlParameter("@mobile", SqlDbType.NVarChar,50),
- new SqlParameter("@phone", SqlDbType.NVarChar,50),
- new SqlParameter("@email", SqlDbType.NVarChar,100),
- new SqlParameter("@status", SqlDbType.Int,10),
- new SqlParameter("@dname", SqlDbType.NVarChar,50),
- new SqlParameter("@dxaddress", SqlDbType.NVarChar,255),
- new SqlParameter("@dmobile", SqlDbType.NVarChar,50),
- new SqlParameter("@id", SqlDbType.Int,4)};
- parameters[0].Value = model.user_id;
- parameters[1].Value = model.name;
- parameters[2].Value = model.sheng;
- parameters[3].Value = model.shi;
- parameters[4].Value = model.xian;
- parameters[5].Value = model.ssx;
- parameters[6].Value = model.xaddress;
- parameters[7].Value = model.mobile;
- parameters[8].Value = model.phone;
- parameters[9].Value = model.email;
- parameters[10].Value = model.status;
- parameters[11].Value = model.dname;
- parameters[12].Value = model.dxaddress;
- parameters[13].Value = model.dmobile;
- parameters[14].Value = model.id;
- int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
- if (rows > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
- /// <summary>
- /// ɾ��һ������
- /// </summary>
- public bool Delete(int id)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("delete from tb_address");
- strSql.Append(" where id=@id");
- SqlParameter[] parameters = {
- new SqlParameter("@id", SqlDbType.Int,4)};
- parameters[0].Value = id;
- int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
- if (rows > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
- /// <summary>
- /// �õ�һ������ʵ��
- /// </summary>
- public Basic.Model.address GetModel(int id)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select top 1 id,user_id,name,sheng,shi,xian,ssx,xaddress,mobile,phone,email,status,dname,dxaddress,dmobile from tb_address");
- strSql.Append(" where id=@id");
- SqlParameter[] parameters = {
- new SqlParameter("@id", SqlDbType.Int,4)};
- parameters[0].Value = id;
- Basic.Model.address model = new Basic.Model.address();
- DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
- if (ds.Tables[0].Rows.Count > 0)
- {
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
- {
- model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["user_id"].ToString()))
- {
- model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["name"].ToString()))
- {
- model.name = ds.Tables[0].Rows[0]["name"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["sheng"].ToString()))
- {
- model.sheng = ds.Tables[0].Rows[0]["sheng"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["shi"].ToString()))
- {
- model.shi = ds.Tables[0].Rows[0]["shi"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["xian"].ToString()))
- {
- model.xian = ds.Tables[0].Rows[0]["xian"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["ssx"].ToString()))
- {
- model.ssx = ds.Tables[0].Rows[0]["ssx"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["xaddress"].ToString()))
- {
- model.xaddress = ds.Tables[0].Rows[0]["xaddress"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["mobile"].ToString()))
- {
- model.mobile = ds.Tables[0].Rows[0]["mobile"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["phone"].ToString()))
- {
- model.phone = ds.Tables[0].Rows[0]["phone"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["email"].ToString()))
- {
- model.email = ds.Tables[0].Rows[0]["email"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["status"].ToString()))
- {
- model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
- }
- //������
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dname"].ToString()))
- {
- model.dname = ds.Tables[0].Rows[0]["dname"].ToString();
- }
-
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dxaddress"].ToString()))
- {
- model.dxaddress = ds.Tables[0].Rows[0]["dxaddress"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dmobile"].ToString()))
- {
- model.dmobile = ds.Tables[0].Rows[0]["dmobile"].ToString();
- }
-
- return model;
- }
- else
- {
- return null;
- }
- }
-
- /// <summary>
- /// �õ�һ������ʵ��
- /// </summary>
- public Basic.Model.address GetModel(string strUserName)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select top 1 id,user_id,name,sheng,shi,xian,ssx,xaddress,mobile,phone,email,status,dname,dxaddress,dmobile from tb_address");
- strSql.Append(" where user_id=(select top 1 id from tb_user where name=@name) and status=1 order by id desc");
- SqlParameter[] parameters = {
- new SqlParameter("@name", SqlDbType.VarChar,50)};
- parameters[0].Value = strUserName;
- Basic.Model.address model = new Basic.Model.address();
- DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
- if (ds.Tables[0].Rows.Count > 0)
- {
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
- {
- model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["user_id"].ToString()))
- {
- model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["name"].ToString()))
- {
- model.name = ds.Tables[0].Rows[0]["name"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["sheng"].ToString()))
- {
- model.sheng = ds.Tables[0].Rows[0]["sheng"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["shi"].ToString()))
- {
- model.shi = ds.Tables[0].Rows[0]["shi"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["xian"].ToString()))
- {
- model.xian = ds.Tables[0].Rows[0]["xian"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["ssx"].ToString()))
- {
- model.ssx = ds.Tables[0].Rows[0]["ssx"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["xaddress"].ToString()))
- {
- model.xaddress = ds.Tables[0].Rows[0]["xaddress"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["mobile"].ToString()))
- {
- model.mobile = ds.Tables[0].Rows[0]["mobile"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["phone"].ToString()))
- {
- model.phone = ds.Tables[0].Rows[0]["phone"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["email"].ToString()))
- {
- model.email = ds.Tables[0].Rows[0]["email"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["status"].ToString()))
- {
- model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
- }
- //������
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dname"].ToString()))
- {
- model.dname = ds.Tables[0].Rows[0]["dname"].ToString();
- }
-
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dxaddress"].ToString()))
- {
- model.dxaddress = ds.Tables[0].Rows[0]["dxaddress"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dmobile"].ToString()))
- {
- model.dmobile = ds.Tables[0].Rows[0]["dmobile"].ToString();
- }
-
- return model;
- }
- else
- {
- return null;
- }
- }
- /// <summary>
- /// �õ�һ������ʵ��
- /// </summary>
- public Basic.Model.address GetModelByUserId(int user_id)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select top 1 id,user_id,name,sheng,shi,xian,ssx,xaddress,mobile,phone,email,status,dname,dxaddress,dmobile from tb_address");
- strSql.Append(" where user_id=@user_id order by status desc,id desc");
- SqlParameter[] parameters = {
- new SqlParameter("@user_id", SqlDbType.Int,4)};
- parameters[0].Value = user_id;
- Basic.Model.address model = new Basic.Model.address();
- DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
- if (ds.Tables[0].Rows.Count > 0)
- {
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
- {
- model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["user_id"].ToString()))
- {
- model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["name"].ToString()))
- {
- model.name = ds.Tables[0].Rows[0]["name"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["sheng"].ToString()))
- {
- model.sheng = ds.Tables[0].Rows[0]["sheng"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["shi"].ToString()))
- {
- model.shi = ds.Tables[0].Rows[0]["shi"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["xian"].ToString()))
- {
- model.xian = ds.Tables[0].Rows[0]["xian"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["ssx"].ToString()))
- {
- model.ssx = ds.Tables[0].Rows[0]["ssx"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["xaddress"].ToString()))
- {
- model.xaddress = ds.Tables[0].Rows[0]["xaddress"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["mobile"].ToString()))
- {
- model.mobile = ds.Tables[0].Rows[0]["mobile"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["phone"].ToString()))
- {
- model.phone = ds.Tables[0].Rows[0]["phone"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["email"].ToString()))
- {
- model.email = ds.Tables[0].Rows[0]["email"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["status"].ToString()))
- {
- model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
- }
- //������
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dname"].ToString()))
- {
- model.dname = ds.Tables[0].Rows[0]["dname"].ToString();
- }
-
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dxaddress"].ToString()))
- {
- model.dxaddress = ds.Tables[0].Rows[0]["dxaddress"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dmobile"].ToString()))
- {
- model.dmobile = ds.Tables[0].Rows[0]["dmobile"].ToString();
- }
-
- return model;
- }
- else
- {
- return null;
- }
- }
-
- /// <summary>
- /// ����ǰ��������
- /// </summary>
- public DataSet GetList(int Top, string strWhere, string filedOrder)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select ");
- if (Top > 0)
- {
- strSql.Append(" top " + Top.ToString());
- }
- strSql.Append("id,user_id,name,sheng,shi,xian,ssx,xaddress,mobile,phone,email,status,dname,dxaddress,dmobile");
- strSql.Append(" from tb_address");
- if (strWhere.Trim() != "")
- {
- strSql.Append(" where " + strWhere);
- }
- strSql.Append(" order by " + filedOrder);
- return DbHelperSQL.Query(strSql.ToString());
- }
-
- /// <summary>
- /// �Ƿ����ڸü�¼
- /// </summary>
- public bool Exists(int id)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select count(1) from tb_address");
- strSql.Append(" where id=@id");
- SqlParameter[] parameters = {
- new SqlParameter("@id", SqlDbType.Int,4)};
- parameters[0].Value = id;
-
- return DbHelperSQL.Exists(strSql.ToString(), parameters);
- }
- /// <summary>
- /// ��һ������
- /// </summary>
- public void UpdateField(int id, string strValue)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("update tb_address set " + strValue);
- strSql.Append(" where id=" + id);
- DbHelperSQL.ExecuteSql(strSql.ToString());
- }
-
- //�����ӵ�======================================================================================================================================
-
- /// <summary>
- /// ��Ĭ�ϵ�ַ
- /// </summary>
- public void UpdateStatus(int id, int _UserID)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("update tb_address set status=0");
- strSql.Append(" where user_id=" + _UserID);
- strSql.Append(" update tb_address set status=1");
- strSql.Append(" where id=" + id);
- DbHelperSQL.ExecuteSql(strSql.ToString());
- }
- /// <summary>
- /// �õ�һ������ʵ��
- /// </summary>
- public Basic.Model.address GetModel(int id, int user_id)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select top 1 id,user_id,name,sheng,shi,xian,ssx,xaddress,mobile,phone,email,status,dname,dxaddress,dmobile from tb_address");
- strSql.Append(" where id=@id and user_id=@user_id");
- SqlParameter[] parameters = {
- new SqlParameter("@id", SqlDbType.Int,4),
- new SqlParameter("@user_id", SqlDbType.Int,4)};
- parameters[0].Value = id;
- parameters[1].Value = user_id;
- Basic.Model.address model = new Basic.Model.address();
- DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
- if (ds.Tables[0].Rows.Count > 0)
- {
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
- {
- model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["user_id"].ToString()))
- {
- model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["name"].ToString()))
- {
- model.name = ds.Tables[0].Rows[0]["name"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["sheng"].ToString()))
- {
- model.sheng = ds.Tables[0].Rows[0]["sheng"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["shi"].ToString()))
- {
- model.shi = ds.Tables[0].Rows[0]["shi"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["xian"].ToString()))
- {
- model.xian = ds.Tables[0].Rows[0]["xian"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["ssx"].ToString()))
- {
- model.ssx = ds.Tables[0].Rows[0]["ssx"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["xaddress"].ToString()))
- {
- model.xaddress = ds.Tables[0].Rows[0]["xaddress"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["mobile"].ToString()))
- {
- model.mobile = ds.Tables[0].Rows[0]["mobile"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["phone"].ToString()))
- {
- model.phone = ds.Tables[0].Rows[0]["phone"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["email"].ToString()))
- {
- model.email = ds.Tables[0].Rows[0]["email"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["status"].ToString()))
- {
- model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
- }
- //������
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dname"].ToString()))
- {
- model.dname = ds.Tables[0].Rows[0]["dname"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dxaddress"].ToString()))
- {
- model.dxaddress = ds.Tables[0].Rows[0]["dxaddress"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dmobile"].ToString()))
- {
- model.dmobile = ds.Tables[0].Rows[0]["dmobile"].ToString();
- }
- return model;
- }
- else
- {
- return null;
- }
- }
- /// <summary>
- /// �õ�һ������ʵ��
- /// </summary>
- public Basic.Model.address GetModel(int user_id, string status)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select top 1 id,user_id,name,sheng,shi,xian,ssx,xaddress,mobile,phone,email,status,dname,dxaddress,dmobile from tb_address");
- strSql.Append(" where status=@status and user_id=@user_id");
- SqlParameter[] parameters = {
- new SqlParameter("@status", SqlDbType.Int,4),
- new SqlParameter("@user_id", SqlDbType.Int,4)};
- parameters[0].Value = status;
- parameters[1].Value = user_id;
- Basic.Model.address model = new Basic.Model.address();
- DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
- if (ds.Tables[0].Rows.Count > 0)
- {
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
- {
- model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["user_id"].ToString()))
- {
- model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["name"].ToString()))
- {
- model.name = ds.Tables[0].Rows[0]["name"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["sheng"].ToString()))
- {
- model.sheng = ds.Tables[0].Rows[0]["sheng"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["shi"].ToString()))
- {
- model.shi = ds.Tables[0].Rows[0]["shi"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["xian"].ToString()))
- {
- model.xian = ds.Tables[0].Rows[0]["xian"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["ssx"].ToString()))
- {
- model.ssx = ds.Tables[0].Rows[0]["ssx"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["xaddress"].ToString()))
- {
- model.xaddress = ds.Tables[0].Rows[0]["xaddress"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["mobile"].ToString()))
- {
- model.mobile = ds.Tables[0].Rows[0]["mobile"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["phone"].ToString()))
- {
- model.phone = ds.Tables[0].Rows[0]["phone"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["email"].ToString()))
- {
- model.email = ds.Tables[0].Rows[0]["email"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["status"].ToString()))
- {
- model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
- }
- //������
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dname"].ToString()))
- {
- model.dname = ds.Tables[0].Rows[0]["dname"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dxaddress"].ToString()))
- {
- model.dxaddress = ds.Tables[0].Rows[0]["dxaddress"].ToString();
- }
- if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dmobile"].ToString()))
- {
- model.dmobile = ds.Tables[0].Rows[0]["dmobile"].ToString();
- }
- return model;
- }
- else
- {
- return null;
- }
- }
- /// <summary>
- /// ɾ��һ������
- /// </summary>
- public bool Delete(int id, int user_id)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("delete from tb_address");
- strSql.Append(" where id=@id and user_id=@user_id");
- SqlParameter[] parameters = {
- new SqlParameter("@id", SqlDbType.Int,4),
- new SqlParameter("@user_id", SqlDbType.Int,4)};
- parameters[0].Value = id;
- parameters[1].Value = user_id;
- int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
- if (rows > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- }
-
|