javascript
----------------------------------------
<!--
function GetValue(str_id,str_no,str_name){
document.all("Txt_NO").value=str_no
document.all("Txt_Name").value=str_name
document.all("Txt_Id").value=str_id
document.all("Txt_oldNo").value=str_no
document.all("Txt_oldName").value=str_name
document.all("Cmd_Add").disabled=false
document.all("Cmd_Upt").disabled=false
document.all("Cmd_Del").disabled=false
}
----------------------------------------
<!--
function GetValue(str_id,str_no,str_name){
document.all("Txt_NO").value=str_no
document.all("Txt_Name").value=str_name
document.all("Txt_Id").value=str_id
document.all("Txt_oldNo").value=str_no
document.all("Txt_oldName").value=str_name
document.all("Cmd_Add").disabled=false
document.all("Cmd_Upt").disabled=false
document.all("Cmd_Del").disabled=false
}
e.Item.Attributes.Add("Onmouseover", "this.style.backgroundColor='#ccffff';this.style.color='buttontext';this.style.cursor='default';")
Dim x As String
x = "javascript:GetValue" & "(""" & e.Item.Cells(0).Text & """,""" & e.Item.Cells(1).Text & """,""" & e.Item.Cells(2).Text & """)"
e.Item.Attributes.Add("onclick", x)
Call mbln_EnableSet(0) End If
---------------------------------------
If e.Item.ItemType <> ListItemType.Header And e.Item.ItemType <> ListItemType.Footer Then
'Response.Write(Color.Beige.ToString())
'e.Item.Attributes("id") = e.Item.ItemType.ToString() + e.Item.ItemIndex.ToString()
e.Item.Attributes.Add("OnMouseOut", "this.style.backgroundColor='#FFF7E7';this.style.color='#8C4510'")
e.Item.Attributes.Add("OnMouseOver", "this.style.backgroundColor='#A55129';this.style.color='white';this.style.cursor='hand';")
e.Item.Attributes.Add("Ondblclick", "javascript:setv(" + e.Item.Cells(0).Text + ")")
End If
End Sub
这是我以前第一次写代码做的 也许是乱了点 但基本的东西都在里面 希望对你有帮助
我的处女作哦 :)
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.IO;
using System.Configuration;
using System.Data.SqlClient;
namespace testsys.chenbenRpt
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WFfms : System.Web.UI.Page
{
//SqlConnection Conn=new SqlConnection("server = 192.168.1.237;database = newfms;uid = webfms_1;password = *864web1;Timeout = 5000");
public CRfms Arth = new CRfms(); protected System.Web.UI.HtmlControls.HtmlGenericControl DIV1;
protected System.Web.UI.HtmlControls.HtmlGenericControl DIV2;
protected System.Web.UI.HtmlControls.HtmlGenericControl DIV3;
protected System.Web.UI.HtmlControls.HtmlGenericControl DIV4;
protected System.Web.UI.HtmlControls.HtmlGenericControl DIV5;
protected System.Web.UI.HtmlControls.HtmlGenericControl DIV6;
protected System.Web.UI.HtmlControls.HtmlGenericControl DIV7;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.TextBox TextBox4;
protected System.Web.UI.WebControls.TextBox TextBox5;
protected System.Web.UI.WebControls.TextBox TextBox6;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Button2;
string message ;
string flag ;
protected System.Web.UI.WebControls.ListBox bmlist;
protected System.Web.UI.WebControls.DropDownList DDbm;
string dflag ;
protected System.Web.UI.HtmlControls.HtmlGenericControl DIV8;
protected System.Web.UI.HtmlControls.HtmlGenericControl DIV9;
protected System.Web.UI.WebControls.DropDownList DDLdate;
protected System.Web.UI.WebControls.TextBox TextBox3;
protected System.Web.UI.HtmlControls.HtmlGenericControl DIV10;
protected System.Web.UI.WebControls.DropDownList DDLc;
Service1 fms = new Service1();
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
TextBox1.Text=DateTime.Now.ToShortDateString();
TextBox2.Text=DateTime.Now.ToShortDateString();
TextBox3.Text=DateTime.Now.ToShortDateString();
TextBox3.BackColor=Color.Silver;
TextBox3.ReadOnly=true;
DDLdate.BackColor=Color.Silver;
DDLdate.Enabled = false;
addDDbm(); }
// 在此处放置用户代码以初始化页面
} #region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.TextBox1.TextChanged += new System.EventHandler(this.TextBox1_TextChanged);
this.TextBox2.TextChanged += new System.EventHandler(this.TextBox2_TextChanged);
this.TextBox4.TextChanged += new System.EventHandler(this.TextBox4_TextChanged);
this.TextBox5.TextChanged += new System.EventHandler(this.TextBox5_TextChanged);
this.TextBox6.TextChanged += new System.EventHandler(this.TextBox6_TextChanged);
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Button2.Click += new System.EventHandler(this.Button2_Click);
this.DDbm.SelectedIndexChanged += new System.EventHandler(this.DDbm_SelectedIndexChanged);
this.DDLc.SelectedIndexChanged += new System.EventHandler(this.DDLc_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion
protected void AddHtml(string addstr)
{
message=addstr;
}
protected override void Render(HtmlTextWriter output)
{
base.Render(output);
output.Write(message);
message="";
}
private void DDLc_SelectedIndexChanged(object sender, System.EventArgs e)
{
string isintype = DDLc.Items[DDLc.SelectedIndex].Value.ToString().Trim();
if(isintype == "Y")
{
TextBox1.Text=DateTime.Now.ToShortDateString();
TextBox2.Text=DateTime.Now.ToShortDateString();
TextBox3.BackColor = Color.Silver;
TextBox3.ReadOnly = true;
DDLdate.BackColor=Color.Silver;
DDLdate.Enabled = false;
TextBox1.BackColor = Color.White;
TextBox2.BackColor = Color.White;
TextBox1.ReadOnly = false;
TextBox2.ReadOnly = false;
DDbm.BackColor=Color.White;
DDbm.Enabled = true; }
if(isintype == "N")
{
TextBox1.BackColor = Color.Silver;
TextBox2.BackColor = Color.Silver;
TextBox1.ReadOnly = true;
TextBox2.ReadOnly = true;
TextBox3.BackColor = Color.White;
TextBox3.ReadOnly = false;
DDLdate.BackColor=Color.White;
DDLdate.Enabled = true;
DDbm.BackColor=Color.Silver;
DDbm.Enabled = false;
}
}
private void Button1_Click(object sender, System.EventArgs e)
{
string fdate = TextBox1.Text.ToString().Trim();
string tdate = TextBox2.Text.ToString().Trim();
string div = DDbm.Items[DDbm.SelectedIndex].ToString().Trim();
string job = TextBox4.Text.ToString().Trim();
string item = TextBox5.Text.ToString().Trim();
string color = TextBox6.Text.ToString().Trim();
string type= DDLdate.Items[DDLdate.SelectedIndex].Value.ToString().Trim();
string todate = TextBox3.Text.ToString().Trim();
string isintype = DDLc.Items[DDLc.SelectedIndex].Value.ToString().Trim();// string flag = DropDownList1.SelectedValue.ToString().Trim();
// string dflag = DropDownList2.SelectedValue.ToString().Trim();
if(isintype == "N")
{
fdate = "";
tdate = "";
flag = "y";
dflag = "y";
}
else
{
type = "%";
if(fdate == "" && tdate == "")
{
flag = "y";
}
else
{
fdate = TextBox1.Text.ToString().Trim();
flag ="n";
} if(div == "ALL")
{
dflag = "y";
}
else
{
div = DDbm.Items[DDbm.SelectedIndex].ToString().Trim();
dflag = "n";
}
}
if( item.Trim() == null || item.Trim() == "")
{
item = "%";
} if( color.Trim() == null || color.Trim() == "")
{
color = "%";
}
if( job.Trim() == null || job.Trim() == "")
{
job = "%";
}
if( todate.Trim() == null || todate.Trim() == "")
{
todate = "2049-12-30";
}
// string sql = "exec usp_cost_count_sum_stk '2001.01.01','2005.01.01','dsd','n','y','ydrl03/607501','%','%'";
// ydrl03/607501
string sql =
"exec usp_cost_count_sum_stk '"
+ fdate + "','" + tdate + "','" + div
+ "','" + flag + "','" + dflag + "','"
+ job + "','" + item + "','" + color + "','"+todate+"','"+type+"','"+isintype+"'"; SqlCommand comm = new SqlCommand(sql,fms.sysConn());
comm.CommandTimeout = 180;
SqlDataAdapter da = new SqlDataAdapter(comm);
DataSet ds = new DataSet();
try
{
da.Fill(ds, "chengben");
}
catch(Exception er)
{
Response.Write(er.Message);
Response.End();
}//
// DataTable dte=new DataTable();
// da.Fill(dte);
// string status = dte.Rows[0][21].ToString();
//
// if(status == "000"||status == "FIN")
// {
// string = "0";
// string = "0";
// string = "0";
// } if(item == "%")
{
item = "全部";
}
if(color == "%")
{
color = "全部";
}
if(job == "%")
{
job = "全部";
} if(fdate == "" && tdate == "")
{
fdate = "全部";
tdate = "";
} if(div == "ALL")
{
div = "全部";
}
else
{
string strselect="select short_name from v_sup where supplier_code like '"+div+"'";
SqlDataAdapter sd=new SqlDataAdapter(strselect,fms.sysConn());
DataTable dt=new DataTable();
sd.Fill(dt);
div = dt.Rows[0][0].ToString();
}
if(type == "%")
{
type = "全部";
}
if(type == "AY")
{
type = "全部纱";
}
if(type == "AF")
{
type = "全部布";
}
if(type == "GY")
{
type = "胚纱";
}
if(type == "SY")
{
type = "色纱";
}
if(type == "HY")
{
type = "花纱";
}
if(type == "GF")
{
type = "胚布";
}
if(type == "SF")
{
type = "色布";
}
if(type == "GF1")
{
type = "胚扁机";
}
if(type == "SF1")
{
type = "色扁机";
}
if(isintype == "Y")
{
todate = "全部";
} if (ds.Tables[0].Rows.Count>0)
{
Arth.SetDataSource(ds.Tables[0]);
// 声明变量并获取导出选项。
ExportOptions exportOpts = new ExportOptions();
DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
exportOpts = Arth.ExportOptions;
// 设置导出格式。
exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat;// ExportFormatType.PortableDocFormat;
exportOpts.ExportDestinationType = ExportDestinationType.DiskFile; // 设置磁盘文件选项。
string pdfname="XIAOCHAO"+DateTime.Now.ToShortDateString()+"_"+DateTime.Now.ToLongTimeString().Replace(":","-")+"_"+DateTime.Now.Millisecond.ToString()+".pdf";
diskOpts.DiskFileName = Server.MapPath("PDF/"+pdfname);
exportOpts.DestinationOptions = diskOpts; //传送参数
ParameterValues paramValues=new ParameterValues();
//定义参数
ParameterDiscreteValue discreteVal = new ParameterDiscreteValue();//
discreteVal.Value = fdate;
paramValues.Add(discreteVal);
discreteVal = new ParameterDiscreteValue();//
discreteVal.Value = tdate;
paramValues.Add(discreteVal);
discreteVal = new ParameterDiscreteValue();//
discreteVal.Value = div;
paramValues.Add(discreteVal);
discreteVal = new ParameterDiscreteValue();//
discreteVal.Value = job;
paramValues.Add(discreteVal);
discreteVal = new ParameterDiscreteValue();//
discreteVal.Value = item;
paramValues.Add(discreteVal);
discreteVal = new ParameterDiscreteValue();//
discreteVal.Value = color;
paramValues.Add(discreteVal);
discreteVal = new ParameterDiscreteValue();//
discreteVal.Value = todate;
paramValues.Add(discreteVal);
discreteVal = new ParameterDiscreteValue();//
discreteVal.Value = type;
paramValues.Add(discreteVal);
//将参数
discreteVal.Kind =DiscreteOrRangeKind.DiscreteValue;
ParameterValues paramValue = new ParameterValues();
for(int i = 0; i <= paramValues.Count - 1; i++)
{
paramValue.Clear();
paramValue.Add(paramValues[i]);
Arth.DataDefinition.ParameterFields[i].ApplyCurrentValues(paramValue);
}
// 导出报表。
Arth.Export();
try
{
Response.Write("<script>window.open('PDF/"+pdfname+"');history.go(-1);</script>");
}
catch(Exception err)
{
Response.Write(err.Message );
}
}
else
{
AddHtml("<script>{alert('没有记录,请重新输入查询条件!');}</script>");
//
Response.Write("<script>alert('没有数据,请重新输入查询条件!');window.history.go(-1);</script>");
Response.End();
}
Response.End ();
da.Dispose();
ds.Dispose();
fms.sysConn().Close();
} private void Button2_Click(object sender, System.EventArgs e)
{
TextBox1.Text = DateTime.Now.ToShortDateString().ToString();
TextBox2.Text = DateTime.Now.ToShortDateString().ToString();
TextBox3.Text = DateTime.Now.ToShortDateString().ToString();
addDDbm();
TextBox4.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
}
private void addDDbm()
{
ArrayList list=new ArrayList();
string strsele="select supplier_code from v_sup";
SqlDataAdapter ds =new SqlDataAdapter(strsele,fms.sysConn());
DataTable dt=new DataTable();
ds.Fill(dt);
list.Add("ALL");
for (int i=0;i<dt.Rows.Count ;i++)
list.Add(dt.Rows[i][0]);
this.DDbm.DataSource=list;
this.DDbm.DataBind();
}
}
内容 你没复制我的代码吗?
应该:
AutoGenerateColumns="False" 这个代表不要自动生成的列
----------------------------------------------------------------
原贴内容:
兄台,你的那个是用墨版列做的,我做了以后本来应该是3列可是显示的是6列,好像datagrid默认的有3列,怎么去掉呢?
编号: 20 发送者 goody9807 发送时间 2004-8-26 17:03:50 删除 回复
内容
又给你做了一个带隐藏列的 给你发过去了 !
编号: 19 发送者 goody9807 发送时间 2004-8-26 15:10:59 删除 回复
内容 好的 我把那个工程修改一下
----------------------------------------------------------------
原贴内容:
----------------------------------------------------------------
原贴内容:
我没做隐藏列
你想要隐藏第几列
----------------------------------------------------------------
随便哪一列,最好是第一列,而且单击时Getvalue可以得到它的值,现在比较困惑~
编号: 18 发送者 goody9807 发送时间 2004-8-26 14:39:46 删除 回复
内容 我没做隐藏列
你想要隐藏第几列
----------------------------------------------------------------
原贴内容:
偶打开了,但是Dim d As New Data()出错了说没有定义另外,兄台,你给偶的代码能实现隐藏列吗?偶试了试,好像不行~但击得到值的那个偶已经实现了~
编号: 17 发送者 goody9807 发送时间 2004-8-26 14:13:45 删除 回复
内容 你直接把vbproj 然后另存为到一个新的sln里面不行吗
----------------------------------------------------------------
原贴内容:
打不开呀,把你的.sln文件发给偶呀~兄台`、 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
---------------------------------------------------------------------
再次感谢goody9807