private void PopulatePhrases() { string mappDesc = ""; try { if (lkupMappings.Text.Equals("")) return; resetPhraseTable(); mappDesc = lkupMappings.Text; string select = "Description = " + "'" + mappDesc.Replace("'", "''") + "'"; DataRow[] rows = tblUserMappings.Select(select); if (rows.Length == 0) return; DataRow row = rows[0]; if (row != null) { Int32 inbAttribMapValId = Convert.ToInt32(row["ID"]); List<InbAttribMapPhraseDto> inbAttribMapPhraseList = new List<InbAttribMapPhraseDto>(); InbAttribMapPhraseDal inbAttribMapPhraseDal = new InbAttribMapPhraseDal(sqlConnectionStr); inbAttribMapPhraseList = inbAttribMapPhraseDal.GetPhrases(inbAttribMapValId); if (inbAttribMapPhraseList.Count > 0) { foreach (InbAttribMapPhraseDto data in inbAttribMapPhraseList) { DataRow dr = tblPhrases.NewRow(); dr[0] = data.Id; dr[1] = data.InbAttribMapValId; dr[2] = data.Phrase; dr[3] = "Y"; tblPhrases.Rows.Add(dr); } } else { //throw new Exception("Error in PopulatePhrases()"); throw new Exception("An error occurred while populating phrases." + Environment.NewLine + "Error CNF-186 in " + FORM_NAME + ".PopulatePhrases()"); } } } catch (Exception err) { //XtraMessageBox.Show(err.Message); XtraMessageBox.Show("An error occurred while processing phrases." + Environment.NewLine + "Error CNF-187 in " + FORM_NAME + ".PopulatePhrases(): " + err.Message, MAIN_FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void UpdateMappedPhrase(InbAttribMapPhraseDto pData) { bool isUpdate = pData.Id > 0; DataRow row = null; try { InbAttribMapPhraseDal inbAttribMapPhraseDal = new InbAttribMapPhraseDal(sqlConnectionStr); int methodResult = 0; if (isUpdate) methodResult = inbAttribMapPhraseDal.Update(pData); else if (pData.ActiveFlag.Equals("N")) methodResult = inbAttribMapPhraseDal.Delete(pData.Id); else methodResult = inbAttribMapPhraseDal.Insert(pData); if (methodResult > 0) { // update grid view with new row. if (tblPhrases == null) { InitPhraseTable(); } if (isUpdate) { row = tblPhrases.Rows.Find(pData.Id); if (row != null) { tblPhrases.Rows[tblPhrases.Rows.IndexOf(row)].Delete(); } } else { row = tblPhrases.NewRow(); row["ID"] = methodResult; row["Mapped Attribute ID"] = pData.InbAttribMapValId; row["Phrase"] = pData.Phrase; row["Active Flag"] = pData.ActiveFlag; tblPhrases.Rows.Add(row); } } else { //throw new Exception("Error UpdateMappedPhrase(InbAttribMapPhraseDto pData)"); //Israel 11/25/2015 -- The purpose of numbering this exception separately is to differentiate between a general //error that won't trigger this exception and one of these 0 rows updated errors. throw new Exception("An error occurred while updating a mapped phrase." + Environment.NewLine + "Error CNF-182 in " + FORM_NAME + ".UpdateMappedPhrase()"); } } catch (Exception err) { //XtraMessageBox.Show(err.Message); XtraMessageBox.Show("An error occurred while processing a Mapped Phrase." + Environment.NewLine + "Error CNF-183 in " + FORM_NAME + ".UpdateMappedPhrase(): " + err.Message, MAIN_FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void lkupMappedValue_TextChanged(object sender, EventArgs e) { try { if (lkupMappedValue.Text.Equals("")) return; DataRow row = ((System.Data.DataRowView)(lkupMappedValue.EditValue)).Row; if (row != null) { string mappedValue = row["CptySn"].ToString().Trim(); List<InbAttribMapComboDto> inbAttribMapComboList = new List<InbAttribMapComboDto>(); InbAttribMapPhraseDal inbAttribMapPhraseDal = new InbAttribMapPhraseDal(sqlConnectionString); inbAttribMapComboList = inbAttribMapPhraseDal.GetPhrases(mappedValue); if (inbAttribMapComboList.Count == 0) return; if (inbAttribMapComboList.Count > 0) { if (tblPhrases == null) { InitPhraseTable(); } else { tblPhrases.Clear(); } foreach (InbAttribMapComboDto data in inbAttribMapComboList) { DataRow dr = tblPhrases.NewRow(); dr[0] = data.PhraseId; dr[1] = data.MappedValId; dr[2] = data.Phrase; dr[3] = "Y"; tblPhrases.Rows.Add(dr); } } else { throw new Exception("Error CNF-536: No attribute mapped phrases were found for Mapped Value: " + mappedValue + "."); } } } catch (Exception err) { XtraMessageBox.Show("An error occurred while attempting to retrieve the requested data." + Environment.NewLine + "Error CNF-303 in " + FORM_NAME + ".lkupMappedValue_TextChanged(): " + err.Message, FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void barDeleteMapping_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { DataRow dr = null; try { if (gridViewMappedPhrases.IsValidRowHandle(gridViewMappedPhrases.FocusedRowHandle)) { dr = gridViewMappedPhrases.GetDataRow(gridViewMappedPhrases.FocusedRowHandle); InbAttribMapPhraseDal inbAttribMapPhraseDal = new InbAttribMapPhraseDal(sqlConnectionString); Int32 id = Convert.ToInt32(dr["ID"].ToString()); inbAttribMapPhraseDal.Delete(id); } } catch (Exception ex) { XtraMessageBox.Show("An error occurred while attempting to delete the requested mapping." + Environment.NewLine + "Error CNF-304 in " + FORM_NAME + ".barDeleteMapping_ItemClick(): " + ex.Message, FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void UpdateMappedPhrase(InbAttribMapPhraseDto pData) { bool isUpdate = pData.Id > 0; DataRow row = null; try { InbAttribMapPhraseDal inbAttribMapPhraseDal = new InbAttribMapPhraseDal(sqlConnectionString); int methodResult = 0; if (isUpdate) methodResult = inbAttribMapPhraseDal.Update(pData); else if (pData.ActiveFlag.Equals("N")) methodResult = inbAttribMapPhraseDal.Delete(pData.Id); else methodResult = inbAttribMapPhraseDal.Insert(pData); if (methodResult > 0) { // update grid view with new row. if (tblPhrases == null) { InitPhraseTable(); } if (isUpdate) { row = tblPhrases.Rows.Find(pData.Id); if (row != null) { tblPhrases.Rows[tblPhrases.Rows.IndexOf(row)].Delete(); } } else { row = tblPhrases.NewRow(); row["ID"] = methodResult; row["Mapped Attribute ID"] = pData.InbAttribMapValId; row["Phrase"] = pData.Phrase; row["Active Flag"] = pData.ActiveFlag; tblPhrases.Rows.Add(row); } } else { throw new Exception("No Attribute changes were made to the database."); } } catch (Exception err) { XtraMessageBox.Show("An error occurred while attempting to perform the requested update." + Environment.NewLine + "Error CNF-301 in " + FORM_NAME + ".UpdateMappedPhrase(): " + err.Message, FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } }