在同一解决方案中从web表单访问textbox.text到类库时出错

时间:2015-07-07 11:00:43

标签: c# .net

类库代码:

此代码在BlackBaud Crm中添加了批处理行。 它使用来自网页表单设计的文本框和组合框。 即使在异常部分,它也会在BatchException上给出错误

    public string AddRowToBatch(string param)
    {

        Guid SaveRequestGUID = default(Guid);
        Dictionary<string, string> BatchRowValues = new Dictionary<string, string>();
        int ISORGANIZATION = 0;
        string type = "Individual";
        try{
        if (type == "Individual")
        {
            ISORGANIZATION = 0;
        }
        else
        {
            ISORGANIZATION = 1;
        }

        BatchRowValues.Add(this.comboBox1.Tag.ToString, ISORGANIZATION.ToString);
        BatchRowValues.Add(this.textBox2.Tag.ToString, this.textBox2.Text.ToString);//key name 
        BatchRowValues.Add(this.comboBox2.Tag.ToString, ((SimpleAddressType)this.comboBox2.SelectedItem).AddressType.ToString);//address type
        BatchRowValues.Add(this.textBox3.Tag.ToString, this.textBox3.Text.ToString);//address
        BatchRowValues.Add(this.textBox4.Tag.ToString, this.textBox4.Text.ToString);//city
        BatchRowValues.Add(this.comboBox4.Tag.ToString, ((SimpleState)this.comboBox4.SelectedItem).StateID.ToString);//state
        BatchRowValues.Add(this.comboBox3.Tag.ToString, ((SimpleCountry)this.comboBox3.SelectedItem).getCountryID.ToString);//country
        BatchRowValues.Add(this.textBox5.Tag.ToString, this.textBox5.Text.ToString);


            int _batchRowSequence;

                _batchRowSequence += 1;
                SaveRequestGUID = _helper.BatchSaveRequest(_currentBatchID, BatchRowValues, _batchRowSequence);

               //ClearBatchRow();
               //button4_Click.Enabled = CheckEnableAddRowToBatchButton();


            }

            catch (BatchException ex)
            {
                Interaction.MsgBox(ex.BatchErrorMessage, MsgBoxStyle.Exclamation);
           }
            catch (Exception ex)
            {
                Interaction.MessageBox(ex.Message);
                //Interaction.MsgBox(ex.Message);
            }
        return "successfull";
    }

按钮点击代码:

    private void button4_Click(object sender, EventArgs e)
    {

        BBDataOperations obj = new BBDataOperations();
        obj.AddRowToBatch();
        //MessageBox.Show(obj.AddRowToBatch());
    }

0 个答案:

没有答案