internal void UpdateArticle(TableArticle Article) { SqlConnection conn = new SqlConnection(connectionString); try { conn.Open(); } catch (SqlException se) { return; } SqlCommand cmd = new SqlCommand("Update Article" + " Set Name = @Name, Price = @Price, Prod = @Prod, Requisition = @Requisition where IdArticle = @ID", conn); SqlParameter param = new SqlParameter(); param.ParameterName = "@Name"; param.Value = Article.GetName(); param.SqlDbType = SqlDbType.VarChar; cmd.Parameters.Add(param); param = new SqlParameter(); param.ParameterName = "@Price"; param.Value = Article.GetPrice(); param.SqlDbType = SqlDbType.Int; cmd.Parameters.Add(param); param = new SqlParameter(); param.ParameterName = "@Prod"; param.Value = Article.GetProduction(); param.SqlDbType = SqlDbType.Int; cmd.Parameters.Add(param); param = new SqlParameter(); param.ParameterName = "@Requisition"; param.Value = Article.GetRequisition(); param.SqlDbType = SqlDbType.Int; cmd.Parameters.Add(param); param = new SqlParameter(); param.ParameterName = "@ID"; param.Value = Article.GetId(); param.SqlDbType = SqlDbType.VarChar; cmd.Parameters.Add(param); try { cmd.ExecuteNonQuery(); } catch (SqlException se) { return; } conn.Close(); conn.Dispose(); }
public static TableArticle ZnajdzTowar(string id) { TableArticle towar = tableArticle.Select(n => n).Where(x => x.GetId() == id).FirstOrDefault(); return(towar); }