Esempio n. 1
0
    /// <summary>
    /// 添加分类
    /// </summary>
    public int AddCategory(string Cname, string Cstatus)
    {
        //标识变量
        int result = 1;
        //创建LINQ查询语句
        var results = from v_pc in lqc.Photo_Category
                      where v_pc.C_Name == Cname
                      select v_pc;

        //判断是否存在同名分类名称
        if (results.Count() > 0)
        {
            result = 0;//说明存在同名分类
        }
        else//执行添加操作
        {
            Photo_Category pc = new Photo_Category();
            pc.C_Name   = Cname;
            pc.C_Status = Cstatus;
            try
            {
                //插入信息
                lqc.Photo_Category.InsertOnSubmit(pc);
                //提交数据库
                lqc.SubmitChanges();
            }
            catch (Exception ex)
            {
                //抛出异常
                throw new Exception(ex.Message, ex);
            }
        }
        return(result);
    }
Esempio n. 2
0
    /// <summary>
    ///   删除行数据
    /// </summary>
    protected void gvCategory_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int DataKey = Convert.ToInt32(gvCategory.DataKeys[e.RowIndex].Value.ToString());
        //定义查询操作的SQL语句
        string  sqlstr = "select * from Photo where CategoryID=" + DataKey;
        DataSet ds     = am.GetDataSet(sqlstr, "PhotoCategory");

        if (ds.Tables["PhotoCategory"].Rows.Count > 0)
        {
            ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('此相册中由于存在照片不可删除!');", true);
        }
        else
        {
            Photo_Category pc = lqc.Photo_Category.SingleOrDefault(itm => itm.ID == DataKey);
            lqc.Photo_Category.DeleteOnSubmit(pc); //执行删除操作
            lqc.SubmitChanges();                   //提交删除操作
        }
        BindGV();
    }
Esempio n. 3
0
    /// <summary>
    /// 添加分类
    /// </summary>
    public int AddCategory(string Cname, string Cstatus)
    {
        //标识变量
        int result = 1;
        //创建LINQ查询语句
        var results = from v_pc in lqc.Photo_Category
                     where v_pc.C_Name == Cname
                     select v_pc;
        //判断是否存在同名分类名称
        if (results.Count() > 0)
        {
            result = 0;//说明存在同名分类
        }
        else//执行添加操作
        {
            Photo_Category pc = new Photo_Category();
            pc.C_Name = Cname;
            pc.C_Status = Cstatus;
            try
            {
                //插入信息
                lqc.Photo_Category.InsertOnSubmit(pc);
                //提交数据库
                lqc.SubmitChanges();

            }
            catch (Exception ex)
            {
                //抛出异常
                throw new Exception(ex.Message, ex);
            }
        }
        return result;
    }
 partial void DeletePhoto_Category(Photo_Category instance);
 partial void UpdatePhoto_Category(Photo_Category instance);
 partial void InsertPhoto_Category(Photo_Category instance);
Esempio n. 7
0
 partial void DeletePhoto_Category(Photo_Category instance);
Esempio n. 8
0
 partial void UpdatePhoto_Category(Photo_Category instance);
Esempio n. 9
0
 partial void InsertPhoto_Category(Photo_Category instance);