Exemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(TFXK.Model.TestingPersonPlan model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_TestingPersonPlan(");
            strSql.Append("TestingTitle,TestTimeAMStart,TestTimeAMEnd,TestTimePMStart,TestTimePMEnd,TestingClass,TestingSubClass,Address,AddresDes,Contactor,Description,TotalCount,Status,OrderNum,CreateTime,NumberPrefx,NumberStart,NumberIndex)");
            strSql.Append(" values (");
            strSql.Append("@TestingTitle,@TestTimeAMStart,@TestTimeAMEnd,@TestTimePMStart,@TestTimePMEnd,@TestingClass,@TestingSubClass,@Address,@AddresDes,@Contactor,@Description,@TotalCount,@Status,@OrderNum,@CreateTime,@NumberPrefx,@NumberStart,@NumberIndex)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TestingTitle",    SqlDbType.VarChar,   100),
                new SqlParameter("@TestTimeAMStart", SqlDbType.DateTime),
                new SqlParameter("@TestTimeAMEnd",   SqlDbType.DateTime),
                new SqlParameter("@TestTimePMStart", SqlDbType.DateTime),
                new SqlParameter("@TestTimePMEnd",   SqlDbType.DateTime),
                new SqlParameter("@TestingClass",    SqlDbType.VarChar,   500),
                new SqlParameter("@TestingSubClass", SqlDbType.VarChar,   500),
                new SqlParameter("@Address",         SqlDbType.NVarChar,  500),
                new SqlParameter("@AddresDes",       SqlDbType.NVarChar,  500),
                new SqlParameter("@Contactor",       SqlDbType.NVarChar,  100),
                new SqlParameter("@Description",     SqlDbType.Text),
                new SqlParameter("@TotalCount",      SqlDbType.Int,         4),
                new SqlParameter("@Status",          SqlDbType.Int,         4),
                new SqlParameter("@OrderNum",        SqlDbType.Int,         4),
                new SqlParameter("@CreateTime",      SqlDbType.DateTime),
                new SqlParameter("@NumberPrefx",     SqlDbType.VarChar,   100),
                new SqlParameter("@NumberStart",     SqlDbType.VarChar,   100),
                new SqlParameter("@NumberIndex",     SqlDbType.Int)
            };
            parameters[0].Value  = model.TestingTitle;
            parameters[1].Value  = model.TestTimeAMStart;
            parameters[2].Value  = model.TestTimeAMEnd;
            parameters[3].Value  = model.TestTimePMStart;
            parameters[4].Value  = model.TestTimePMEnd;
            parameters[5].Value  = model.TestingClass;
            parameters[6].Value  = model.TestingSubClass;
            parameters[7].Value  = model.Address;
            parameters[8].Value  = model.AddresDes;
            parameters[9].Value  = model.Contactor;
            parameters[10].Value = model.Description;
            parameters[11].Value = model.TotalCount;
            parameters[12].Value = model.Status;
            parameters[13].Value = model.OrderNum;
            parameters[14].Value = model.CreateTime;
            parameters[15].Value = model.NumberPrefx;
            parameters[16].Value = model.NumberStart;
            parameters[17].Value = model.NumberIndex;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TFXK.Model.TestingPersonPlan GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,TestingTitle,TestTimeAMStart,TestTimeAMEnd,TestTimePMStart,TestTimePMEnd,TestingClass,TestingSubClass,Address,AddresDes,Contactor,Description,TotalCount,Status,OrderNum,CreateTime,NumberPrefx,NumberStart,NumberIndex from tb_TestingPersonPlan ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TFXK.Model.TestingPersonPlan DataRowToModel(DataRow row)
        {
            TFXK.Model.TestingPersonPlan model = new TFXK.Model.TestingPersonPlan();
            if (row != null)
            {
                if (row["id"] != null && row["id"].ToString() != "")
                {
                    model.id = int.Parse(row["id"].ToString());
                }
                if (row["TestingTitle"] != null)
                {
                    model.TestingTitle = row["TestingTitle"].ToString();
                }
                if (row["TestTimeAMStart"] != null && row["TestTimeAMStart"].ToString() != "")
                {
                    model.TestTimeAMStart = DateTime.Parse(row["TestTimeAMStart"].ToString());
                }
                if (row["TestTimeAMEnd"] != null && row["TestTimeAMEnd"].ToString() != "")
                {
                    model.TestTimeAMEnd = DateTime.Parse(row["TestTimeAMEnd"].ToString());
                }
                if (row["TestTimePMStart"] != null && row["TestTimePMStart"].ToString() != "")
                {
                    model.TestTimePMStart = DateTime.Parse(row["TestTimePMStart"].ToString());
                }
                if (row["TestTimePMEnd"] != null && row["TestTimePMEnd"].ToString() != "")
                {
                    model.TestTimePMEnd = DateTime.Parse(row["TestTimePMEnd"].ToString());
                }
                if (row["TestingClass"] != null)
                {
                    model.TestingClass = row["TestingClass"].ToString();
                }
                if (row["TestingSubClass"] != null)
                {
                    model.TestingSubClass = row["TestingSubClass"].ToString();
                }
                if (row["Address"] != null)
                {
                    model.Address = row["Address"].ToString();
                }
                if (row["AddresDes"] != null)
                {
                    model.AddresDes = row["AddresDes"].ToString();
                }
                if (row["Contactor"] != null)
                {
                    model.Contactor = row["Contactor"].ToString();
                }
                if (row["Description"] != null)
                {
                    model.Description = row["Description"].ToString();
                }
                if (row["TotalCount"] != null && row["TotalCount"].ToString() != "")
                {
                    model.TotalCount = int.Parse(row["TotalCount"].ToString());
                }
                if (row["Status"] != null && row["Status"].ToString() != "")
                {
                    model.Status = int.Parse(row["Status"].ToString());
                }
                if (row["OrderNum"] != null && row["OrderNum"].ToString() != "")
                {
                    model.OrderNum = int.Parse(row["OrderNum"].ToString());
                }
                if (row["CreateTime"] != null && row["CreateTime"].ToString() != "")
                {
                    model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
                }

                if (row["NumberPrefx"] != null)
                {
                    model.NumberPrefx = row["NumberPrefx"].ToString();
                }
                if (row["NumberStart"] != null)
                {
                    model.NumberStart = row["NumberStart"].ToString();
                }
                if (row["NumberIndex"] != null && row["NumberIndex"].ToString() != "")
                {
                    model.NumberIndex = int.Parse(row["NumberIndex"].ToString());
                }
            }
            return(model);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(TFXK.Model.TestingPersonPlan model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_TestingPersonPlan set ");
            strSql.Append("TestingTitle=@TestingTitle,");
            strSql.Append("TestTimeAMStart=@TestTimeAMStart,");
            strSql.Append("TestTimeAMEnd=@TestTimeAMEnd,");
            strSql.Append("TestTimePMStart=@TestTimePMStart,");
            strSql.Append("TestTimePMEnd=@TestTimePMEnd,");
            strSql.Append("TestingClass=@TestingClass,");
            strSql.Append("TestingSubClass=@TestingSubClass,");
            strSql.Append("Address=@Address,");
            strSql.Append("AddresDes=@AddresDes,");
            strSql.Append("Contactor=@Contactor,");
            strSql.Append("Description=@Description,");
            strSql.Append("TotalCount=@TotalCount,");
            strSql.Append("Status=@Status,");
            strSql.Append("OrderNum=@OrderNum,");
            strSql.Append("CreateTime=@CreateTime,");
            strSql.Append("NumberPrefx=@NumberPrefx,");
            strSql.Append("NumberStart=@NumberStart,");
            strSql.Append("NumberIndex=@NumberIndex");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TestingTitle",    SqlDbType.VarChar,   100),
                new SqlParameter("@TestTimeAMStart", SqlDbType.DateTime),
                new SqlParameter("@TestTimeAMEnd",   SqlDbType.DateTime),
                new SqlParameter("@TestTimePMStart", SqlDbType.DateTime),
                new SqlParameter("@TestTimePMEnd",   SqlDbType.DateTime),
                new SqlParameter("@TestingClass",    SqlDbType.VarChar,   500),
                new SqlParameter("@TestingSubClass", SqlDbType.VarChar,   500),
                new SqlParameter("@Address",         SqlDbType.NVarChar,  500),
                new SqlParameter("@AddresDes",       SqlDbType.NVarChar,  500),
                new SqlParameter("@Contactor",       SqlDbType.NVarChar,  100),
                new SqlParameter("@Description",     SqlDbType.Text),
                new SqlParameter("@TotalCount",      SqlDbType.Int,         4),
                new SqlParameter("@Status",          SqlDbType.Int,         4),
                new SqlParameter("@OrderNum",        SqlDbType.Int,         4),
                new SqlParameter("@CreateTime",      SqlDbType.DateTime),
                new SqlParameter("@id",              SqlDbType.Int,         4),
                new SqlParameter("@NumberPrefx",     SqlDbType.VarChar,   100),
                new SqlParameter("@NumberStart",     SqlDbType.VarChar,   100),
                new SqlParameter("@NumberIndex",     SqlDbType.Int,         4),
            };
            parameters[0].Value  = model.TestingTitle;
            parameters[1].Value  = model.TestTimeAMStart;
            parameters[2].Value  = model.TestTimeAMEnd;
            parameters[3].Value  = model.TestTimePMStart;
            parameters[4].Value  = model.TestTimePMEnd;
            parameters[5].Value  = model.TestingClass;
            parameters[6].Value  = model.TestingSubClass;
            parameters[7].Value  = model.Address;
            parameters[8].Value  = model.AddresDes;
            parameters[9].Value  = model.Contactor;
            parameters[10].Value = model.Description;
            parameters[11].Value = model.TotalCount;
            parameters[12].Value = model.Status;
            parameters[13].Value = model.OrderNum;
            parameters[14].Value = model.CreateTime;
            parameters[15].Value = model.id;
            parameters[16].Value = model.NumberPrefx;
            parameters[17].Value = model.NumberStart;
            parameters[18].Value = model.NumberIndex;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }