Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(jdgl_res_head_app.Model.Ffjrb model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Ffjrb set ");
            strSql.Append("yydh=@yydh,");
            strSql.Append("qymc=@qymc,");
            strSql.Append("fjrb_code=@fjrb_code,");
            strSql.Append("fjrb=@fjrb,");
            strSql.Append("sjjg=@sjjg,");
            strSql.Append("is_top=@is_top,");
            strSql.Append("is_select=@is_select");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@yydh",      SqlDbType.VarChar, 50),
                new SqlParameter("@qymc",      SqlDbType.VarChar, 50),
                new SqlParameter("@fjrb_code", SqlDbType.VarChar, 50),
                new SqlParameter("@fjrb",      SqlDbType.VarChar, 50),
                new SqlParameter("@sjjg",      SqlDbType.Decimal,  9),
                new SqlParameter("@is_top",    SqlDbType.Bit,      1),
                new SqlParameter("@is_select", SqlDbType.Bit,      1),
                new SqlParameter("@id",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.yydh;
            parameters[1].Value = model.qymc;
            parameters[2].Value = model.fjrb_code;
            parameters[3].Value = model.fjrb;
            parameters[4].Value = model.sjjg;
            parameters[5].Value = model.is_top;
            parameters[6].Value = model.is_select;
            parameters[7].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(jdgl_res_head_app.Model.Ffjrb model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Ffjrb(");
            strSql.Append("yydh,qymc,fjrb_code,fjrb,sjjg,is_top,is_select)");
            strSql.Append(" values (");
            strSql.Append("@yydh,@qymc,@fjrb_code,@fjrb,@sjjg,@is_top,@is_select)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@yydh",      SqlDbType.VarChar, 50),
                new SqlParameter("@qymc",      SqlDbType.VarChar, 50),
                new SqlParameter("@fjrb_code", SqlDbType.VarChar, 50),
                new SqlParameter("@fjrb",      SqlDbType.VarChar, 50),
                new SqlParameter("@sjjg",      SqlDbType.Decimal,  9),
                new SqlParameter("@is_top",    SqlDbType.Bit,      1),
                new SqlParameter("@is_select", SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.yydh;
            parameters[1].Value = model.qymc;
            parameters[2].Value = model.fjrb_code;
            parameters[3].Value = model.fjrb;
            parameters[4].Value = model.sjjg;
            parameters[5].Value = model.is_top;
            parameters[6].Value = model.is_select;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public jdgl_res_head_app.Model.Ffjrb GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,yydh,qymc,fjrb_code,fjrb,sjjg,is_top,is_select from Ffjrb ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            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]["yydh"] != null && ds.Tables[0].Rows[0]["yydh"].ToString() != "")
                {
                    model.yydh = ds.Tables[0].Rows[0]["yydh"].ToString();
                }
                if (ds.Tables[0].Rows[0]["qymc"] != null && ds.Tables[0].Rows[0]["qymc"].ToString() != "")
                {
                    model.qymc = ds.Tables[0].Rows[0]["qymc"].ToString();
                }
                if (ds.Tables[0].Rows[0]["fjrb_code"] != null && ds.Tables[0].Rows[0]["fjrb_code"].ToString() != "")
                {
                    model.fjrb_code = ds.Tables[0].Rows[0]["fjrb_code"].ToString();
                }
                if (ds.Tables[0].Rows[0]["fjrb"] != null && ds.Tables[0].Rows[0]["fjrb"].ToString() != "")
                {
                    model.fjrb = ds.Tables[0].Rows[0]["fjrb"].ToString();
                }
                if (ds.Tables[0].Rows[0]["sjjg"] != null && ds.Tables[0].Rows[0]["sjjg"].ToString() != "")
                {
                    model.sjjg = decimal.Parse(ds.Tables[0].Rows[0]["sjjg"].ToString());
                }
                if (ds.Tables[0].Rows[0]["is_top"] != null && ds.Tables[0].Rows[0]["is_top"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["is_top"].ToString() == "1") || (ds.Tables[0].Rows[0]["is_top"].ToString().ToLower() == "true"))
                    {
                        model.is_top = true;
                    }
                    else
                    {
                        model.is_top = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["is_select"] != null && ds.Tables[0].Rows[0]["is_select"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["is_select"].ToString() == "1") || (ds.Tables[0].Rows[0]["is_select"].ToString().ToLower() == "true"))
                    {
                        model.is_select = true;
                    }
                    else
                    {
                        model.is_select = false;
                    }
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }