Example #1
0
        public bool Delete(Model.T_Style model)
        {
            //读取配置文件中的相关节点信息:数据库连接字符串
            string setting = ConfigurationManager.ConnectionStrings["connstring"].ToString();
            //创建数据库对象
            SqlConnection myconn = new SqlConnection(setting);

            //打开连接
            myconn.Open();
            //创建命令对象,并准备好操作数据库的SQL语句
            SqlCommand cmd = new SqlCommand("delete from T_Style where Id=@id;delete from T_Music where StyleId=@styleid", myconn);

            //为SQL语句匹配相关参数,并赋值
            cmd.Parameters.AddWithValue("@id", model.Id);
            cmd.Parameters.AddWithValue("@styleid", model.Id);


            //执行相关SQL语句并返回受影响的行数,若受影响行数大于0,则表示执行成功,否者,执行失败
            if (cmd.ExecuteNonQuery() > 0)
            {
                cmd.Dispose();
                myconn.Dispose();
                return(true);
            }
            else
            {
                cmd.Dispose();
                myconn.Dispose();
                return(false);
            }
        }
Example #2
0
        public bool Update(Model.T_Style model)
        {
            //读取配置文件中的相关节点信息:数据库连接字符串
            string setting = ConfigurationManager.ConnectionStrings["connstring"].ToString();

            SqlConnection myconn = new SqlConnection(setting);

            myconn.Open();

            SqlCommand cmd = new SqlCommand("update T_Style set Style=@style where Id=@id", myconn);

            cmd.Parameters.AddWithValue("@style", model.Style);
            cmd.Parameters.AddWithValue("@id", model.Id);

            if (cmd.ExecuteNonQuery() > 0)
            {
                cmd.Dispose();
                myconn.Dispose();

                return(true);
            }
            else
            {
                cmd.Dispose();
                myconn.Dispose();

                return(false);
            }
        }
    //点击更新按钮更新数据
    protected void Update_Click(object sender, EventArgs e)
    {
        Model.T_Style Style = new Model.T_Style();

        Style.Id    = Convert.ToInt32(S_Id.Value);
        Style.Style = TB_Style.Text.Trim();
        //Style.Sex = SingerSex.SelectedItem.ToString();
        //Singer.ClassNO = ddlClass.SelectedValue.ToString();

        BLL.T_Style StyleBll = new BLL.T_Style();


        if (StyleBll.Update(Style))
        {
            Response.Write("修改成功");
            Add.Visible    = true;
            Update.Visible = false;
            TB_Style.Text  = "";

            BindDate();
        }
        else
        {
            Response.Write("修改失败");
        }
    }
Example #4
0
        public bool Add(Model.T_Style model)
        {
            //读取配置文件中的相关节点信息:数据库连接字符串
            string setting = ConfigurationManager.ConnectionStrings["connstring"].ToString();
            //创建数据库对象
            SqlConnection myconn = new SqlConnection(setting);

            //打开连接
            myconn.Open();
            //创建命令对象,并准备好操作数据库的SQL语句
            SqlCommand cmd = new SqlCommand("insert into T_Style([Style]) values (@style)", myconn);

            //为SQL语句匹配相关参数,并赋值
            cmd.Parameters.AddWithValue("@style", model.Style);

            //执行相关SQL语句并返回受影响的行数,若受影响行数大于0,则表示执行成功,否者,执行失败
            if (cmd.ExecuteNonQuery() > 0)
            {
                cmd.Dispose();
                myconn.Dispose();
                return(true);
            }
            else
            {
                cmd.Dispose();
                myconn.Dispose();
                return(false);
            }
        }
    //增加歌曲类型
    protected void Add_Click(object sender, EventArgs e)
    {
        //如果文本框为空,不保存
        if (TB_Style.Text == "")
        {
            Response.Write("保存失败");
        }

        else
        {
            Model.T_Style Style = new Model.T_Style();
            Style.Style = TB_Style.Text.Trim();

            BLL.T_Style StyleBll = new BLL.T_Style();
            if (StyleBll.Add(Style))
            {
                Response.Write("保存成功");

                BindDate();
            }
            else
            {
                Response.Write("保存失败");
            }
        }
    }
    //删除数据
    protected void GV_Style_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        Model.T_Style Style     = new Model.T_Style();
        BLL.T_Style   SingerBll = new BLL.T_Style();
        //Singer.Id = Convert.ToInt32(GVSinger.Rows[e.RowIndex].Cells[0].Text);
        Style.Id = Convert.ToInt32(SingerBll.Select(Convert.ToInt32(GV_Style.Rows[e.RowIndex].Cells[0].Text)).Tables[0].Rows[0][0].ToString());


        if (SingerBll.Delete(Style))
        {
            Response.Write("删除成功");
            BindDate();
        }
        else
        {
            Response.Write("删除失败");
        }
    }
Example #7
0
 //更新
 public bool Update(Model.T_Style model)
 {
     return(db.Update(model));
 }
Example #8
0
 //删除
 public bool Delete(Model.T_Style model)
 {
     return(db.Delete(model));
 }
Example #9
0
        //增加

        public bool Add(Model.T_Style model)
        {
            return(db.Add(model));
        }