Example #1
0
File: Plans.cs Project: xty3019/CRM
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.Plans DataRowToModel(DataRow row)
 {
     Maticsoft.Model.Plans model = new Maticsoft.Model.Plans();
     if (row != null)
     {
         if (row["PlanID"] != null)
         {
             model.PlanID = row["PlanID"].ToString();
         }
         if (row["ChanID"] != null && row["ChanID"].ToString() != "")
         {
             model.ChanID = int.Parse(row["ChanID"].ToString());
         }
         if (row["PlanDate"] != null && row["PlanDate"].ToString() != "")
         {
             model.PlanDate = DateTime.Parse(row["PlanDate"].ToString());
         }
         if (row["PlanContent"] != null)
         {
             model.PlanContent = row["PlanContent"].ToString();
         }
         if (row["PlanResultDate"] != null && row["PlanResultDate"].ToString() != "")
         {
             model.PlanResultDate = DateTime.Parse(row["PlanResultDate"].ToString());
         }
         if (row["PlanResult"] != null)
         {
             model.PlanResult = row["PlanResult"].ToString();
         }
     }
     return(model);
 }
Example #2
0
File: Plans.cs Project: xty3019/CRM
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.Plans model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Plans(");
            strSql.Append("PlanID,ChanID,PlanDate,PlanContent,PlanResultDate,PlanResult)");
            strSql.Append(" values (");
            strSql.Append("@PlanID,@ChanID,@PlanDate,@PlanContent,@PlanResultDate,@PlanResult)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@PlanID",         SqlDbType.Char,        36),
                new SqlParameter("@ChanID",         SqlDbType.Int,          4),
                new SqlParameter("@PlanDate",       SqlDbType.DateTime),
                new SqlParameter("@PlanContent",    SqlDbType.NVarChar,  1000),
                new SqlParameter("@PlanResultDate", SqlDbType.DateTime),
                new SqlParameter("@PlanResult",     SqlDbType.NVarChar, 1000)
            };
            parameters[0].Value = model.PlanID;
            parameters[1].Value = model.ChanID;
            parameters[2].Value = model.PlanDate;
            parameters[3].Value = model.PlanContent;
            parameters[4].Value = model.PlanResultDate;
            parameters[5].Value = model.PlanResult;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
File: Plans.cs Project: xty3019/CRM
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.Plans model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Plans set ");
            strSql.Append("ChanID=@ChanID,");
            strSql.Append("PlanDate=@PlanDate,");
            strSql.Append("PlanContent=@PlanContent,");
            strSql.Append("PlanResultDate=@PlanResultDate,");
            strSql.Append("PlanResult=@PlanResult");
            strSql.Append(" where PlanID=@PlanID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ChanID",         SqlDbType.Int,          4),
                new SqlParameter("@PlanDate",       SqlDbType.DateTime),
                new SqlParameter("@PlanContent",    SqlDbType.NVarChar,  1000),
                new SqlParameter("@PlanResultDate", SqlDbType.DateTime),
                new SqlParameter("@PlanResult",     SqlDbType.NVarChar,  1000),
                new SqlParameter("@PlanID",         SqlDbType.Char, 36)
            };
            parameters[0].Value = model.ChanID;
            parameters[1].Value = model.PlanDate;
            parameters[2].Value = model.PlanContent;
            parameters[3].Value = model.PlanResultDate;
            parameters[4].Value = model.PlanResult;
            parameters[5].Value = model.PlanID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
File: Plans.cs Project: xty3019/CRM
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.Plans GetModel(string PlanID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 PlanID,ChanID,PlanDate,PlanContent,PlanResultDate,PlanResult from Plans ");
            strSql.Append(" where PlanID=@PlanID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@PlanID", SqlDbType.Char, 36)
            };
            parameters[0].Value = PlanID;

            Maticsoft.Model.Plans model = new Maticsoft.Model.Plans();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }