问题描述
有没有用动软.NET+C#做项目的啊我用了,结果无法往表里添加数据有谁帮帮忙啊主类mainForm如下:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;usingBSMS.WinForm;usingBSMS.Employee;namespaceBSMS{publicpartialclassForm1:Form{publicForm1(){InitializeComponent();}privatevoid今日销售情况ToolStripMenuItem_Click(objectsender,EventArgse){}privatevoidForm1_Load(objectsender,EventArgse){}privatevoidpictureBox3_Click(objectsender,EventArgse){TimeStatForm1Dialog=newTimeStat();Form1Dialog.ShowDialog();}privatevoidsplitContainer2_Panel2_Paint(objectsender,PaintEventArgse){}privatevoidEmployeeAddButton_Click(objectsender,EventArgse){EmployeeAddFormEmployeeAdd=newEmployeeAddForm();EmployeeAdd.TopLevel=false;EmployeeAdd.Visible=true;this.splitContainer2.Panel2.Controls.Add(EmployeeAdd);}}}我的employee类如下:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;namespaceBSMS.Employee{publicpartialclassEmployeeAddForm:Form{BSMS.Model.employeesnailEdit=null;publicEmployeeAddForm(){InitializeComponent();}privatevoidEmlpoyeeAddForm_Load(objectsender,EventArgse){textboxEAcc.Text=snailEdit.EAccount;textBoxEName.Text=snailEdit.EName;comboBoxESex.Text=snailEdit.ESex;textBoxEAddress.Text=snailEdit.EAddress;textBoxEMTel.Text=Convert.ToString(snailEdit.EMobileTel);textBoxEEmail.Text=snailEdit.EEmail;dateTimePicker1.Value=snailEdit.ERegDate;}privatevoidbuttonEAddOK_Click(objectsender,EventArgse){if(textboxEAcc.Text.Trim()==""){MessageBox.Show("帐号不能为空!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);textboxEAcc.Select();return;}if(textBoxEName.Text.Trim()==""){MessageBox.Show("姓名不能为空!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);textBoxEName.Select();return;}if(textBoxEMTel.Text.Trim()==""){MessageBox.Show("移动电话不能为空!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);textBoxEMTel.Select();return;}if(comboBoxESex.Text.Trim()==""){MessageBox.Show("性别不能为空!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);comboBoxESex.Select();return;}BSMS.Model.employeesnailModel=newBSMS.Model.employee();BSMS.BLL.employeesnailBLL=newBSMS.BLL.employee();snailModel.EAccount=textboxEAcc.Text.Trim();snailModel.EName=textboxEAcc.Text.Trim();snailModel.ESex=comboBoxESex.Text.Trim();snailModel.EAddress=textBoxEAddress.Text.Trim();snailModel.ETel=Convert.ToInt16(textBoxETel.Text.Trim());snailModel.EMobileTel=Convert.ToInt16(textBoxEMTel.Text.Trim());snailModel.EEmail=textBoxEEmail.Text.Trim();snailModel.ERegDate=dateTimePicker1.Value;snailBLL.Add(snailModel);this.Close();BSMS.BLL.employeeEInsert=newBSMS.BLL.employee();DataSetdata=EInsert.GetAllList();if(data.Tables[0].Rows.Count==0){return;}textboxEAcc.Text=data.Tables[0].Rows[0]["EAccount"].ToString();textBoxEName.Text=data.Tables[0].Rows[0]["EName"].ToString();comboBoxESex.Text=data.Tables[0].Rows[0]["ESex"].ToString();textBoxEMTel.Text=data.Tables[0].Rows[0]["EMTel"].ToString();textBoxEAddress.Text=data.Tables[0].Rows[0]["EAddress"].ToString();textBoxEEmail.Text=data.Tables[0].Rows[0]["EEmail"].ToString();dateTimePicker1.Value=Convert.ToDateTime(data.Tables[0].Rows[0]["ERegDate"]);}privatevoidEmployeeAddForm_Load(objectsender,EventArgse){//TODO:这行代码将数据加载到表“BSMSDataSet.employee”中。您可以根据需要移动或移除它。this.employeeTableAdapter.Fill(bSMSDataSet.employee);}privatevoidEAddCancel_Click(objectsender,EventArgse){this.Close();}}}
解决方案
解决方案二:
补充下问题还有有谁知道用动软生成代码以后,应该如何连接数据库才是正确的啊
解决方案三:
我还忘记一点了我添加的消息提示框怎么也弹不出来,是什么问题我刚刚接触C#谢谢大家