c#代码.docx

上传人:b****3 文档编号:4262149 上传时间:2023-05-06 格式:DOCX 页数:131 大小:33.01KB
下载 相关 举报
c#代码.docx_第1页
第1页 / 共131页
c#代码.docx_第2页
第2页 / 共131页
c#代码.docx_第3页
第3页 / 共131页
c#代码.docx_第4页
第4页 / 共131页
c#代码.docx_第5页
第5页 / 共131页
c#代码.docx_第6页
第6页 / 共131页
c#代码.docx_第7页
第7页 / 共131页
c#代码.docx_第8页
第8页 / 共131页
c#代码.docx_第9页
第9页 / 共131页
c#代码.docx_第10页
第10页 / 共131页
c#代码.docx_第11页
第11页 / 共131页
c#代码.docx_第12页
第12页 / 共131页
c#代码.docx_第13页
第13页 / 共131页
c#代码.docx_第14页
第14页 / 共131页
c#代码.docx_第15页
第15页 / 共131页
c#代码.docx_第16页
第16页 / 共131页
c#代码.docx_第17页
第17页 / 共131页
c#代码.docx_第18页
第18页 / 共131页
c#代码.docx_第19页
第19页 / 共131页
c#代码.docx_第20页
第20页 / 共131页
亲,该文档总共131页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

c#代码.docx

《c#代码.docx》由会员分享,可在线阅读,更多相关《c#代码.docx(131页珍藏版)》请在冰点文库上搜索。

c#代码.docx

c#代码

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Text;

usingSystem.Data.SqlClient;

namespaceWindowsApplication1

{

classDBHelperr

{

privatestaticstringconnString="DataSource=.;InitialCatalog=Hefeifj;IntegratedSecurity=True";

publicstaticSqlConnectionconnection=newSqlConnection(connString);

}

}

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Windows.Forms;

namespaceWindowsApplication1

{

staticclassProgram

{

staticvoidMain()

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(newForm1());

}

}

usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Text;

usingSystem.Windows.Forms;

usingSystem.Data.Common;

usingSystem.Data.SqlClient;

namespaceWindowsApplication1

{

publicpartialclassForm1:

Form

{

privateDataSetdataSet=newDataSet();

privateSqlDataAdapterdataAdapter;

publicForm1()

{

InitializeComponent();

}

privatevoidForm1_Load(objectsender,EventArgse)

{

this.heFeiTableAdapter.Fill(this.hefeifjDataSet1.HeFei);

dataAdapter=newSqlDataAdapter(sql,DBHelperr.connection);

dataGridView1.DataSource=dataSet.Tables["House"];

}

privatevoidfillByToolStripButton_Click(objectsender,EventArgse)

{

try

{

this.heFeiTableAdapter.FillBy(this.hefeifjDataSet1.HeFei);

}

catch(System.Exceptionex)

{

System.Windows.Forms.MessageBox.Show(ex.Message);

}

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

this.Close();

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

if(ChatView())

{

stringsql="SELECT*FROMdbo.Housewhere";

{

Sql+=string.Format("CompoundNamelike'%{0}%'",textBox1.Text);

}

}

else

{

dataSet.Tables[0].Clear();

stringsql="select*fromdbo.House";

dataAdapter=newSqlDataAdapter(sql,DBHelperr.connection);

dataAdapter.Fill(dataSet);

dataGridView1.DataSource=dataSet.Tables[0];

textBox1.Text="";

textBox2.Text="";

}

}

privateboolChatView()

{

if(comboBox1.Text=="")

{

MessageBoxButtons.OK,MessageBoxIcon.Error);

comboBox1.Focus();

returnfalse;

}

}

}

}

usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Text;

usingSystem.Windows.Forms;

usingSystem.Data.Common;

usingSystem.Data.SqlClient;

namespaceWindowsApplication1

publicpartialclassHouseInfoForm:

Form

{

privateDataSetdataSet=newDataSet();

privateSqlDataAdapterdataAdapter;

publicHouseInfoForm()

{

InitializeComponent();

}

privatevoidHouseInfoForm_Load(objectsender,EventArgse)

{

stringsql="SELECTHourseID,HourseType,Area,Landlord,LandLordID,ExchangeType,LandLordTel,AddressFROMHouseInfo";

dataAdapter=newSqlDataAdapter(sql,DBHelperr.connection);

dataAdapter.Fill(dataSet,"HouseInfo");

dataGridView1.DataSource=dataSet.Tables["HouseInfo"];

}

privatevoidbntEnd_Click(objectsender,EventArgse)

{

this.Close();

}

privatevoidbntOk_Click(objectsender,EventArgse)

{

if(ChatView())

{

stringsql="SELECT*FROMHouseInfowhere";

{

sql+=string.Format("HourseTypelike'%{0}%'",txtText.Text);

}

{

sql+=string.Format("Area>={0}AndArea<={1}",(float)(Convert.ToDouble(txtText.Text)),(float)(Convert.ToDouble(txtText2.Text)));

}

{

sql+=string.Format("ExchangeTypelike'%{0}%'",txtText.Text);

}

else

{

sql+=string.Format("Addresslike'%{0}%'",txtText.Text);

}

dataSet.Tables.Clear();

dataAdapter=newSqlDataAdapter(sql,DBHelperr.connection);

dataAdapter.Fill(dataSet);

dataGridView1.DataSource=dataSet.Tables[0];

if(dataGridView1.SelectedCells.Count==0)

{

MessageBoxButtons.OK,MessageBoxIcon.Error);

}

}

else

{

dataSet.Tables[0].Clear();

stringsql="select*fromHouseInfo";

dataAdapter=newSqlDataAdapter(sql,DBHelperr.connection);

dataAdapter.Fill(dataSet);

dataGridView1.DataSource=dataSet.Tables[0];

txtText.Text="";

txtText2.Text="";

}

}

privatevoidtxtcob_TextChanged(objectsender,EventArgse)

{

{

this.label4.Visible=true;

this.txtText2.Visible=true;

}

else

{

this.label4.Visible=false;

this.txtText2.Visible=false;

}

}

privateboolChatView()

{

if(txtcob.Text=="")

{

MessageBoxButtons.OK,MessageBoxIcon.Error);

txtcob.Focus();

returnfalse;

}

{

if((txtText.Text=="")||(txtText2.Text==""))

{

MessageBoxButtons.OK,MessageBoxIcon.Error);

txtText.Focus();

returnfalse;

}

else

{

returntrue;

}

}

else

{

if(txtText.Text=="")

{

MessageBoxButtons.OK,MessageBoxIcon.Error);

txtText.Focus();

returnfalse;

}

else

{

returntrue;

}

}

}

}

usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Text;

usingSystem.Windows.Forms;

namespaceWindowsApplication2

{

publicpartialclassAboutForm:

Form

{

publicAboutForm()

{

InitializeComponent();

}

}

}

usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Text;

usingSystem.Windows.Forms;

usingSystem.Data.SqlClient;

namespaceWindowsApplication2

{

publicpartialclassClearForm:

Form

{

publicClearForm()

{

InitializeComponent();

}

DBHelperlinkdb=newDBHelper();

stringstrSelectAll="select*fromApplianceInfo.dbo.Appliance";

stringstrTable="Appliance";

DataSetds=newDataSet();

privatevoidclearForm_Load(objectsender,EventArgse)

{

dataGridView1.AutoGenerateColumns=false;

dataGridView1.AllowUserToAddRows=false;

dataGridView1.AlternatingRowsDefaultCellStyle.BackColor=Color.Azure;

//ds=DBHelper.(strSelectAll,strTable);

dataGridView1.DataSource=ds;

//dataGridView1.DataMember=strTable;

"DELETEFROMApplianceInfo.dbo.Appliance"

}

}

}

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Text;

usingSystem.Data.SqlClient;

namespaceWindowsApplication2

{

classDBHelper

{

privatestaticstringconnString="DataSource=.;InitialCatalog=ApplianceInfo;IntegratedSecurity=True";

publicstaticSqlConnectionconnection=newSqlConnection(connString);

}

}

uingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Text;

usingSystem.Windows.Forms;

mespaceWindowsApplication2

{

publicpartialclassfrmMain:

Form

{

publicfrmMain()

{

InitializeComponent();

}

privatevoidEsc_Click(objectsender,EventArgse)

{

MessageBoxButtons.YesNo,MessageBoxIcon.Question);

if(result==DialogResult.Yes)

{

Application.Exit();

}

}

privatevoidHelp_Click(objectsender,EventArgse)

{

AboutFormform=newAboutForm();

form.MdiParent=this;

form.Show();

}

{

ClearFormform=newClearForm();

form.MdiParent=this;

form.Show();

}

{

IncreaseFormform=newIncreaseForm();

form.MdiParent=this;

form.Show();

}

{

ClearFormform=newClearForm();

form.MdiParent=this;

form.Show();

}

{

TradeFromform=newTradeFrom();

form.MdiParent=this;

form.Show();

}

{

LoginFormform=newLoginForm();

form.MdiParent=this;

form.Show();

}

}

}

usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Text;

usingSystem.Windows.Forms;

usingSystem.Data.SqlClient;

namespaceWindowsApplication2

{

publicpartialclassIncreaseForm:

Form

{

publicIncreaseForm()

{

InitializeComponent();

}

voidbntQc_Click(objectsender,EventArgse)

{

this.txtName.Text="";

this.txtNo.Text="";

this.txtNum.Text="";

this.txtPrice.Text="";

this.txtWat.Text="";

this.txtAdssree.Text="";

}

privatevoidbntTC_Click(objectsender,EventArgse)

{

MessageBoxButtons.YesNo,MessageBoxIcon.Question);

if(result==DialogResult.Yes)

{

Application.Exit();

}

}

privateboolChatView()

{

if(txtName.Text.Trim()==""||txtNo.Text.Trim()==""||txtNum.Text.Trim()==""||txtPrice.Text.Trim()==""||txtWat.Text.Trim()==""||txtAdssree.Text.Trim()=="")

{

MessageBoxButtons.OK,MessageBoxIcon.Error);

returnfalse

}

else

{

returntrue;

}

}

privatevoidbntBC_Click(objectsender,EventArgse)

{

if(ChatView())

{

stringsql=string.Format(@"INSERTINTOAppliance

(Name

Type

Power

MadeIn

Price

Amount)

VALUES

('{0}',

'{1}',

'{2}',

'{3}',

'{4}',

'{5}')",Name,Type,Power,MadeIn,Price,Amount);

try

{

SqlCommandcmd=newSqlCommand(sql,DBHelper.connection);

DBHelper.connection.Open();

intrespol=cmd.ExecuteNonQuery();

if(respol!

=1)

{

MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

}

else

{

MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.txtName.Text="";

this.txtNo.Text="";

this.txtNum.Text="";

this.txtPrice.Text="";

this.txtWat.Text="";

this.txtAdssree.Text="";

}

}

catch

{

MessageBoxButtons.OK,MessageBoxIcon.Error);

}

finally

{

DBHelper.connection.Close();

}

}

}

}

usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Text;

usingSystem.Windows.Forms;

usingSystem.Data.SqlClient;

namespaceWindowsApplication2

{

publicpartialclassInquiryForm:

Form

{

privateDataSetdataSet=newDataSet();

privateSqlDataAdapterdataAdapter;

publicInquiryForm()

{

InitializeComponent();

}

privatevoidInquiryForm_Load(objectsender,EventArgse)

{this.applianceTableAdapter.Fill(this.applianceInfoDataSet.Appliance);

stringsql

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 表格模板 > 合同协议

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2