Ejemplo n.º 1
0
    public IList <FbCategory> FindFbCategories()
    {
        SqlConnection      con  = ConnectDB.Connect();
        IList <FbCategory> list = new List <FbCategory>();

        string         sql = "select * from FbCategory";
        SqlCommand     cmd = new SqlCommand(sql, con);
        SqlDataAdapter da  = new SqlDataAdapter(cmd);
        DataTable      dt  = new DataTable();

        da.Fill(dt);

        if (dt != null)
        {
            FbCategory c = null;
            foreach (DataRow row in dt.Rows)
            {
                c      = new FbCategory();
                c.ID   = Int32.Parse(row["id"].ToString());
                c.Name = row["name"].ToString();
                list.Add(c);
            }
        }



        return(list);
    }
Ejemplo n.º 2
0
    public int AddFbCategory(FbCategory fbCategory)
    {
        SqlConnection con = ConnectDB.Connect();
        string        sql = String.Format("insert into FbCategory(name) values('{0}')", fbCategory.Name);
        SqlCommand    cmd = new SqlCommand(sql, con);

        con.Open();
        int num = cmd.ExecuteNonQuery();

        con.Close();
        return(num);
    }
Ejemplo n.º 3
0
    public int EditFbCategory(FbCategory fbCategory)
    {
        SqlConnection con = ConnectDB.Connect();
        string        sql = String.Format("update FbCategory set name='{0}' where id={1}", fbCategory.Name, fbCategory.ID);
        SqlCommand    cmd = new SqlCommand(sql, con);

        con.Open();
        int num = cmd.ExecuteNonQuery();

        con.Close();
        return(num);
    }
Ejemplo n.º 4
0
 public FbProduct(string catName, int id, int catID, string name, string image, decimal price, string summary, string Producer)
 {
     _FbCategory      = new FbCategory();
     _FbCategory.ID   = catID;
     _FbCategory.Name = catName;
     _ID       = id;
     _CatID    = catID;
     _Name     = name;
     _Image    = image;
     _Price    = price;
     _Summary  = summary;
     _Producer = Producer;
 }
Ejemplo n.º 5
0
 public FbProduct()
 {
     _FbCategory = new FbCategory();
 }
Ejemplo n.º 6
0
 public int AddFbCategory(FbCategory fbCategory)
 {
     return(fbCategoryDAL.AddFbCategory(fbCategory));
 }
Ejemplo n.º 7
0
 public int EditFbCategory(FbCategory fbCategory)
 {
     return(fbCategoryDAL.EditFbCategory(fbCategory));
 }