北京安通林JIS系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

85 lines
3.0 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using Stone.Entity;
using Gm_WMS.DataAccess.DataService;
using Stone.Common;
namespace Stone.WinBiz.BasicData
{
public class F_TTZ_Data : F_Base
{
public F_TTZ_Data()
{
this.type = "TTZ_Data";
this.name = "基础资料_TTZ数据导入";
this.entity = new Entity_t_TTZ_Data();
this.entityView = new Entity_t_TTZ_Data();
this.dateWhere = "[AddTime] >= '{0}' and [AddTime] <= '{1}'";
}
public override void GetView(DataGridView dgv)
{
base.GetView(dgv);
dgv.Columns["CarType"].HeaderText = "车型";
dgv.Columns["Purpose"].HeaderText = "阶段";
dgv.Columns["ProductionNo"].HeaderText = "生产号";
dgv.Columns["ReleaseDate"].HeaderText = "发布日期";
dgv.Columns["AddTime"].HeaderText = "导入日期";
dgv.Columns["UserName"].HeaderText = "导入用户";
}
public void InputDataNew(string filename, Label lblState)
{
DataSet dsData = null;
Stone.Common.MyExcelDatabase.OpenDatabase(filename, true);
dsData = Stone.Common.MyExcelDatabase.ExecuteDataSet("select * from [Sheet1$]");
Stone.Common.MyExcelDatabase.CloseDatabase();
LocalDBService db = new LocalDBService();
int i = 1;
foreach (DataRow drData in dsData.Tables[0].Rows)
{
lblState.Text = i + "/" + dsData.Tables[0].Rows.Count;
lblState.Update();
i++;
string CarType = MyStrings.GetString(drData["车型"].ToString()).Trim();
string ProductionNo = MyStrings.GetString(drData["生产号"].ToString()).Trim();
string Purpose = MyStrings.GetString(drData["阶段"].ToString()).Trim();
string ReleaseDate = MyStrings.GetString(drData["发布日期"].ToString()).Trim();
//string sql_delete = $"delete from t_TTZ_Data where [ProductionNo]='{ProductionNo}';";
DataTable dt = db.Exec_DataSet($"select * from t_TTZ_Data where [ProductionNo]='{ProductionNo}';").Tables[0];
if(dt.Rows.Count == 0)
{
string sql_insert = $@"insert into [t_TTZ_Data]([CarType],[ProductionNo],[Purpose],[ReleaseDate],[UserName])
values('{CarType}','{ProductionNo}', '{Purpose}', '{ReleaseDate}', '{User.UserInfo.UserName}');";
db.Exec_NonQuery(sql_insert);
}
else
{
string sql_update = $"update t_TTZ_Data set [CarType]='{CarType}',[Purpose]='{Purpose}',[ReleaseDate]='{ReleaseDate}', [AddTime]=getdate(),[UserName]='{User.UserInfo.UserName}' where [ProductionNo]='{ProductionNo}';";
db.Exec_NonQuery(sql_update);
}
}
}
}
}