private void DtGridInventarListe_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (dtGridInventarListe.SelectedItem != null) { ArticleModel inv = (ArticleModel)dtGridInventarListe.SelectedItem; addupdate.txtArticleType.Text = inv.ArticleID.ToString(); addupdate.txtDescription.Text = inv.Description; addupdate.txtManufacturer.Text = inv.Manufacturer; addupdate.txtManufacturerPartNumber.Text = inv.ManufacturerPartNumber; addupdate.txtPricing.Text = inv.Pricing.ToString(); addupdate.txtLocation.Text = inv.Location; addupdate.txtQuantity.Text = inv.Quantity.ToString(); addupdate.txtProjects.Text = Article_ProjectController.getProjects(inv.ArticleID.ToString()); addupdate.txtProjects.ToolTip = Article_ProjectController.getProjects(inv.ArticleID.ToString()).Replace(",", "\n"); addupdate.txtSupplier.Text = inv.Supplier; addupdate.txtSupplierPartNumber.Text = inv.SupplierPartNumber; addupdate.cbxStatus.SelectedIndex = 0; addupdate.btnAddArticle.Content = "Update"; addupdate.itsAnUpdate = true; addupdate.txtArticleType.IsReadOnly = true; addupdate.itsAnUpdate = true; } }
public static void addHyperLinkAndProjects(List <ArticleModel> inv) { foreach (ArticleModel article in inv) { if (article.Supplier == "Mouser") { article.SupplierOrGoogleLink = "https://www.mouser.ch/Search/Refine?Keyword=" + article.SupplierPartNumber; } else if (article.Supplier == "Digi-Key") { article.SupplierOrGoogleLink = "https://www.digikey.com/products/en?keywords=" + article.SupplierPartNumber; } else if (article.Supplier == "Distrelec") { article.SupplierOrGoogleLink = "https://www.distrelec.ch/search?q=" + article.SupplierPartNumber; } else if (article.Manufacturer == "Mini-Circuits") { article.SupplierOrGoogleLink = "https://ww2.minicircuits.com/WebStore/modelSearch.html?model=" + article.ManufacturerPartNumber + "&search=1"; } else { article.SupplierOrGoogleLink = "https://www.google.com/search?q=" + article.SupplierPartNumber + " " + article.ManufacturerPartNumber + " " + article.Supplier + " " + article.Manufacturer; } article.Project = Article_ProjectController.getProjects(article.ArticleID.ToString()); } }
//Fills the focused text box with the selected information from the Suggestion list private void itemSelectedFullList(object sender, SelectionChangedEventArgs e) { if (listfullSuggestions.SelectedItem != null && itsME == "Supplier") { txtSupplier.Text = listfullSuggestions.SelectedValue.ToString(); } if (listfullSuggestions.SelectedItem != null && itsME == "Manufacturer") { txtManufacturer.Text = listfullSuggestions.SelectedValue.ToString(); } if (listfullSuggestions.SelectedItem != null && itsME == "Articletype") { txtArticleType.Text = listfullSuggestions.SelectedItem.ToString().Substring(0, 3); } if (listfullSuggestions.SelectedValue != null && itsAnUpdate) { Article_ProjectModel artproj = new Article_ProjectModel() { ID_Article = Convert.ToInt32(txtArticleType.Text), ID_Project = Convert.ToInt32(ProjectController.getProjectID(listfullSuggestions.SelectedValue.ToString())) }; if (!Article_ProjectController.articleprojectExists(artproj) && itsAnUpdate) { if (txtProjects.Text != "") { if (listfullSuggestions.SelectedItem != null && itsME == "Project") { txtProjects.Text += "," + listfullSuggestions.SelectedValue.ToString(); } } if (txtProjects.Text == "") { if (listfullSuggestions.SelectedItem != null && itsME == "Project") { txtProjects.Text += listfullSuggestions.SelectedValue.ToString(); } } } } if (!itsAnUpdate && itsME == "Project") { if (txtProjects.Text != "") { txtProjects.Text += "," + listfullSuggestions.SelectedValue.ToString(); } if (txtProjects.Text == "") { txtProjects.Text += listfullSuggestions.SelectedValue.ToString(); } } if (listfullSuggestions.SelectedItem != null && itsME == "Location") { txtLocation.Text = listfullSuggestions.SelectedValue.ToString(); } }
public static void archivInsert(ArticleModel article) { SQLiteConnection con = new SQLiteConnection(InventoryDBSqliteConnection.LoadConnectionString()); con.Open(); string query = "INSERT INTO Archiv_Article( " + "old_ArticleID, old_Description, " + "old_Category, old_Pricing, " + "old_Projects, " + "old_SupplierPartNumber, " + "old_ManufacturerPartNumber, " + "old_Manufacturer, " + "old_Supplier, " + "old_Status," + "old_Created, " + "old_Deleted) " + "VALUES(" + "@old_ArticleID, @old_Description, " + "@old_Category, @old_Pricing, " + "@old_Projects, " + "@old_SupplierPartNumber, " + "@old_ManufacturerPartNumber, " + "@old_Manufacturer, " + "@old_Supplier, " + "@old_Status," + "@old_Created, " + "@old_Deleted )"; SQLiteCommand cmd = new SQLiteCommand(query, con); cmd.Parameters.AddWithValue("@old_ArticleID", article.ArticleID); cmd.Parameters.AddWithValue("@old_Description", article.Description); cmd.Parameters.AddWithValue("@old_Category", article.Category); cmd.Parameters.AddWithValue("@old_Pricing", article.Pricing); cmd.Parameters.AddWithValue("@old_Projects", Article_ProjectController.getProjects(article.ArticleID.ToString())); cmd.Parameters.AddWithValue("@old_SupplierPartNumber", article.SupplierPartNumber); cmd.Parameters.AddWithValue("@old_ManufacturerPartNumber", article.ManufacturerPartNumber); cmd.Parameters.AddWithValue("@old_Manufacturer", article.Manufacturer); cmd.Parameters.AddWithValue("@old_Supplier", article.Supplier); cmd.Parameters.AddWithValue("@old_Status", article.Status); cmd.Parameters.AddWithValue("@old_Created", article.Created); cmd.Parameters.AddWithValue("@old_Created", article.Created); cmd.Parameters.AddWithValue("@old_Deleted", DateTime.Now.ToString("dd/MM/yyyy")); cmd.ExecuteNonQuery(); con.Close(); }
private void BtnAddArticle_Click(object sender, RoutedEventArgs e) { if (!isNumber(txtPricing.Text)) { txtPricing.Text = "1"; } if (!isNumber(txtQuantity.Text)) { txtQuantity.Text = "1"; } if (!CategoryController.categoryExist(txtArticleType.Text) && !itsAnUpdate) { MessageBox.Show("Invalid Category" + CategoryController.getCategoryID(txtArticleType.Text)); return; } ArticleModel am = new ArticleModel() { ArticleID = ArticleController.generateNewArticleNumber(Convert.ToInt32(txtArticleType.Text)), Description = txtDescription.Text, ID_Category = Convert.ToInt32(txtArticleType.Text), Pricing = Convert.ToDouble(txtPricing.Text), Quantity = Convert.ToInt32(txtQuantity.Text), //ID_Project = ProjectController.getProjectID(txtProjects.Text), SupplierPartNumber = txtSupplierPartNumber.Text, ManufacturerPartNumber = txtManufacturerPartNumber.Text, ID_Manufacturer = ManufacturerController.getManufacturerID(txtManufacturer.Text), ID_Supplier = SupplierController.getSupplierID(txtSupplier.Text), ID_Status = Convert.ToInt32(cbxStatus.SelectedValue.ToString()), Created = DateTime.Now.ToString("dd/MM/yyyy"), LastUpdate = DateTime.Now.ToString("dd/MM/yyyy"), ID_Location = LocationController.getLocationID(txtLocation.Text) }; if (!idsExist(am)) { return; } List <ArticleModel> duplicateArticles = ArticleController.checkSupplierAndManufacturerPartNumber(txtManufacturerPartNumber.Text, txtSupplierPartNumber.Text); if (duplicateArticles.Count > 0 && itsAnUpdate == false) { MessageBox.Show("Manufacturer or Supplier Part Number Already Exist on ArticleNumber: " + duplicateArticles[0].ArticleID.ToString()); return; } //AC.InsertArticle(am); if (!itsAnUpdate) { ArticleController.addNewArticle(am); inv.Add(am); Article_ProjectController.addArticleProjects(articleprojectList(am.ArticleID)); } else if (itsAnUpdate) { am.ArticleID = Convert.ToInt32(txtArticleType.Text); ArticleController.updateArticle(am); Article_ProjectController.addArticleProjects(articleprojectList(am.ArticleID)); } adv.refreshGrid(); // adv.inv = new ObservableCollection<ArticleModel>(ArticleController.GetInventoryList()); }