Exemple #1
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public int Add(JuBaoInfo model)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@id",          SqlDbType.Int,         4),
                    new SqlParameter("@name",        SqlDbType.NVarChar,   50),
                    new SqlParameter("@email",       SqlDbType.NVarChar,   30),
                    new SqlParameter("@tel",         SqlDbType.VarChar,    20),
                    new SqlParameter("@url",         SqlDbType.NVarChar,  200),
                    new SqlParameter("@type",        SqlDbType.TinyInt,     1),
                    new SqlParameter("@remark",      SqlDbType.NVarChar,  500),
                    new SqlParameter("@addtime",     SqlDbType.DateTime),
                    new SqlParameter("@status",      SqlDbType.TinyInt,     1),
                    new SqlParameter("@checktime",   SqlDbType.DateTime),
                    new SqlParameter("@check",       SqlDbType.Int,         4),
                    new SqlParameter("@checkremark", SqlDbType.NVarChar,  500),
                    new SqlParameter("@pwd",         SqlDbType.NVarChar,   20),
                    new SqlParameter("@field1",      SqlDbType.NVarChar,   50),
                    new SqlParameter("@field2",      SqlDbType.NVarChar,   50),
                    new SqlParameter("@field3",      SqlDbType.NVarChar, 200)
                };
                parameters[0].Direction = ParameterDirection.Output;
                parameters[1].Value     = model.name;
                parameters[2].Value     = model.email;
                parameters[3].Value     = model.tel;
                parameters[4].Value     = model.url;
                parameters[5].Value     = (int)model.type;
                parameters[6].Value     = model.remark;
                parameters[7].Value     = model.addtime;
                parameters[8].Value     = (int)model.status;
                parameters[9].Value     = model.checktime;
                parameters[10].Value    = model.check;
                parameters[11].Value    = model.checkremark;
                parameters[12].Value    = model.pwd;
                parameters[13].Value    = model.field1;
                parameters[14].Value    = model.field2;
                parameters[15].Value    = model.field3;

                DataBase.ExecuteNonQuery(CommandType.StoredProcedure, "proc_JuBao_add", parameters);
                return((int)parameters[0].Value);
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
                return(0);
            }
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ds"></param>
        /// <returns></returns>
        public JuBaoInfo GetModelFromDs(DataSet ds)
        {
            JuBaoInfo model = new JuBaoInfo();

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["name"] != null && ds.Tables[0].Rows[0]["name"].ToString() != "")
                {
                    model.name = ds.Tables[0].Rows[0]["name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["email"] != null && ds.Tables[0].Rows[0]["email"].ToString() != "")
                {
                    model.email = ds.Tables[0].Rows[0]["email"].ToString();
                }
                if (ds.Tables[0].Rows[0]["tel"] != null && ds.Tables[0].Rows[0]["tel"].ToString() != "")
                {
                    model.tel = ds.Tables[0].Rows[0]["tel"].ToString();
                }
                if (ds.Tables[0].Rows[0]["url"] != null && ds.Tables[0].Rows[0]["url"].ToString() != "")
                {
                    model.url = ds.Tables[0].Rows[0]["url"].ToString();
                }
                if (ds.Tables[0].Rows[0]["type"] != null && ds.Tables[0].Rows[0]["type"].ToString() != "")
                {
                    model.type = (JuBaoEnum)int.Parse(ds.Tables[0].Rows[0]["type"].ToString());
                }
                if (ds.Tables[0].Rows[0]["remark"] != null && ds.Tables[0].Rows[0]["remark"].ToString() != "")
                {
                    model.remark = ds.Tables[0].Rows[0]["remark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["addtime"] != null && ds.Tables[0].Rows[0]["addtime"].ToString() != "")
                {
                    model.addtime = DateTime.Parse(ds.Tables[0].Rows[0]["addtime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["status"] != null && ds.Tables[0].Rows[0]["status"].ToString() != "")
                {
                    model.status = (viviapi.Model.JuBaoStatusEnum) int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["checktime"] != null && ds.Tables[0].Rows[0]["checktime"].ToString() != "")
                {
                    model.checktime = DateTime.Parse(ds.Tables[0].Rows[0]["checktime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["check"] != null && ds.Tables[0].Rows[0]["check"].ToString() != "")
                {
                    model.check = int.Parse(ds.Tables[0].Rows[0]["check"].ToString());
                }
                if (ds.Tables[0].Rows[0]["checkremark"] != null && ds.Tables[0].Rows[0]["checkremark"].ToString() != "")
                {
                    model.checkremark = ds.Tables[0].Rows[0]["checkremark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["pwd"] != null && ds.Tables[0].Rows[0]["pwd"].ToString() != "")
                {
                    model.pwd = ds.Tables[0].Rows[0]["pwd"].ToString();
                }
                if (ds.Tables[0].Rows[0]["field1"] != null && ds.Tables[0].Rows[0]["field1"].ToString() != "")
                {
                    model.field1 = ds.Tables[0].Rows[0]["field1"].ToString();
                }
                if (ds.Tables[0].Rows[0]["field2"] != null && ds.Tables[0].Rows[0]["field2"].ToString() != "")
                {
                    model.field2 = ds.Tables[0].Rows[0]["field2"].ToString();
                }
                if (ds.Tables[0].Rows[0]["field3"] != null && ds.Tables[0].Rows[0]["field3"].ToString() != "")
                {
                    model.field3 = ds.Tables[0].Rows[0]["field3"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }