Files
lserp_cs_6.0/其他程序/mes_YzUsedby/Form1.cs
T
cyf ab56a9bcf7 基线 SVN r240
SVN-Revision: r240
2025-02-06 06:46:06 +00:00

125 lines
4.3 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace mes_BgManage
{
public partial class Form1 : Form
{
//不加@会报转义序列错误
SqlConnection conn = new SqlConnection(@"Data Source=115.238.74.182,19010;Initial Catalog=thwtest;User ID=lserpAdmin;Password=lserp110;");//创建数据库连接类的对象
public Form1()
{
InitializeComponent();
}
private System.Data.DataTable BgSqTable = new System.Data.DataTable();
private System.Data.DataTable BGSjTable = new System.Data.DataTable();
private System.Data.DataTable tmpTable = new System.Data.DataTable();
private void Form1_Load(object sender, EventArgs e)
{
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
}
private void gridControl1_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
string sql = "select DBO.p_Getbillid('8000301','') as Gdbillid ";
SqlDataAdapter TmpAdatper = new SqlDataAdapter(sql, conn);
tmpTable.Clear();
TmpAdatper.Fill(tmpTable);
string Gdbillid = tmpTable.Rows[0]["Gdbillid"].ToString();
string Gopname="管理员";
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "INSERT P_FixedAssetsDYTab(DYbilldocument_id,LProductid,JtID,operatename,operatedate) " +
"select '" + Gdbillid + "','" + BgSqTable.Rows[gridView1.FocusedRowHandle]["productid"].ToString() + "',1, '" + Gopname + "',getdate()";
cmd.ExecuteNonQuery();
string jtwz="GA";
cmd.CommandText = "UPDATE P_FixedAssetsMlTab SET ZtTig=2,jtwz='" + jtwz + "' where ProductId='" + BgSqTable.Rows[gridView1.FocusedRowHandle]["productid"].ToString() + "' ";
int i = i = cmd.ExecuteNonQuery();
if (i > 0) { MessageBox.Show("操作成功"); }
button3.PerformClick();
}
private void Form1_Shown(object sender, EventArgs e)
{
button3.PerformClick();
//下方产生一个表
//DataSet ds = new DataSet();
//MyAdatper.Fill(ds);
//gridControl1.DataSource = ds;
}
private void button2_Click(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
string Gproductid = "CZ000045";
string sql = "select ZtTig,a.ProductId,a.Appellation,a.spec,a.model,originbill,mc,case when ZtTig=1 then wz else jtwz end as wz from P_FixedAssetsMlTab " +
"a join p_ProductTab b on a.SbBillid=b.GbProductidA left join P_BgZtView c on a.ZtTig=c.dm where b.ProductId='" + Gproductid + "' ";
SqlDataAdapter MyAdatper = new SqlDataAdapter(sql, conn);
BgSqTable.Clear();
MyAdatper.Fill(BgSqTable);
gridControl1.DataSource = BgSqTable;
sql = "select b.ProductId,a.id,tigid,Appellation,model,cast(tigid as bit) as tigid1 from P_FixedAssetsDYTab a join P_FixedAssetsMlTab b on a.lproductid=b.ProductId where JtID=1 and tigid<2 and Redid=0 ";
MyAdatper = new SqlDataAdapter(sql, conn);
BGSjTable.Clear();
MyAdatper.Fill(BGSjTable);
gridControl2.DataSource = BGSjTable;
}
private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
{
string zttig= BgSqTable.Rows[gridView1.FocusedRowHandle]["ZtTig"].ToString();
if (zttig == "2")
{button1.Enabled=false;}
else
{ button1.Enabled=true;}
}
private void gridControl2_Click(object sender, EventArgs e)
{
}
}
}