水晶报告不起作用,在3层架构中显示错误无效报告 [英] crystal report not working,showing error invalid report in 3 tier architechture

查看:92
本文介绍了水晶报告不起作用,在3层架构中显示错误无效报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码在.cs



使用System;

使用System.Collections.Generic;

使用System.ComponentModel;

使用System.Drawing;

使用System.Data;

使用System.Linq;

使用System.Text;

使用System.Windows.Forms;

使用DAL;

使用BLL;



命名空间_3TIERlanguage

{

公共部分类nvcontrol:UserControl

{

bll obj = new bll();

public nvcontrol()

{

InitializeComponent(); < br $>
}



// private void btnsave_Click(object sender,EventArgs e)

// {



//}



private void btnupdate_Click(object sender,EventArgs e)

{

if(txtcode.Text ==)

{

MessageBox.Show(输入您想要更新的代码);

}

其他

{

try

{

obj.pCODE = Convert.ToInt32(txtcode.Text);

obj.pNAME = txtname.Text;

obj.updaterec();

MessageBox.Show(更新);

obj.bind();

}

catch(例外情况)

{

MessageBox.Show(ex.Message);

}

}



}



private void btndelete_Click(object sender, EventArgs e)

{

if(txtcode.Text ==)

{

MessageBox.Show (输入您要删除的代码);

}

其他

{

试试

{

obj.pCODE = Convert.ToInt32(txtcode.Text);

obj.deleterec();



obj.bind( );

MessageBox.Show(LANGUAGE'+ txtcode.Text +'已删除');

}

catch(Exception ex)

{

MessageBox.Show(ex.Message);

}

}



}



private void btnew_Click(object sender,EventArgs e)

{

txtcode.Text =;

txtname.Text =;



}



private void nvcontrol_Load(object sender,EventArgs e)

{

dataGridView1.DataSource = obj.getlandata();

}



private void dataGridView1_CellEnter(object sender ,DataGridViewCellEventArgs e)

{

if(e.RowIndex> = 0)

{



dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

DataGridViewRow row = this.dataGridView1.Rows [e.RowIndex];

dataGridView1.ReadOnly = true;

txtcode.Text = row.Cells [CODE]。Value.ToString();

txtname.Text = row.Cells [NAME]。值。 ToString();



}

}



private void toolStripButton1_Click(对象发送者,EventArgs e)

{

obj.pCODE = Convert.ToInt32(txtsearch.Text);

obj.fin drec();

txtcode.Text = txtsearch.Text;

txtname.Text = obj.pNAME;



}



private void txtcode_KeyPress(object sender,KeyPressEventArgs e)

{

const char delete = (char)8;

e.Handled =!char.IsDigit(e.KeyChar)&& e.KeyChar!=删除;

}



private void toolStripButton2_Click(object sender,EventArgs e)

{

if(txtcode.Text ==)

{

MessageBox.Show(输入deatils);

}

其他

{

试试

{

obj.pCODE = Convert.ToInt32(txtcode.Text);

obj.pNAME = txtname.Text;

obj.insertrec();

MessageBox.Show(inserted);

obj.bind();

}

catch(异常) ex)

{

MessageBox.Show(ex.Message);

}



}



}



private void btnprint_Click(object sender,EventArgs e)

{

Form2 re = new Form2();

re.Show();



}

}

}









form2中的crystalreport代码

使用System;

使用System.Collections.Generic;

使用System.ComponentModel;

使用System.Data;

使用System.Drawing;

使用System.Linq ;

使用System.Text;

使用System.Windows.Forms;



使用_3TIERlanguage.DataSet1TableAdapters;



命名空间_3TIERlanguage

{

public partial class Form2:Form

{

public Form2()

{

InitializeComponent();

}



private void crystalReportViewer1_Load(object sender,EventArgs e)

{

DataSet1报告= new DataSet1();



DataSet1TableAdapters.language1TableAdapter la = new _3TIERlanguage.DataSet1TableAdapters.language1TableAdapter();

DataSet1.language1DataTable table = la .GetData();

report.SetDataSource(table.DefaultView);

crystalReportViewer1.ReportSource = report;

crystalReportViewer1.Refresh();





}



}

}

code in .cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DAL;
using BLL;

namespace _3TIERlanguage
{
public partial class nvcontrol : UserControl
{
bll obj = new bll();
public nvcontrol()
{
InitializeComponent();
}

// private void btnsave_Click(object sender, EventArgs e)
// {

// }

private void btnupdate_Click(object sender, EventArgs e)
{
if (txtcode.Text == "")
{
MessageBox.Show("enter code you want to updated");
}
else
{
try
{
obj.pCODE = Convert.ToInt32(txtcode.Text);
obj.pNAME = txtname.Text;
obj.updaterec();
MessageBox.Show("updated");
obj.bind();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

}

private void btndelete_Click(object sender, EventArgs e)
{
if (txtcode.Text == "")
{
MessageBox.Show("enter code you want to delete");
}
else
{
try
{
obj.pCODE = Convert.ToInt32(txtcode.Text);
obj.deleterec();

obj.bind();
MessageBox.Show("LANGUAGE '"+txtcode.Text+"'deleted");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

}

private void btnew_Click(object sender, EventArgs e)
{
txtcode.Text = "";
txtname.Text = "";

}

private void nvcontrol_Load(object sender, EventArgs e)
{
dataGridView1.DataSource = obj.getlandata();
}

private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0)
{

dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex];
dataGridView1.ReadOnly = true;
txtcode.Text = row.Cells["CODE"].Value.ToString();
txtname.Text = row.Cells["NAME"].Value.ToString();

}
}

private void toolStripButton1_Click(object sender, EventArgs e)
{
obj.pCODE = Convert.ToInt32(txtsearch.Text);
obj.findrec();
txtcode.Text = txtsearch.Text;
txtname.Text = obj.pNAME;

}

private void txtcode_KeyPress(object sender, KeyPressEventArgs e)
{
const char delete = (char)8;
e.Handled = !char.IsDigit(e.KeyChar)&&e.KeyChar!=delete;
}

private void toolStripButton2_Click(object sender, EventArgs e)
{
if (txtcode.Text == "")
{
MessageBox.Show("enter deatils");
}
else
{
try
{
obj.pCODE = Convert.ToInt32(txtcode.Text);
obj.pNAME = txtname.Text;
obj.insertrec();
MessageBox.Show("inserted");
obj.bind();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

}

}

private void btnprint_Click(object sender, EventArgs e)
{
Form2 re = new Form2();
re.Show();

}
}
}




code for crystalreport in form2
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using _3TIERlanguage.DataSet1TableAdapters;

namespace _3TIERlanguage
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

private void crystalReportViewer1_Load(object sender, EventArgs e)
{
DataSet1 report = new DataSet1();

DataSet1TableAdapters.language1TableAdapter la = new _3TIERlanguage.DataSet1TableAdapters.language1TableAdapter();
DataSet1.language1DataTable table = la.GetData();
report.SetDataSource(table.DefaultView);
crystalReportViewer1.ReportSource = report;
crystalReportViewer1.Refresh();


}

}
}

推荐答案

查看此

Crystal Reports - 报告文件路径无效 [ ^ ]


这篇关于水晶报告不起作用,在3层架构中显示错误无效报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆