Example #1
0
 /// <summary>
 /// Checks if employee with username and password exists in database BarStock.
 /// </summary>
 /// <param name="username"></param>
 /// <param name="password"></param>
 /// <param name="employee"></param>
 /// <returns></returns>
 public bool IsEmployee(string username, string password, out tblEmployee employee)
 {
     try
     {
         using (BarStockEntities context = new BarStockEntities())
         {
             employee = (from e in context.tblEmployees where e.UserName == username && e.Pass == password select e).First();
             return(true);
         }
     }
     catch
     {
         employee = null;
         return(false);
     }
 }
Example #2
0
 /// <summary>
 /// Updates articles amount in DB with data from the list.
 /// </summary>
 /// <param name="articles"></param>
 public void UpdateAmount(List <vwArticle> articles)
 {
     using (BarStockEntities context = new BarStockEntities())
     {
         for (int i = 0; i < articles.Count; i++)
         {
             if (articles[i].NewAmount != null)
             {
                 int        id      = articles[i].ArticleID;
                 tblArticle article = (from a in context.tblArticles where a.ArticleID == id select a).First();
                 article.Amount = (decimal)articles[i].NewAmount;
             }
         }
         context.SaveChanges();
     }
 }
Example #3
0
        /// <summary>
        /// Retrives all articles from database and adds them to a list.
        /// </summary>
        /// <returns></returns>
        public List <vwArticle> GetAllArticles()
        {
            List <vwArticle> articles;

            try
            {
                using (BarStockEntities context = new BarStockEntities())
                {
                    articles = (from a in context.vwArticles select a).ToList();
                }
            }
            catch
            {
                articles = null;
            }
            return(articles);
        }