private void BindArticle() { string ktm = gridExProductsAndArticles.CurrentRow.Cells["KTM"].Value.ToString(); string descriptor = gridExProductsAndArticles.CurrentRow.Cells["Deskryptor"].Value.ToString(); int agreementId = gridExAgreementsListGrouped.CurrentRow.GroupCaption == null ? (int)gridExAgreementsListGrouped.CurrentRow.Cells["IdUmowy"].Value : Convert.ToInt16(gridExAgreementsListGrouped.CurrentRow.GroupCaption); if (MessageBox.Show(string.Format("Do umowy {0} zostanie dopisany towar powiązany:\r\n\r\nKTM:\t\t{1}\r\nDeskryptor:\t{2}", agreementId.ToString(), ktm, descriptor), "Przypisanie", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { try { RelatedArticle relatedArticle = new RelatedArticle() { AgreementId = agreementId, KTM = ktm, Descriptor = descriptor, Comments = "" }; AgreementsRepo.InsertRelatedArticle(relatedArticle); MessageBox.Show("Towar został poprawnie powiązany.", "Przypisanie", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { MessageBox.Show("Nie udało się wykonać powiązania.\r\nOdśwież listę i spróbuj ponownie.", "Przypisanie", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.LoadData(); } }
private void InsertAgreement() { try { AgreementsRepo.Insert(this.agreement); this.LoadData(); } catch (Exception ex) { MessageBox.Show("Nie udało się zapisać nowej umowy.\r\nSpróbuj ponownie.", "Zapis umowy", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void UpdateAgreement() { bool isFullySaved = true; try { AgreementsRepo.Update(this.agreement); } catch (Exception ex) { MessageBox.Show("Nie udało się zapisać nagłówka umowy.\r\nSpróbuj ponownie.", "Zapis umowy", MessageBoxButtons.OK, MessageBoxIcon.Error); isFullySaved = false; } try { this.gridArticlesRepo.Update(); } catch (Exception ex) { MessageBox.Show("Nie udało się zapisać towarów powiązanych.\r\nSpróbuj ponownie.", "Zapis umowy", MessageBoxButtons.OK, MessageBoxIcon.Error); isFullySaved = false; } try { this.gridLicensorsRepo.Update(); } catch (Exception ex) { MessageBox.Show("Nie udało się zapisać licencjodawców.\r\nSpróbuj ponownie.", "Zapis umowy", MessageBoxButtons.OK, MessageBoxIcon.Error); isFullySaved = false; } try { this.gridScheduleRepo.Update(); } catch (Exception ex) { MessageBox.Show("Nie udało się zapisać harmonogramu.\r\nSpróbuj ponownie.", "Zapis umowy", MessageBoxButtons.OK, MessageBoxIcon.Error); isFullySaved = false; } if (isFullySaved) { MessageBox.Show("Umowa została poprawnie zapisana.", "Zapis umowy", MessageBoxButtons.OK, MessageBoxIcon.Information); this.SetAgreementChangesPending(false); this.LoadData(); } }
public FrmAgreement(int agreementID, int positionId, FrmAgreementsList parentForm = null) { InitializeComponent(); this.gridPositionsRepo = new GridAgreementPositionsRepo(); this.gridArticlesRepo = new GridAgreementArticlesRepo(); this.gridLicensorsRepo = new GridAgreementLicensorsRepo(); this.gridScheduleRepo = new GridAgreementScheduleRepo(); this.gridThresholdsRepo = new GridAgreementThresholdsRepo(); this.gridRelatedProductsRepo = new GridAgreementRelatedProductsRepo(); this.parentForm = parentForm; this.agreement = agreementID > 0 ? AgreementsRepo.GetByID(agreementID) : new Agreement(); this.PrepareForm(); this.LoadData(); this.SelectPositionById(positionId); }