
2.设定全局变量:
MySqlConnection conn
MySqlDataAdapter adapter
MySqlTransaction trans
3. // 数据库联接
private System.Data.DataTable dbconn(string strSql)
{
string strconn = "host=localhostdatabase=testuser id=rootpassword="
conn = new MySqlConnection()
conn.ConnectionString = strconn
conn.Open()
this.adapter = new MySqlDataAdapter(strSql, conn)
System.Data.DataTable dtSelect = new System.Data.DataTable()
int rnt=this.adapter.Fill(dtSelect)
conn.Close()
return dtSelect
}
4. //设定DataGridView的样式
private void setDgStyle()
{
this.dgselect.Columns.Clear()
DataGridViewCheckBoxColumn colDel = new DataGridViewCheckBoxColumn()
colDel.DataPropertyName = "Del"
colDel.Name = "Del"
colDel.Selected = false
colDel.FalseValue = "0"
colDel.TrueValue = "1"
colDel.Width = 40
colDel.SortMode = DataGridViewColumnSortMode.NotSortable
colDel.HeaderText = "删除"
colDel.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
colDel.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
this.dgselect.Columns.Insert(0, colDel)
DataGridViewTextBoxColumn colID = new DataGridViewTextBoxColumn()
colID.DataPropertyName = "ProductsSpecID"
colID.Name = "ProductsSpecID"
colID.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
colID.HeaderText = "产品规格ID"
colID.Width = 160
this.dgselect.Columns.Insert(1, colID)
DataGridViewTextBoxColumn colNM = new DataGridViewTextBoxColumn()
colNM.DataPropertyName = "ProductsSpec"
colNM.Name = "ProductsSpec"
colNM.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
colNM.HeaderText = "产品规格名称"
colNM.Width = 160
this.dgselect.Columns.Insert(2, colNM)
DataGridViewTextBoxColumn colUnit = new DataGridViewTextBoxColumn()
colUnit.DataPropertyName = "ProductsSpecUnit"
colUnit.Name = "ProductsSpecUnit"
colUnit.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
colUnit.HeaderText = "产品规格单位"
colUnit.Width = 180
this.dgselect.Columns.Insert(3, colUnit)
DataGridViewTextBoxColumn colPID = new DataGridViewTextBoxColumn()
colPID.DataPropertyName = "ProductsID"
colPID.Name = "ProductsID"
colPID.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
colPID.HeaderText = "产品ID"
colPID.Width = 140
this.dgselect.Columns.Insert(4, colPID)
DataGridViewButtonColumn colButton = new DataGridViewButtonColumn()
colButton.DataPropertyName = "colSearch"
colButton.Name = "colSearch"
colButton.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
colButton.HeaderText = "Button"
colButton.Width = 80
this.dgselect.Columns.Insert(5, colButton)
this.dgselect.RowHeadersWidth = 15
this.dgselect.ColumnHeadersDefaultCellStyle.Font=new System.Drawing.Font("宋体",14)
}
5. //修改数据,并将数据提交到数据库
private Boolean dbUpdate()
{
string strSql = "select ProductsSpecID,ProductsSpec,ProductsSpecUnit,ProductsID from tbl_product_detail_master"
System.Data.DataTable dtUpdate = new System.Data.DataTable()
dtUpdate = this.dbconn(strSql)
dtUpdate.Rows.Clear()
System.Data.DataTable dtShow = new System.Data.DataTable()
//dtShow = (DataTable)this.bindSource.DataSource
dtShow = (System.Data.DataTable)this.dgselect.DataSource
int p1 = dtShow.Rows.Count
// try
// {
for (int i = 0i <dtShow.Rows.Counti++)
{
DataRowState rowState=new DataRowState()
rowState=dtShow.Rows[i].RowState
if (rowState==DataRowState.Added || rowState==DataRowState.Detached || rowState==DataRowState.Modified)
{
if (this.dgselect["Del", i].Value.ToString() == "1")
{
dtShow.Rows[i].Delete()
}
}
}
for (int i = 0i <dtShow.Rows.Counti++)
{
dtUpdate.ImportRow(dtShow.Rows[i])
}
int num = dtUpdate.Rows.Count
try
{
this.conn.Open()
trans = this.conn.BeginTransaction()
MySqlCommandBuilder CommandBuiler
CommandBuiler = new MySqlCommandBuilder(this.adapter)
this.adapter.Update(dtUpdate)
trans.Commit()
this.conn.Close()
}
catch ( Exception ex)
{
MessageBox.Show(ex.Message.ToString())
trans.Rollback()
return false
}
dtUpdate.AcceptChanges()
return true
}
代理程序 来源于 web-proxy-master 基于node做的代理服务器
nodejs在windows上运行 ,运行命令如下,启动起来的地址是 http://localhost:6001/ ( localhost = 192.168.0.105)
在200上的linux中的/davido/project/nginx-1.17.10_prefix中conf/host/localhost_6066.conf配置以下参数
重启nginx后,在程序中配置天地图访问代理路径为 "proxy": " http://192.168.0.200:6066/proxy/ ",
可以在web页面上看到天地图已经加载出来了。
现在尝试把代理服务器部署到linux上,以下是 *** 作的步骤
参考链接地址为 nodejs 在linux上后台运行
和 linux下使用forever进行管理
linux 提前已经安装nodejs ,路径是/davido/local/ds/nodejs/
出错了, -bash: forever: command not found ,需设置环境变量
forever 管理
修改nginx中代理配置,修改成 http://192.168.0.200:6001 ,把200服务器上的6001端口放开,代理没起作用;
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)