private Boolean createAndUpdateTermsAndConditions(tcmapping tcm) { Boolean status = true; try { TCmappingDB tcdb = new TCmappingDB(); tcmapping tc = new tcmapping(); int count = 0; List <tcmapping> TCMDetails = new List <tcmapping>(); foreach (ListViewItem itemRow in ListViewTC.Items) { try { if (itemRow.Checked) { tc = new tcmapping(); tc.DocumentID = cmbSelectDocument.SelectedItem.ToString(); tc.ReferenceTC = Convert.ToInt32(itemRow.SubItems[1].Text); TCMDetails.Add(tc); count++; } } catch (Exception ex) { MessageBox.Show("createAndUpdateTermsAndConditions() : Error creating Terms and Conditions mapping"); status = false; } } if (count == 0) { MessageBox.Show("No item selected"); status = false; } else { if (!tcdb.UpdateTCMapping(TCMDetails, tc)) { MessageBox.Show("createAndUpdateTermsAndConditions() : Failed to update Terms and Conditions mapping. Please check the values"); status = false; } } } catch (Exception) { MessageBox.Show("createAndUpdateTermsAndConditions() : Error updating Terms and Conditions."); status = false; } return(status); }
private void btnSave_Click_1(object sender, EventArgs e) { Boolean status = true; try { tcmapping tc = new tcmapping(); System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button; string btnText = btnSave.Text; if (btnText.Equals("Save")) { if (createAndUpdateTermsAndConditions(tc)) { MessageBox.Show("Terms and Conditions updated"); closeAllPanels(); pnlList.Visible = true; clearData(); disableButtons(); //ListTermsAndConditions(did); } else { status = false; } } if (!status) { MessageBox.Show("Failed to update Terms and condition mappiing"); } } catch (Exception ex) { MessageBox.Show("createAndUpdateTermsAndConditions() : Error"); } }