Exemplo n.º 1
0
 /// <summary>
 /// 构造实体对象
 /// </summary>
 /// <param name="dt"></param>
 /// <param name="rowindex"></param>
 /// <returns></returns>
 public Daiv_OA.Entity.ContactEntity ConvertModel(DataTable dt, int rowindex)
 {
     Daiv_OA.Entity.ContactEntity model = new Daiv_OA.Entity.ContactEntity();
     try
     {
         if (dt.Rows[rowindex]["Cid"].ToString() != "")
         {
             model.Cid = int.Parse(dt.Rows[rowindex]["Cid"].ToString());
         }
         if (dt.Rows[rowindex]["Sid"].ToString() != "")
         {
             model.Sid = int.Parse(dt.Rows[rowindex]["Sid"].ToString());
         }
         if (dt.Rows[rowindex]["Cblacklistflag"].ToString() != "")
         {
             model.Cblacklistflag = int.Parse(dt.Rows[rowindex]["Cblacklistflag"].ToString());
         }
         model.Cphone     = dt.Rows[rowindex]["Cphone"].ToString();
         model.Cphone2    = dt.Rows[rowindex]["Cphone2"].ToString();
         model.Cphone3    = dt.Rows[rowindex]["Cphone3"].ToString();
         model.Cphone4    = dt.Rows[rowindex]["Cphone4"].ToString();
         model.CPhoneName = dt.Rows[rowindex]["CPhoneName"].ToString();
         model.CreatDate  = Convert.ToDateTime(dt.Rows[rowindex]["CreatDate"]);
         if (dt.Rows[rowindex]["IsDeleted"].ToString() != "")
         {
             model.IsDeleted = int.Parse(dt.Rows[rowindex]["IsDeleted"].ToString());
         }
     }
     catch (Exception ex)
     {
         log.Info("转换成用户对象失败!原因:" + ex.Message);
         return(new Entity.ContactEntity());
     }
     return(model);
 }
Exemplo n.º 2
0
        /// <summary>
        /// 得到多个联系电话
        /// </summary>
        public List <Daiv_OA.Entity.ContactEntity> GetEntitysBySid(int[] Sid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  ");
            strSql.Append(" Cid,Sid ,Cphone ,Cphone2 ,Cphone3 ,Cphone4 ,Cblacklistflag ,CPhoneName,CreatDate ,IsDeleted  ");
            strSql.Append(" FROM [OA_Contact] ");
            strSql.Append(" where IsDeleted = 0 and Sid in(" + string.Join(",", Sid) + ") ");
            Daiv_OA.Entity.ContactEntity model = new Daiv_OA.Entity.ContactEntity();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                List <Daiv_OA.Entity.ContactEntity> list = new List <Entity.ContactEntity>();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    list.Add(ConvertModel(ds.Tables[0], i));
                }
                return(list);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Daiv_OA.Entity.ContactEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update [OA_Contact] set ");
            strSql.Append("Cphone='" + model.Cphone + "',");
            strSql.Append("Cphone2='" + model.Cphone2 + "',");
            strSql.Append("Cphone3='" + model.Cphone3 + "',");
            strSql.Append("CPhoneName='" + model.CPhoneName + "',");
            strSql.Append("CreatDate='" + model.CreatDate + "',");
            strSql.Append("Cphone4='" + model.Cphone4 + "'");//注意: 最后不需要加逗号
            strSql.Append(" where Cid=" + model.Cid + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Daiv_OA.Entity.ContactEntity GetEntityBySid(int Sid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" Cid,Sid ,Cphone ,Cphone2 ,Cphone3 ,Cphone4 ,Cblacklistflag ,CPhoneName,CreatDate ,IsDeleted  ");
            strSql.Append(" FROM [OA_Contact] ");
            strSql.Append(" where IsDeleted = 0 and Sid=" + Sid + " ");
            Daiv_OA.Entity.ContactEntity model = new Daiv_OA.Entity.ContactEntity();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(ConvertModel(ds.Tables[0], 0));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Daiv_OA.Entity.ContactEntity model)
        {
            if (model.Cid > 0 && Exists(model.Sid))//已经存在该用户
            {
                return(0);
            }
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            model.IsDeleted = 0;
            model.CreatDate = DateTime.Now;

            if (model.Sid > 0)
            {
                strSql1.Append("Sid,");
                strSql2.Append("" + model.Sid + ",");
            }
            if (model.Cphone != null)
            {
                strSql1.Append("Cphone,");
                strSql2.Append("'" + model.Cphone + "',");
            }
            if (model.Cphone2 != null)
            {
                strSql1.Append("Cphone2,");
                strSql2.Append("'" + model.Cphone2 + "',");
            }
            if (model.Cphone3 != null)
            {
                strSql1.Append("Cphone3,");
                strSql2.Append("'" + model.Cphone3 + "',");
            }
            if (model.Cphone4 != null)
            {
                strSql1.Append("Cphone4,");
                strSql2.Append("'" + model.Cphone4 + "',");
            }
            if (model.CPhoneName != null)
            {
                strSql1.Append("CPhoneName,");
                strSql2.Append("'" + model.CPhoneName + "',");
            }
            if (model.CreatDate != null)
            {
                strSql1.Append("CreatDate,");
                strSql2.Append("'" + model.CreatDate + "',");
            }
            if (model.Cblacklistflag >= 0)
            {
                strSql1.Append("Cblacklistflag,");
                strSql2.Append("" + model.Cblacklistflag + ",");
            }
            if (model.IsDeleted >= 0)
            {
                strSql1.Append("IsDeleted,");
                strSql2.Append("0,");
            }
            strSql.Append("insert into [OA_Contact](");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            strSql.Append(";select @@IDENTITY");
            object obj = DbHelperSQL.GetSingle(strSql.ToString());

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }