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 ListTermsAndConditions(string did) { try { ListViewTC.Items.Clear(); TCmappingDB tcmdb = new TCmappingDB(); List <tcmapping> TCMList = tcmdb.getTCMappingList(did); string[] str = new string[TCMList.Count]; int i = 0; TermsAndConditionsDB tcdb = new TermsAndConditionsDB(); List <termsandconditions> TCList = tcdb.getTermsAndConditions(); foreach (tcmapping tcm in TCMList) { str[i] = Convert.ToString(tcm.ReferenceTC); string s = str[i]; i++; } foreach (termsandconditions tcond in TCList) { ListViewItem item1 = new ListViewItem(); for (int j = 0; j < str.Length; j++) { if (str[j].Equals(tcond.ParagraphID.ToString())) { item1.Checked = true; break; } else { item1.Checked = false; } } item1.SubItems.Add(tcond.ParagraphID.ToString()); item1.SubItems.Add(tcond.ParagraphHeading); item1.SubItems.Add(tcond.Details); ListViewTC.Items.Add(item1); } } catch (Exception ex) { MessageBox.Show("Error in Terms and Condition mapping Listing"); } try { enableButtons(); pnlList.Visible = true; if (getuserPrivilegeStatus() == 1) { btnSave.Visible = false; } else { btnSave.Visible = true; } } catch (Exception ex) { } }