/// <summary> /// Gets the product by line from import file. /// </summary> /// <param name="productImportLine">The product import line.</param> /// <returns></returns> /// Erstellt von Joshua Frey, am 20.01.2016 private Product GetProductByLineFromImportFile(string productImportLine) { Product importProduct; // Product_Id|Name|Producer|Price var lineAsArray = productImportLine.Split(this._delimiter); int productId; System.Nullable<double> extractedPrice; try { productId = Convert.ToInt32(lineAsArray[0]); extractedPrice = CommonMethods.GetNullableDoubleValueFromString(lineAsArray[3]); } catch (FormatException formatException) { throw new NWATException(String.Format("{0}\n\n{1}", formatException, MessageWrongDatatypeInExportedLine("Product", productImportLine, "int|string|string|int"))); } importProduct = new Product() { Product_Id = productId, Name = lineAsArray[1], Producer = lineAsArray[2], Price = extractedPrice }; return importProduct; }
/// <summary> /// Handles the SelectedIndexChanged event of the comboBox_ProjCritProdFulf control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> /// Erstellt von Veit Berg, am 27.01.16 private void comboBox_ProjCritProdFulf_SelectedIndexChanged(object sender, EventArgs e) { try{ if (formloaded > 2) { Product selectedValue = new Product(); ComboBox cmb = (ComboBox)sender; int selectedIndex = cmb.SelectedIndex; if (cmb.SelectedIndex > -1) { selectedValue = (Product)cmb.SelectedValue; if (selectedValue != null) { using (FulfillmentController fuFiCont = new FulfillmentController()) { int i = 0; var projProdFulf = fuFiCont.GetAllFulfillmentsForSingleProduct(PID, selectedValue.Product_Id); foreach (Fulfillment singleProjProdFulf in projProdFulf) { int row = i; bool selected = singleProjProdFulf.Fulfilled; String note = singleProjProdFulf.Comment; dataGridView_ProjCritProdFulf.Rows[row].Cells["Erfüllung"].Value = selected; dataGridView_ProjCritProdFulf.Rows[row].Cells["Bemerkung"].Value = note; i++; } } } } } formloaded++; } catch (Exception x) { MessageBox.Show(x.Message); } }
/// <summary> /// Handles the Click event of the btn_ProjCritProdFulfSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> /// Erstellt von Veit Berg, am 27.01.16 private void btn_ProjCritProdFulfSave_Click(object sender, EventArgs e) { try { if (comboBox_ProjCritProdFulf.SelectedIndex != -1) { using (FulfillmentController fulCont = new FulfillmentController()) { bool saveSucceeded = true; foreach (DataGridViewRow row in dataGridView_ProjCritProdFulf.Rows) { if (CommonMethods.CheckIfForbiddenDelimiterInDb((string)row.Cells["Bemerkung"].Value)) { CommonMethods.MessageForbiddenDelimiterWasFoundInText(); break; } else { Fulfillment fulFi = new Fulfillment(); fulFi.Criterion_Id = (int)row.Cells[0].Value; fulFi.Project_Id = Project.Project_Id; int selectedIndex = comboBox_ProjCritProdFulf.SelectedIndex; Product selectedValue = new Product(); selectedValue = (Product)comboBox_ProjCritProdFulf.SelectedItem; fulFi.Product_Id = selectedValue.Product_Id; fulFi.Comment = (string)row.Cells["Bemerkung"].Value; if ((bool)row.Cells["Erfüllung"].Value == true) { fulFi.Fulfilled = true; } else if ((bool)row.Cells["Erfüllung"].Value == false) { fulFi.Fulfilled = false; } if (!fulCont.UpdateFulfillmentEntry(fulFi)) { saveSucceeded = false; } } } if (saveSucceeded) { MessageBox.Show("Die Änderungen wurden erfolgreich gespeichert."); } else { MessageBox.Show("Beim Speichern ist ein Fehler unterlaufen."); } } } else { MessageBox.Show("Sie müssen ein Produkt auswählen."); } } catch (Exception x) { MessageBox.Show(x.Message); } }
partial void DeleteProduct(Product instance);
partial void UpdateProduct(Product instance);
partial void InsertProduct(Product instance);