| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2041 人关注过本帖
标题:[求助]如何自动生成流水号P001?
只看楼主 加入收藏
猫猫
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-1-25
收藏
 问题点数:0 回复次数:1 
[求助]如何自动生成流水号P001?

我有一个员工信息录入的界面,在点击“添加”后,我希望员工号如p001自动生成,请问应该怎么做?
我现在的员工号是和其它值一样,手动输入的。我声明了一个DataSet,把Employee表放入DatasetEmployee,然后在页面登录时,用da.Fill填充(this.DataSetEmployy,"Employee"),然后将DatasetEmployee和datagrid邦定,接下来将每个控件和DataSetEmployy里的列值邦定,那我现在要改员工号,请问应该怎么改呢?
我刚学,不是很懂,哪位大人帮小妹一下好吗,写的详细一点,我怕我不能理解,感激涕零T_T
public EmployeeManage()
{
InitializeComponent();//窗体自带的所有控件的构造函数
this.connectionStr="workstation id=localhost;Integrated Security=SSPI;database=Management";
this.selectStr="select * from Employee";
this.myConnection=new SqlConnection(connectionStr);
this.da1=new SqlDataAdapter(this.selectStr,this.myConnection);
//创建数据适配器
this.Command1=new SqlCommand();
this.Command1.Connection=this.myConnection;
}

private void EmployeeManage_Load(object sender, System.EventArgs e)
{
try
{
this.myConnection.Open();
this.da1.Fill(this.DataSetEmployy,"Employee");
}
catch(Exception E)
{
MessageBox.Show(E.ToString());
}
finally
{
this.myConnection.Close();
}
this.DataSet_Bingding();
}

private void DataSet_Bingding()//手动绑定,把数据集中的数据绑定到数据控件中
{
this.dg1_Employee.DataSource=this.DataSetEmployy;
this.dg1_Employee.DataMember="Employee";

this.textEmployeeID.DataBindings.Add("Text",this.DataSetEmployy,"Employee.EmployeeID");
this.textName.DataBindings.Add("Text",this.DataSetEmployy,"Employee.EmployeeName");
this.comboSex.DataBindings.Add("Text",this.DataSetEmployy,"Employee.Sex");
this.numericUpDown1.DataBindings.Add("Text",this.DataSetEmployy,"Employee.Age");
this.comboDepartment.DataBindings.Add("Text",this.DataSetEmployy,"Employee.Department");
this.comboTitle.DataBindings.Add("Text",this.DataSetEmployy,"Employee.Title");
this.comboDuty.DataBindings.Add("Text",this.DataSetEmployy,"Employee.Duty");
this.comboWorkType.DataBindings.Add("Text",this.DataSetEmployy,"Employee.WorkType");
this.comboDegree.DataBindings.Add("Text",this.DataSetEmployy,"Employee.Degree");
this.dateTimePicker1.DataBindings.Add("Text",this.DataSetEmployy,"Employee.InDate");
}

private void btnAdd_Click(object sender, System.EventArgs e)//添加
{
this.BindingContext[this.DataSetEmployy,"Employee"].AddNew();//在数据集中添加一行新的记录
}

搜索更多相关主题的帖子: 流水号 员工 Employee 自动 
2006-01-25 14:37
marer
Rank: 2
等 级:新手上路
威 望:3
帖 子:928
专家分:0
注 册:2005-7-18
收藏
得分:0 

在添加按钮点击事件里写:
private void button1_Click(object sender,EventArgs e)
{
this.txtEmpID.Text="p001";
......
}


public class 人生历程 extends Thread{public void run(){while(true){努力,努力,再努力!!;Thread.sleep(0);}}}
2006-01-26 10:52
快速回复:[求助]如何自动生成流水号P001?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011331 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved