Пример #1
0
 private void barButtonItem2_ItemClick(object sender, ItemClickEventArgs e)
 {
     DataRow dr = null;
     try
     {
         if (gridViewMappedPhrases.IsValidRowHandle(gridViewMappedPhrases.FocusedRowHandle))
         {
             dr = gridViewMappedPhrases.GetDataRow(gridViewMappedPhrases.FocusedRowHandle);
             InbAttribMapPhraseDto inbAttribMapPhraseData = new InbAttribMapPhraseDto();
             inbAttribMapPhraseData.ActiveFlag = "N";
             inbAttribMapPhraseData.Id = Convert.ToInt32(dr["ID"].ToString());
             inbAttribMapPhraseData.InbAttribMapValId = Convert.ToInt32(dr["Mapped Attribute ID"]);
             inbAttribMapPhraseData.Phrase = dr["Phrase"].ToString();
             UpdateMappedPhrase(inbAttribMapPhraseData);
         }
     }
     catch (Exception ex)
     {
         //XtraMessageBox.Show("Exception in delete mapping: " + ex.Message);
         XtraMessageBox.Show("An error occurred while deleting mappings." + Environment.NewLine +
             "Error CNF-188 in " + FORM_NAME + ".barButtonItem2_ItemClick(): " + ex.Message,
           MAIN_FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #2
0
        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);
            }
        }
Пример #3
0
       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);
           }
       }
Пример #4
0
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            string phrase = richTextBox1.SelectedText.Trim();
            if (lkupMappings.Text.Equals(""))
            {
                XtraMessageBox.Show("Please select a valid mapping for your phrase: " + phrase);
                return;
            }
            string mappDesc = lkupMappings.Text;
            DataRow[] rows = tblUserMappings.Select("Description = " + "'" + mappDesc.Replace("'", "''") + "'");
            if (rows.Length == 0) return;
            DataRow row = rows[0];

            if (row == null || phrase.Trim().Equals("")) return;

            InbAttribMapPhraseDto inbAttribMapPhraseData = new InbAttribMapPhraseDto();
            inbAttribMapPhraseData.Id = 0;
            inbAttribMapPhraseData.ActiveFlag = "Y";
            inbAttribMapPhraseData.InbAttribMapValId = Convert.ToInt32(row["ID"]);
            inbAttribMapPhraseData.Phrase = phrase;

            UpdateMappedPhrase(inbAttribMapPhraseData);
        }
Пример #5
0
       private void btnMapPhraseSave_Click(object sender, EventArgs e)
       {
           if (lkupMappedValue.Text.Equals("")) return;
           DataRow row = ((System.Data.DataRowView)(lkupMappedValue.EditValue)).Row;
           string phrase = tedPhrase.Text.Trim();

           InbAttribMapPhraseDto mapPhraseData = new InbAttribMapPhraseDto();
           mapPhraseData.ActiveFlag = "Y";
           mapPhraseData.InbAttribMapValId = Convert.ToInt32(row["ID"].ToString());
           mapPhraseData.Phrase = phrase;
           mapPhraseData.Id = 0;

           if (row == null || phrase.Trim().Equals("")) return;
           UpdateMappedPhrase(mapPhraseData);
       }