ab56a9bcf7
SVN-Revision: r240
240 lines
11 KiB
C#
240 lines
11 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 Lskj.Control;
|
||
using Lskj.Core;
|
||
using Lskj.Util;
|
||
using Lskj.Data;
|
||
using Lskj.Business.Impl;
|
||
using System.Data.SqlClient;
|
||
|
||
|
||
namespace WindowsFormsApplication2
|
||
{
|
||
public partial class FrmMain : BaseForm
|
||
{
|
||
public DynamicDemoModel Model;
|
||
public TextBox t1 { get { return textBox1; } }
|
||
public TextBox t2 { get { return textBox2; } }
|
||
|
||
public FrmMain()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
private System.Data.DataTable BgSqTable = new System.Data.DataTable();
|
||
private System.Data.DataTable BGSjTable = new System.Data.DataTable();
|
||
private System.Data.DataTable BGXjTable = new System.Data.DataTable();
|
||
private System.Data.DataTable tmpTable = new System.Data.DataTable();
|
||
|
||
/**
|
||
* 说明如下:ss
|
||
* 开发环境:采用Vs2010开发环境
|
||
* 调用.net程序支持2种模式:1、调用exe 2、调用dll类库
|
||
*
|
||
* 1、调用exe方式:无需建立DllBaseClass.cs参数类,直接建立exe程序即可。参数通过入口参数提取。
|
||
* 2、调用dll方式: 需要建立DllBaseClass.cs参数类,需要注意类名称必须为DllBaseClass,具体参考DllBaseClass.cs方法,基本上通用。
|
||
*
|
||
* 通用设置:
|
||
* 建立窗口需要继承BaseForm窗口,同时引入6个公共dll程序(Lskj.Business.dll、Lskj.Control.dll、Lskj.Core.dll、Lskj.Data.dll、Lskj.Model.dll、Lskj.Util.dll)
|
||
* 此窗口在Lskj.Control.dll中,前提需要安装DevExpress15.2版本。
|
||
* Lskj.Business.dll 所有业务处理类库,以及访问数据库操作类
|
||
* Lskj.Core.dll 数据库连接创建类库
|
||
* Lskj.Data.dll 存放资源文件以及所有提示信息
|
||
* Lskj.Model.dll 存放公用的业务对象Model
|
||
* Lskj.Util.dll 存放所有常用操作类
|
||
*
|
||
* 下面展示一下怎么创建连接获取数据等
|
||
**/
|
||
|
||
/// <summary>
|
||
/// <para>说明:窗口加载时调用</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期: </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
private void FrmMain_Load(object sender, EventArgs e)
|
||
{
|
||
// 检查数据库连接
|
||
if (!DBConfig.Instance.CreateConnection())
|
||
{
|
||
MessageUtil.Show(ResourceKeys.UnConnectServer);
|
||
return;
|
||
}
|
||
// 检查delphi连接
|
||
if (DelphiHelper.Delphi_Init(new StringBuilder(DBConfig.Instance.GetDelphiConnection())) == 0)
|
||
{
|
||
MessageUtil.Show(ResourceKeys.UnConnectServer + "[By Delphi]");
|
||
return;
|
||
}
|
||
|
||
// 访问数据库开始操作,所有公共操作在BaseImpl类里面,下面还有很多继承类
|
||
string sqlValue = "select * from p_systemtab";
|
||
DataTable tmpTable = BaseImpl.GetDataTableResult(sqlValue);
|
||
|
||
// MessageUtil.Show(table.Rows.Count + "");
|
||
this.Text = tmpTable.Rows[0]["ClientName"].ToString();
|
||
textBox3.Text = DllBaseClass.DyBgModel;
|
||
dateadd();
|
||
|
||
|
||
}
|
||
|
||
private void dateadd()
|
||
{
|
||
string leftstr=DllBaseClass.Gproductid.Substring(0,2);
|
||
string sql = "";
|
||
if (leftstr == "YP")
|
||
{
|
||
|
||
sql = "select OriginBill,ZtTig,a.ProductId,a.Appellation,a.spec,b.model,originbill,mc,case when ZtTig=1 then wz else jtwz end as wz from P_FixedAssetsMlTab " +
|
||
" a left join P_BgZtView c on a.ZtTig=c.dm join ( select case when ISNULL(SjProductid,'')<>'' then SjProductid else ProductId end as GbProductidA,model " +
|
||
" from p_ProductTab a where (left(a.ProductId,2)='BG') AND ( a.model='" + textBox3.Text + "') and (a.model<>'') ) b on a.SbBillid=b.GbProductidA ";
|
||
}
|
||
else
|
||
{
|
||
if (leftstr == "CB")
|
||
{
|
||
|
||
sql = "select OriginBill,ZtTig,a.ProductId,a.Appellation,a.spec,b.model,originbill,mc,case when ZtTig=1 then wz else jtwz end as wz from P_FixedAssetsMlTab " +
|
||
" a left join P_BgZtView c on a.ZtTig=c.dm join ( select ProductId,case when ISNULL(SjProductid,'')<>'' then SjProductid else ProductId end as GbProductidA,model " +
|
||
" from p_ProductTab a where (left(a.ProductId,2)='BG') ) b on a.SbBillid=b.GbProductidA join p_ProductTab d on b.ProductId=d.GbProductidA where d.ProductId='" + DllBaseClass.Gproductid + "' ";
|
||
}
|
||
else
|
||
{
|
||
label1.Visible = false;
|
||
textBox3.Visible = false;
|
||
sql = "select OriginBill,ZtTig,a.ProductId,a.Appellation,a.spec,b.model,originbill,mc,case when ZtTig=1 then wz else jtwz end as wz from P_FixedAssetsMlTab " +
|
||
" a join ( select case when ISNULL(b.SjProductid,'')<>'' then b.SjProductid else b.ProductId end as GbProductidA,b.model from ( " +
|
||
" SELECT bom_cbl_productid FROM Bom_CoBillMainTab a join Bom_CoBillListTab b on a.bom_cbm_billdocument_id=b.bom_cbl_billdocument_id " +
|
||
" where bom_cbm_clientid=" + DllBaseClass.Clientid + " and bom_cbm_productid='" + DllBaseClass.Gproductid + "' and left(bom_cbl_productid,2)='BG') a join p_ProductTab b on a.bom_cbl_productid=b.ProductId ) b " +
|
||
" on a.SbBillid=b.GbProductidA left join P_BgZtView c on a.ZtTig=c.dm ";
|
||
}
|
||
}
|
||
|
||
BgSqTable = BaseImpl.GetDataTableResult(sql);
|
||
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='" + DllBaseClass.Gjtid + "' and tigid<2 and Redid=0 ";
|
||
BGSjTable = BaseImpl.GetDataTableResult(sql);
|
||
gridControl2.DataSource = BGSjTable;
|
||
|
||
sql = "select a.id,tigid,Appellation,model,LProductid from P_FixedAssetsDYTab a join P_FixedAssetsMlTab b on a.lproductid=b.ProductId where JtID='" + DllBaseClass.Gjtid + "' and tigid=2 ";
|
||
BGXjTable = BaseImpl.GetDataTableResult(sql);
|
||
gridControl3.DataSource = BGXjTable;
|
||
|
||
}
|
||
|
||
|
||
private void button1_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
string sql="INSERT P_FixedAssetsDYTab(DYbilldocument_id,LProductid,JtID,operatename,operatedate) " +
|
||
"select DBO.p_Getbillid('8000301',''),'" + BgSqTable.Rows[gridView1.FocusedRowHandle]["productid"].ToString() + "','" + DllBaseClass.Gjtid + "', '" + DllBaseClass.Goperatorname + "',getdate()";
|
||
BaseImpl.ExecSqlValue(sql);
|
||
|
||
sql = "UPDATE P_FixedAssetsMlTab SET ZtTig=2,jtwz='" + DllBaseClass.GjtName + "' where ProductId='" + BgSqTable.Rows[gridView1.FocusedRowHandle]["productid"].ToString() + "' ";
|
||
BaseImpl.ExecSqlValue(sql);
|
||
|
||
|
||
dateadd();
|
||
button1.Enabled = false;
|
||
button2.Enabled = false;
|
||
}
|
||
|
||
private void button2_Click(object sender, EventArgs e)
|
||
{
|
||
string sql="UPDATE P_FixedAssetsMlTab SET ZtTig=3 where ProductId='" + BGSjTable.Rows[gridView2.FocusedRowHandle]["productid"].ToString() + "' ";
|
||
BaseImpl.ExecSqlValue(sql);
|
||
|
||
sql = "update P_FixedAssetsDYTab set tigid=2,sjopname='" + DllBaseClass.Goperatorname + "',sjopdate=getdate() where id='" + BGSjTable.Rows[gridView2.FocusedRowHandle]["ID"].ToString() + "' ";
|
||
BaseImpl.ExecSqlValue(sql);
|
||
|
||
dateadd();
|
||
}
|
||
|
||
private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
|
||
{
|
||
string zttig = BgSqTable.Rows[gridView1.FocusedRowHandle]["ZtTig"].ToString();
|
||
if (zttig == "1" || zttig == "6")
|
||
{ button1.Enabled = true; }
|
||
else
|
||
{ button1.Enabled = false; }
|
||
|
||
}
|
||
|
||
private void gridView2_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
|
||
{
|
||
string zttig = BGSjTable.Rows[gridView2.FocusedRowHandle]["tigid"].ToString();
|
||
if (zttig == "1")
|
||
{
|
||
button4.Enabled = false;
|
||
button2.Enabled = true;
|
||
}
|
||
else
|
||
{
|
||
button4.Enabled = true;
|
||
button2.Enabled = false;
|
||
}
|
||
}
|
||
|
||
private void button4_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
string sql = "UPDATE P_FixedAssetsMlTab SET ZtTig=1,jtwz='' where ProductId='" + BGSjTable.Rows[gridView2.FocusedRowHandle]["productid"].ToString() + "' ";
|
||
BaseImpl.ExecSqlValue(sql);
|
||
|
||
sql = "delete P_FixedAssetsDYTab where id='" + BGSjTable.Rows[gridView2.FocusedRowHandle]["ID"].ToString() + "' ";
|
||
BaseImpl.ExecSqlValue(sql);
|
||
dateadd();
|
||
}
|
||
|
||
private void button5_Click(object sender, EventArgs e)
|
||
{
|
||
string sql = "INSERT P_FixedAssetsDYTab(DYbilldocument_id,LProductid,JtID,operatename,operatedate,Redid,Outid) " +
|
||
"select DBO.p_Getbillid('8000301',''), '" + BGXjTable.Rows[gridView3.FocusedRowHandle]["LProductid"].ToString() + "' , '" + DllBaseClass.Gjtid + "' , " +
|
||
"'" + DllBaseClass.Goperatorname + "',getdate(),1, '" + BGXjTable.Rows[gridView3.FocusedRowHandle]["id"].ToString() + "' ";
|
||
BaseImpl.ExecSqlValue(sql);
|
||
|
||
|
||
sql = "update P_FixedAssetsDYTab set tigid=3 where id='" + BGXjTable.Rows[gridView3.FocusedRowHandle]["id"].ToString() + "' ";
|
||
BaseImpl.ExecSqlValue(sql);
|
||
|
||
dateadd();
|
||
}
|
||
|
||
private void gridControl3_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void button6_Click(object sender, EventArgs e)
|
||
{
|
||
Close();
|
||
}
|
||
|
||
private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
|
||
{
|
||
if (e.KeyChar == 13)
|
||
{
|
||
dateadd();
|
||
}
|
||
}
|
||
|
||
private void button3_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
}
|
||
}
|