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.
145 lines
4.7 KiB
145 lines
4.7 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Stone.WinBiz.BasicData;
|
|
using Stone.Entity;
|
|
using System.Windows.Forms;
|
|
using Stone.Common;
|
|
using Stone.WinBiz.SystemData;
|
|
using System.Data;
|
|
using Gm_WMS.DataAccess.DataService;
|
|
|
|
namespace Stone.WinBiz.JisData
|
|
{
|
|
public class F_SequenceNo : F_Base
|
|
{
|
|
public string address = "";
|
|
public F_SequenceNo(string _address)
|
|
{
|
|
address = _address;
|
|
|
|
this.type = "SequenceNo";
|
|
this.dateWhere = "[sysdtm]>='{0}' and [sysdtm]<='{1}'";
|
|
this.strOrder = "[SequenceNo] asc";
|
|
this.entity = new Entity_t_SequenceNo();
|
|
this.name = $"连续号管理-{F_Common.GetAddress(_address)}";
|
|
|
|
}
|
|
|
|
public override void GetView(DataGridView dgv)
|
|
{
|
|
base.GetView(dgv);
|
|
|
|
}
|
|
|
|
public override void BindPageData(string strWhere)
|
|
{
|
|
if (entityView == null) entityView = entity;
|
|
|
|
dsMain = entityView.GetData("", $"({strWhere}) and [Address]='{address}'", strOrder);
|
|
dsMain.Tables[0].TableName = "Data";
|
|
}
|
|
|
|
public override void Input(string filename)
|
|
{
|
|
DataSet dsInput = null;
|
|
|
|
Stone.Common.MyExcelDatabase.OpenDatabase(filename, true);
|
|
dsInput = Stone.Common.MyExcelDatabase.ExecuteDataSet("select * from [TCFlastweek$]");
|
|
Stone.Common.MyExcelDatabase.CloseDatabase();
|
|
|
|
|
|
|
|
LocalDBService db = null;
|
|
try
|
|
{
|
|
|
|
db = new LocalDBService();
|
|
db.BeginTrans();
|
|
|
|
InputData(dsInput, db);
|
|
|
|
db.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (db != null) db.Rollback();
|
|
throw new Exception("导入数据失败!\r\n" + "原因为:\r\n" + ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
if (db != null) db.EndTrans();
|
|
}
|
|
|
|
|
|
Stone.WinBiz.BasicData.F_Log.WriteLog("导入Excel[" + this.name + "]");
|
|
|
|
|
|
}
|
|
|
|
public override void InputData(DataSet dsData, LocalDBService db)
|
|
{
|
|
Entity_t_SequenceNo t_SequenceNo = new Entity_t_SequenceNo(db);
|
|
Entity_t_CarType t_CarType = new Entity_t_CarType(db);
|
|
var carType = t_CarType.GetData().Tables[0];
|
|
var importBatch = DateTime.Now.ToString("yyMMddHHmm");
|
|
foreach (DataRow drData in dsData.Tables[0].Rows)
|
|
{
|
|
string ProductionNo = drData["Production number"].ToString().Trim();
|
|
string SequenceNo = drData["Shift numbers"].ToString();
|
|
string Model = drData["Model"].ToString().Trim().ToUpper();
|
|
|
|
if (ProductionNo == "") continue;
|
|
if (SequenceNo == "") continue;
|
|
|
|
// if (Model != "156" && Model != "177" && Model != "247" && Model != "H247") //过滤车型
|
|
// continue;
|
|
var compareModel = Model.Substring(Model.Length - 3);
|
|
//获取系统中的车型
|
|
var isFind = 0;
|
|
for (int i = 0; i < carType.Rows.Count; i++)
|
|
{
|
|
var sysCarType = carType.Rows[i]["Code"].ToString();
|
|
if (sysCarType.Contains(compareModel))
|
|
{
|
|
isFind = 1;
|
|
break;
|
|
}
|
|
}
|
|
if(isFind == 0) continue;
|
|
|
|
DataTable dtSequenceNo = t_SequenceNo.GetData($"[Address]='{address}' and [ProductionNo]='{ProductionNo}'").Tables[0];
|
|
if (dtSequenceNo.Rows.Count > 0)
|
|
{
|
|
if(dtSequenceNo.Rows[0]["SequenceNo"].ToString().Trim() == "")
|
|
{
|
|
t_SequenceNo.Del(dtSequenceNo.Rows[0]);
|
|
}
|
|
else
|
|
{
|
|
t_SequenceNo.Del(dtSequenceNo.Rows[0]);
|
|
// continue;
|
|
}
|
|
}
|
|
|
|
if(SequenceNo.Length > 3)
|
|
{
|
|
SequenceNo = SequenceNo.Substring(0, 12) + SequenceNo.Substring(SequenceNo.Length - 3, 3);
|
|
}
|
|
|
|
|
|
DataRow drInput = t_SequenceNo.Table.NewRow();
|
|
drInput["Address"] = address;
|
|
drInput["ProductionNo"] = ProductionNo;
|
|
drInput["Model"] = Model;
|
|
drInput["SequenceNo"] = SequenceNo;
|
|
drInput["UserName"] = User.UserInfo.UserName;
|
|
drInput["ImportBatch"] = importBatch;
|
|
t_SequenceNo.Add(drInput);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|