예제 #1
0
 /// <summary>
 /// method to delete item from datebase
 /// </summary>
 /// <param name="ItemCode"></param>
 /// <returns></returns>
 public static bool DeleteItem(String ItemCode)
 {
     using (OleDbConnection db = clsItemsSQL.GetConnection())
     {
         clsItemsSQL sql = new clsItemsSQL();
         db.Open();
         OleDbCommand command = new OleDbCommand(sql.deletefrom(), db);
         command.Parameters.Add(ItemCode);
         return((command.ExecuteNonQuery() == 0) ? false : true);
     }
 }
예제 #2
0
 /// <summary>
 /// method to save items to the databse
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static bool SaveToDatabase(clsItemsLogic item)
 {
     using (OleDbConnection db = clsItemsSQL.GetConnection())
     {
         db.Open();
         clsItemsSQL  sql     = new clsItemsSQL();
         OleDbCommand command = new OleDbCommand(sql.saveitem(), db);
         command.Parameters.Add(new OleDbParameter("@ItemCode", item.ItemCode));
         command.Parameters.Add(new OleDbParameter("@ItemDesc", item.ItemDesc));
         command.Parameters.Add(new OleDbParameter("@Cost", item.ItemPrice));
         return((command.ExecuteNonQuery() == 0) ? false : true);
     }
 }
예제 #3
0
 /// <summary>
 /// method to update datebase items
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static bool UpdateItem(clsItemsLogic item)
 {
     if (item.ItemCode == null)
     {
         return(false);
     }
     using (OleDbConnection db = clsItemsSQL.GetConnection())
     {
         db.Open();
         clsItemsSQL  sql     = new clsItemsSQL();
         OleDbCommand command = new OleDbCommand(sql.update(), db);
         command.Parameters.AddRange(new OleDbParameter[] {
             new OleDbParameter("@Items", item.ItemDesc),
             new OleDbParameter("@Cost", item.ItemPrice),
             new OleDbParameter("@ItemCode", item.ItemCode)
         });
         return((command.ExecuteNonQuery() == 0) ? false : true);
     }
 }
예제 #4
0
        /// <summary>
        /// method to pull data from database
        /// </summary>
        /// <returns></returns>
        public static List <clsItemsLogic> SelectItem()
        {
            List <clsItemsLogic> items = new List <clsItemsLogic>();

            using (OleDbConnection db = clsItemsSQL.GetConnection())
            {
                db.Open();
                clsItemsSQL     sql     = new clsItemsSQL();
                OleDbCommand    command = new OleDbCommand(sql.select(), db);
                OleDbDataReader read    = command.ExecuteReader();
                while (read.Read())
                {
                    items.Add(new clsItemsLogic()
                    {
                        ItemCode = read.GetString(0) ?? "", ItemDesc = read.GetString(1) ?? "", ItemPrice = read.GetDecimal(2)
                    });
                }
                db.Close();
            }
            return(items);
        }