2026821
This commit is contained in:
@@ -0,0 +1,523 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Collections;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using GThinking.N_MISPRO;
|
||||
using GThinking.N_MISPRO.Data;
|
||||
using GThinking.N_MODEL.Page;
|
||||
using GThinking.N_WORKFLOW;
|
||||
using GThinking.N_MODEL.Dialog;
|
||||
using GThinking.N_PUBLIC;
|
||||
using GThinking.N_MISPRO.Utility;
|
||||
using GThinking.N_CONTROL;
|
||||
using System.IO;
|
||||
using System.Data.OleDb;
|
||||
using System.Data.Common;
|
||||
using System.Collections.Generic;
|
||||
using GThinking.N_MISPROAS;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
|
||||
namespace GThinking.N_XLXSBJ
|
||||
{
|
||||
public partial class DRBJDYZZA : SingleCardBase
|
||||
{
|
||||
TZYZBJA_DRBJDYZZA entity = new TZYZBJA_DRBJDYZZA();
|
||||
|
||||
//int iXSWS = 2;
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.UMID = 100860041;
|
||||
this.UMName = "按型号规格电压等级标准调报价";
|
||||
base.CurMaster = Master;
|
||||
base.CurEntity = entity;
|
||||
this.PageHeight = 180;
|
||||
this.PageWidth = 420;
|
||||
Master.EnableAttachBtn = false;
|
||||
Master.EnableCancelBtn = false;
|
||||
Master.EnableCopyBtn = false;
|
||||
Master.EnableDeleteBtn = false;
|
||||
Master.EnableEditBtn = false;
|
||||
Master.EnableInsertBtn = false;
|
||||
Master.EnablePrintBtn = false;
|
||||
Master.EnableRefreshBtn = false;
|
||||
Master.EnableSaveBtn = false;
|
||||
fupdPost.FileSaveType = gtAsyncFileUpload.DFileSaveType.SaveToPath;
|
||||
fupdPost.Filter = "XLS,XLSX";
|
||||
base.InitPage();
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
txtJGBID.Value = PageParam.GetRTrimString("JGBID");
|
||||
chkIns.Checked = true;
|
||||
|
||||
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
||||
TSQL SQL = new TSQL(dberp);
|
||||
SQL.Clear();
|
||||
SQL.Add("select XLXSTZYZ_YZID, XLXSTZYZ_YZMC, XLXSTZYZ_JJFS ");
|
||||
SQL.Add(" from XLXSTZYZ");
|
||||
SQL.Add(" where XLXSTZYZ_MXBH = 'BJD' and XLXSTZYZ_TJYS='A' ");
|
||||
SQL.Add(" and XLXSTZYZ_JGBID = :pJGBID");
|
||||
SQL.Add("order by XLXSTZYZ_YZID,XLXSTZYZ_XSXH");
|
||||
SQL.ParamByName("pJGBID").Value = txtJGBID.Value;
|
||||
DataSet ds = dberp.OpenDataSet(SQL);
|
||||
cbxYZID.ClearItems();
|
||||
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
||||
{
|
||||
txtXSWS.Value = "2";
|
||||
string sJJFSMC = "";
|
||||
if (ds.Tables[0].Rows[i]["XLXSTZYZ_JJFS"].ToString().Trim().Equals("JJ"))
|
||||
{
|
||||
sJJFSMC = "(元)";
|
||||
txtXSWS.Value = GetOption(this.UMID, "BJU056");
|
||||
}
|
||||
else if (ds.Tables[0].Rows[i]["XLXSTZYZ_JJFS"].ToString().Trim().Equals("MX") || ds.Tables[0].Rows[i]["XLXSTZYZ_JJFS"].ToString().Trim().Equals("DX"))
|
||||
{
|
||||
txtXSWS.Value = "4";
|
||||
}
|
||||
else
|
||||
{
|
||||
sJJFSMC = "(%)";
|
||||
txtXSWS.Value = "2";
|
||||
}
|
||||
cbxYZID.Items.Add(new ListItem(ds.Tables[0].Rows[i]["XLXSTZYZ_YZMC"].ToString().Trim() + sJJFSMC, ds.Tables[0].Rows[i]["XLXSTZYZ_YZID"].ToString().Trim()));
|
||||
}
|
||||
//if (cbxYZID.Items.Count > 0)
|
||||
// cbxYZID.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#region 控件事件
|
||||
|
||||
protected void btnQD_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (fupdPost.FilePath.Equals(""))
|
||||
{
|
||||
ShowMessage("请选择需要导入的文件!");
|
||||
return;
|
||||
}
|
||||
if (cbxYZID.SelectedValue.Trim().Equals(""))
|
||||
{
|
||||
ShowMessage("请选择待设置的调价因子!");
|
||||
return;
|
||||
}
|
||||
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
||||
TSQL sSQL = new TSQL(dberp);
|
||||
try
|
||||
{
|
||||
lblTitle.Text = "正在导入数据,请稍后...";
|
||||
dberp.BeginTrans();
|
||||
DataSet aDataExcel = new DataSet();
|
||||
if (AppRuntime.BitType == AppBitType.Bit32)
|
||||
aDataExcel = XLBJDUtils.ReadFromExcelFile(fupdPost.FilePath, 0, "");
|
||||
else // AppBitType.Bit64
|
||||
ReadWJ(fupdPost.FilePath, ref aDataExcel);//只能读出前33356行记录
|
||||
ExcelColumnValid(aDataExcel);
|
||||
if (dberp.DriverName == "ORACLE")
|
||||
InsertYZZAOracle(dberp, sSQL, aDataExcel);
|
||||
else
|
||||
InsertYZZA(dberp, sSQL, aDataExcel);
|
||||
dberp.CommitTrans();
|
||||
ShowMessage("设置完成!");
|
||||
|
||||
//执行完毕后关闭当前页面
|
||||
DialogOperationScript dos = new DialogOperationScript(this);
|
||||
dos.ClickOwnerButton(PageParam.GetRTrimString("btnRefresh1CID"));
|
||||
dos.CloseSelf();
|
||||
dos.Execute();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
lblTitle.Text = "";
|
||||
dberp.RollbackTrans();
|
||||
ShowMessage(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
protected void btnQX_Click(object sender, EventArgs e)
|
||||
{
|
||||
CloseWindow();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 自定义事件
|
||||
|
||||
public static string GetStdConnStr(string sDriverName, string sJSConnStr)
|
||||
{
|
||||
string result = ""; ;
|
||||
string[] pairs = sJSConnStr.Split(';');
|
||||
foreach (string pair in pairs)
|
||||
{
|
||||
string[] keyValue = pair.Split('=');
|
||||
if (keyValue[0] == "Server Name")
|
||||
{
|
||||
if (sDriverName == "ORACLE")
|
||||
{
|
||||
result = result + "Data Source=" + keyValue[1] + ";";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = result + "Server=" + keyValue[1] + ";";
|
||||
}
|
||||
}
|
||||
else if (keyValue[0] == "Database Name")
|
||||
{
|
||||
result = result + "Database=" + keyValue[1] + ";";
|
||||
}
|
||||
else if (keyValue[0] == "User Name")
|
||||
{
|
||||
result = result + "User ID=" + keyValue[1] + ";";
|
||||
}
|
||||
else if (keyValue[0] == "Password")
|
||||
{
|
||||
result = result + "Password=" + keyValue[1] + ";";
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void InsertYZZAOracle(TDatabase dberp, TSQL sSQL, DataSet ds)
|
||||
{
|
||||
Dictionary<string, string> dicDRMXBZ = new Dictionary<string, string>();
|
||||
dicDRMXBZ.Clear();
|
||||
sSQL.Clear();
|
||||
sSQL.Add("select XLBZ_XLBZID,XLBZ_XLBZLXMC from XLBZ where 1 = 1 ");
|
||||
DataSet dsXLBZ = dberp.OpenDataSet(sSQL);
|
||||
if (dsXLBZ.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < dsXLBZ.Tables[0].Rows.Count; i++)
|
||||
{
|
||||
dicDRMXBZ.Add(dsXLBZ.Tables[0].Rows[i]["XLBZ_XLBZID"].ToString().Trim(), dsXLBZ.Tables[0].Rows[i]["XLBZ_XLBZLXMC"].ToString().Trim());
|
||||
}
|
||||
}
|
||||
string sDefaultXLBZID = XLBJDUtils.GetDefaultXLBZID();
|
||||
//A|× B|*
|
||||
string sXLJGU007 = GetOption(102579000, "XLJGU007");
|
||||
foreach (DataRow Row in ds.Tables[0].Rows)
|
||||
{
|
||||
string sXLXHID = sGetCellTest(Row, 0).Trim();
|
||||
string sXLGGID = sGetCellTest(Row, 1).Trim();
|
||||
if (sXLJGU007.Equals("A"))
|
||||
{
|
||||
sXLGGID = sXLGGID.Replace("x", "X").Replace("X", "*").Replace("*", "×");
|
||||
}
|
||||
else if (sXLJGU007.Equals("B"))
|
||||
{
|
||||
sXLGGID = sXLGGID.Replace("x", "X").Replace("X", "*").Replace("×", "*");
|
||||
}
|
||||
string sXLBZID = sGetCellTest(Row, 2).Trim();
|
||||
sXLBZID = XLBJDUtils.GetBZXLZBZID(sXLBZID, sDefaultXLBZID, dicDRMXBZ);
|
||||
string sXLDYDJ = sGetCellTest(Row, 3).Trim();
|
||||
string sTJDH = "";
|
||||
if (ds.Tables[0].Columns.Contains("调价代号"))
|
||||
sTJDH = sGetCellTest(Row, 5).Trim();
|
||||
if (!CMISproDataBase.ExistsRecord("DBERP", string.Format("select 1 from XLXSBJDYZZA where XLXSBJDYZZA_JGBID='{0}' and XLXSBJDYZZA_XLXHID='{1}' and XLXSBJDYZZA_XLGGID='{2}' and XLXSBJDYZZA_DYDJID='{3}' and XLXSBJDYZZA_XLBZID='{4}' and XLXSBJDYZZA_YZID='{5}'",
|
||||
txtJGBID.Value.Trim(), sXLXHID, sXLGGID, sXLDYDJ, sXLBZID, cbxYZID.SelectedValue.Trim())))
|
||||
{
|
||||
if (chkIns.Checked)//不存在的记录自动插入
|
||||
{
|
||||
sSQL.Clear();
|
||||
sSQL.Add("insert into XLXSBJDYZZA(XLXSBJDYZZA_JGBID,XLXSBJDYZZA_XLXHID,XLXSBJDYZZA_XLGGID,XLXSBJDYZZA_DYDJID,XLXSBJDYZZA_XLBZID,XLXSBJDYZZA_YZID,XLXSBJDYZZA_YZZ,XLXSBJDYZZA_TJDH,XLXSBJDYZZA_WHR,XLXSBJDYZZA_WHRID,XLXSBJDYZZA_WHSJ)");
|
||||
sSQL.Add(" values(:XLXSBJDYZZA_JGBID,:XLXSBJDYZZA_XLXHID,:XLXSBJDYZZA_XLGGID,:XLXSBJDYZZA_DYDJID,:XLXSBJDYZZA_XLBZID,:XLXSBJDYZZA_YZID,:XLXSBJDYZZA_YZZ,:XLXSBJDYZZA_TJDH,:XLXSBJDYZZA_WHR,:XLXSBJDYZZA_WHRID,:XLXSBJDYZZA_WHSJ)");
|
||||
sSQL.ParamByName("XLXSBJDYZZA_JGBID").Value = txtJGBID.Value.Trim();
|
||||
sSQL.ParamByName("XLXSBJDYZZA_XLXHID").Value = sXLXHID;
|
||||
sSQL.ParamByName("XLXSBJDYZZA_XLGGID").Value = sXLGGID;
|
||||
sSQL.ParamByName("XLXSBJDYZZA_DYDJID").Value = sXLDYDJ;
|
||||
sSQL.ParamByName("XLXSBJDYZZA_XLBZID").Value = sXLBZID;
|
||||
sSQL.ParamByName("XLXSBJDYZZA_YZID").Value = cbxYZID.SelectedValue.Trim();
|
||||
sSQL.ParamByName("XLXSBJDYZZA_YZZ").Value = NumberUtils.RoundX(CMISproConvert.StrToFloat(sGetCellTest(Row, 4), 0), CMISproConvert.StrToInt(txtXSWS.Value));
|
||||
sSQL.ParamByName("XLXSBJDYZZA_TJDH").Value = sTJDH;
|
||||
sSQL.ParamByName("XLXSBJDYZZA_WHR").Value = tSession.UserName;
|
||||
sSQL.ParamByName("XLXSBJDYZZA_WHRID").Value = tSession.UserId;
|
||||
sSQL.ParamByName("XLXSBJDYZZA_WHSJ").Value = DateTime.Now;
|
||||
dberp.ExecSQL(sSQL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sSQL.Clear();
|
||||
sSQL.Add("update XLXSBJDYZZA set XLXSBJDYZZA_YZZ=:XLXSBJDYZZA_YZZ,XLXSBJDYZZA_TJDH=:XLXSBJDYZZA_TJDH,XLXSBJDYZZA_WHR=:XLXSBJDYZZA_WHR,XLXSBJDYZZA_WHRID=:XLXSBJDYZZA_WHRID,XLXSBJDYZZA_WHSJ=:XLXSBJDYZZA_WHSJ");
|
||||
sSQL.Add(" where XLXSBJDYZZA_JGBID=:XLXSBJDYZZA_JGBID");
|
||||
sSQL.Add(" and XLXSBJDYZZA_XLXHID=:XLXSBJDYZZA_XLXHID");
|
||||
sSQL.Add(" and XLXSBJDYZZA_XLGGID=:XLXSBJDYZZA_XLGGID");
|
||||
sSQL.Add(" and XLXSBJDYZZA_DYDJID=:XLXSBJDYZZA_DYDJID");
|
||||
sSQL.Add(" and XLXSBJDYZZA_XLBZID=:XLXSBJDYZZA_XLBZID");
|
||||
sSQL.Add(" and XLXSBJDYZZA_YZID=:XLXSBJDYZZA_YZID");
|
||||
sSQL.ParamByName("XLXSBJDYZZA_JGBID").Value = txtJGBID.Value.Trim();
|
||||
sSQL.ParamByName("XLXSBJDYZZA_XLXHID").Value = sXLXHID;
|
||||
sSQL.ParamByName("XLXSBJDYZZA_XLGGID").Value = sXLGGID;
|
||||
sSQL.ParamByName("XLXSBJDYZZA_DYDJID").Value = sXLDYDJ;
|
||||
sSQL.ParamByName("XLXSBJDYZZA_XLBZID").Value = sXLBZID;
|
||||
sSQL.ParamByName("XLXSBJDYZZA_YZID").Value = cbxYZID.SelectedValue.Trim();
|
||||
sSQL.ParamByName("XLXSBJDYZZA_YZZ").Value = NumberUtils.RoundX(CMISproConvert.StrToFloat(sGetCellTest(Row, 4), 0), CMISproConvert.StrToInt(txtXSWS.Value));
|
||||
sSQL.ParamByName("XLXSBJDYZZA_TJDH").Value = sTJDH;
|
||||
sSQL.ParamByName("XLXSBJDYZZA_WHR").Value = tSession.UserName;
|
||||
sSQL.ParamByName("XLXSBJDYZZA_WHRID").Value = tSession.UserId;
|
||||
sSQL.ParamByName("XLXSBJDYZZA_WHSJ").Value = DateTime.Now;
|
||||
dberp.ExecSQL(sSQL);
|
||||
}
|
||||
}
|
||||
// 批量同步XLXSBJXLGGTHB表
|
||||
XLBJDUtils.SyncXLXSBJXLGGTHB_Batch(dberp, tSession);
|
||||
}
|
||||
|
||||
|
||||
private void InsertYZZA(TDatabase dberp, TSQL sSQL, DataSet ds)
|
||||
{
|
||||
DataTable dtV_XLXSBJDYZZ = new DataTable("V_XLXSBJDYZZ");
|
||||
dtV_XLXSBJDYZZ.Columns.Add("V_XLXSBJDYZZ_ID");
|
||||
dtV_XLXSBJDYZZ.Columns.Add("V_XLXSBJDYZZ_TIMESTAMP");
|
||||
dtV_XLXSBJDYZZ.Columns.Add("V_XLXSBJDYZZ_XLXHID");
|
||||
dtV_XLXSBJDYZZ.Columns.Add("V_XLXSBJDYZZ_XLGGID");
|
||||
dtV_XLXSBJDYZZ.Columns.Add("V_XLXSBJDYZZ_DYDJID");
|
||||
dtV_XLXSBJDYZZ.Columns.Add("V_XLXSBJDYZZ_XLBZID");
|
||||
dtV_XLXSBJDYZZ.Columns.Add("V_XLXSBJDYZZ_YZID");
|
||||
dtV_XLXSBJDYZZ.Columns.Add("V_XLXSBJDYZZ_YZZ");
|
||||
dtV_XLXSBJDYZZ.Columns.Add("V_XLXSBJDYZZ_TJDH");
|
||||
DateTime TimeStamp = MISproUtils.GetServerTime();
|
||||
int VnewID = CMISproDataBase.GetMaxXH("DBERP", "V_XLXSBJDYZZ", "V_XLXSBJDYZZ_ID", "") + 1;
|
||||
|
||||
Dictionary<string, string> dicDRMXBZ = new Dictionary<string, string>();
|
||||
dicDRMXBZ.Clear();
|
||||
sSQL.Clear();
|
||||
sSQL.Add("select XLBZ_XLBZID,XLBZ_XLBZLXMC from XLBZ where 1 = 1 ");
|
||||
DataSet dsXLBZ = dberp.OpenDataSet(sSQL);
|
||||
if (dsXLBZ.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < dsXLBZ.Tables[0].Rows.Count; i++)
|
||||
{
|
||||
dicDRMXBZ.Add(dsXLBZ.Tables[0].Rows[i]["XLBZ_XLBZID"].ToString().Trim(), dsXLBZ.Tables[0].Rows[i]["XLBZ_XLBZLXMC"].ToString().Trim());
|
||||
}
|
||||
}
|
||||
string sDefaultXLBZID = XLBJDUtils.GetDefaultXLBZID();
|
||||
//A|× B|*
|
||||
string sXLJGU007 = GetOption(102579000, "XLJGU007");
|
||||
foreach (DataRow Row in ds.Tables[0].Rows)
|
||||
{
|
||||
|
||||
DataRow drDYZZ = dtV_XLXSBJDYZZ.NewRow();
|
||||
drDYZZ["V_XLXSBJDYZZ_ID"] = VnewID;
|
||||
drDYZZ["V_XLXSBJDYZZ_TIMESTAMP"] = TimeStamp;
|
||||
drDYZZ["V_XLXSBJDYZZ_XLXHID"] = sGetCellTest(Row, 0).Trim();
|
||||
string sXLGGID = sGetCellTest(Row, 1).Trim();
|
||||
if (sXLJGU007.Equals("A"))
|
||||
{
|
||||
sXLGGID = sXLGGID.Replace("x", "X").Replace("X", "*").Replace("*", "×");
|
||||
}
|
||||
else if (sXLJGU007.Equals("B"))
|
||||
{
|
||||
sXLGGID = sXLGGID.Replace("x", "X").Replace("X", "*").Replace("×", "*");
|
||||
}
|
||||
drDYZZ["V_XLXSBJDYZZ_XLGGID"] = sXLGGID;
|
||||
drDYZZ["V_XLXSBJDYZZ_DYDJID"] = sGetCellTest(Row, 3).Trim();
|
||||
string sXLBZID = sGetCellTest(Row, 2).Trim();
|
||||
sXLBZID = XLBJDUtils.GetBZXLZBZID(sXLBZID, sDefaultXLBZID, dicDRMXBZ);
|
||||
drDYZZ["V_XLXSBJDYZZ_XLBZID"] = sXLBZID;
|
||||
drDYZZ["V_XLXSBJDYZZ_YZID"] = cbxYZID.SelectedValue.Trim();
|
||||
drDYZZ["V_XLXSBJDYZZ_YZZ"] = NumberUtils.RoundX(CMISproConvert.StrToFloat(sGetCellTest(Row, 4), 0), CMISproConvert.StrToInt(txtXSWS.Value)); ;
|
||||
string sTJDH = "";
|
||||
if (ds.Tables[0].Columns.Contains("调价代号"))
|
||||
sTJDH = sGetCellTest(Row, 5).Trim();
|
||||
drDYZZ["V_XLXSBJDYZZ_TJDH"] = sTJDH;
|
||||
dtV_XLXSBJDYZZ.Rows.Add(drDYZZ);
|
||||
}
|
||||
if (dberp.DriverName == "ORACLE")
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
SqlBulkCopy bulkCopy = new SqlBulkCopy(GetStdConnStr(dberp.DriverName, ConfigurationManager.AppSettings["DBMAIN"])); ;
|
||||
bulkCopy.BulkCopyTimeout = 600;
|
||||
bulkCopy.BatchSize = 10000;
|
||||
bulkCopy.DestinationTableName = "V_XLXSBJDYZZ";
|
||||
bulkCopy.WriteToServer(dtV_XLXSBJDYZZ);
|
||||
}
|
||||
|
||||
sSQL.Clear();
|
||||
sSQL.Add(" merge into XLXSBJDYZZA tar ");
|
||||
sSQL.Add(" using ( ");
|
||||
sSQL.Add(" select ");
|
||||
sSQL.Add(" V_XLXSBJDYZZ_XLXHID, ");
|
||||
sSQL.Add(" V_XLXSBJDYZZ_XLGGID, ");
|
||||
sSQL.Add(" V_XLXSBJDYZZ_DYDJID, ");
|
||||
sSQL.Add(" V_XLXSBJDYZZ_XLBZID, ");
|
||||
sSQL.Add(" V_XLXSBJDYZZ_YZID, ");
|
||||
sSQL.Add(" V_XLXSBJDYZZ_YZZ, ");
|
||||
sSQL.Add(" V_XLXSBJDYZZ_TJDH ");
|
||||
sSQL.Add(" from V_XLXSBJDYZZ ");
|
||||
sSQL.Add(" where V_XLXSBJDYZZ_ID = :V_XLXSBJDYZZ_ID ");
|
||||
sSQL.Add(" ) sor ");
|
||||
sSQL.Add(" on ( ");
|
||||
sSQL.Add(" XLXSBJDYZZA_JGBID = :XLXSBJDYZZA_JGBID ");
|
||||
sSQL.Add(" and XLXSBJDYZZA_XLXHID = V_XLXSBJDYZZ_XLXHID ");
|
||||
sSQL.Add(" and XLXSBJDYZZA_XLGGID = V_XLXSBJDYZZ_XLGGID ");
|
||||
sSQL.Add(" and XLXSBJDYZZA_DYDJID = V_XLXSBJDYZZ_DYDJID ");
|
||||
sSQL.Add(" and XLXSBJDYZZA_XLBZID = V_XLXSBJDYZZ_XLBZID ");
|
||||
sSQL.Add(" and XLXSBJDYZZA_YZID = V_XLXSBJDYZZ_YZID ");
|
||||
sSQL.Add(" ) ");
|
||||
sSQL.Add(" when matched then ");
|
||||
sSQL.Add(" update set ");
|
||||
sSQL.Add(" XLXSBJDYZZA_YZZ = V_XLXSBJDYZZ_YZZ, ");
|
||||
sSQL.Add(" XLXSBJDYZZA_TJDH = V_XLXSBJDYZZ_TJDH, ");
|
||||
sSQL.Add(" XLXSBJDYZZA_WHR = :XLXSBJDYZZA_WHR, ");
|
||||
sSQL.Add(" XLXSBJDYZZA_WHRID = :XLXSBJDYZZA_WHRID, ");
|
||||
sSQL.Add(" XLXSBJDYZZA_WHSJ = :XLXSBJDYZZA_WHSJ ");
|
||||
if (chkIns.Checked)//不存在的记录自动插入
|
||||
{
|
||||
sSQL.Add(" when not matched then ");
|
||||
sSQL.Add(" insert ( ");
|
||||
sSQL.Add(" XLXSBJDYZZA_JGBID, ");
|
||||
sSQL.Add(" XLXSBJDYZZA_XLXHID, ");
|
||||
sSQL.Add(" XLXSBJDYZZA_XLGGID, ");
|
||||
sSQL.Add(" XLXSBJDYZZA_DYDJID, ");
|
||||
sSQL.Add(" XLXSBJDYZZA_XLBZID, ");
|
||||
sSQL.Add(" XLXSBJDYZZA_YZID, ");
|
||||
sSQL.Add(" XLXSBJDYZZA_YZZ, ");
|
||||
sSQL.Add(" XLXSBJDYZZA_TJDH, ");
|
||||
sSQL.Add(" XLXSBJDYZZA_WHR, ");
|
||||
sSQL.Add(" XLXSBJDYZZA_WHRID, ");
|
||||
sSQL.Add(" XLXSBJDYZZA_WHSJ ");
|
||||
sSQL.Add(" ) ");
|
||||
sSQL.Add(" values ( ");
|
||||
sSQL.Add(" :XLXSBJDYZZA_JGBID, ");
|
||||
sSQL.Add(" V_XLXSBJDYZZ_XLXHID, ");
|
||||
sSQL.Add(" V_XLXSBJDYZZ_XLGGID, ");
|
||||
sSQL.Add(" V_XLXSBJDYZZ_DYDJID, ");
|
||||
sSQL.Add(" V_XLXSBJDYZZ_XLBZID, ");
|
||||
sSQL.Add(" V_XLXSBJDYZZ_YZID, ");
|
||||
sSQL.Add(" V_XLXSBJDYZZ_YZZ, ");
|
||||
sSQL.Add(" V_XLXSBJDYZZ_TJDH, ");
|
||||
sSQL.Add(" :XLXSBJDYZZA_WHR, ");
|
||||
sSQL.Add(" :XLXSBJDYZZA_WHRID, ");
|
||||
sSQL.Add(" :XLXSBJDYZZA_WHSJ ");
|
||||
sSQL.Add(" ) ");
|
||||
}
|
||||
sSQL.ParamByName("XLXSBJDYZZA_JGBID").Value = txtJGBID.Value.Trim();
|
||||
sSQL.ParamByName("XLXSBJDYZZA_WHR").Value = tSession.UserName;
|
||||
sSQL.ParamByName("XLXSBJDYZZA_WHRID").Value = tSession.UserId;
|
||||
sSQL.ParamByName("XLXSBJDYZZA_WHSJ").Value = DateTime.Now;
|
||||
sSQL.ParamByName("V_XLXSBJDYZZ_ID").Value = VnewID;
|
||||
//sSQL.ParamByName("V_XLXSBJDYZZ_TIMESTAMP").Value = TimeStamp;
|
||||
dberp.ExecSQL(sSQL);
|
||||
|
||||
sSQL.Clear();
|
||||
sSQL.Add("DELETE FROM V_XLXSBJDYZZ WHERE V_XLXSBJDYZZ_ID=:V_XLXSBJDYZZ_ID ");
|
||||
sSQL.ParamByName("V_XLXSBJDYZZ_ID").Value = VnewID;
|
||||
//sSQL.ParamByName("V_XLXSBJDYZZ_TIMESTAMP").Value = TimeStamp;
|
||||
dberp.ExecSQL(sSQL);
|
||||
// 批量同步XLXSBJXLGGTHB表
|
||||
XLBJDUtils.SyncXLXSBJXLGGTHB_Batch(dberp, tSession);
|
||||
}
|
||||
|
||||
private void ExcelColumnValid(DataSet ds)
|
||||
{
|
||||
Dictionary<string, string> ColumnNames = new Dictionary<string, string>();
|
||||
ColumnNames.Add("0", "型号");
|
||||
ColumnNames.Add("1", "规格");
|
||||
ColumnNames.Add("2", "标准");
|
||||
ColumnNames.Add("3", "电压等级");
|
||||
ColumnNames.Add("4", cbxYZID.SelectedItem.Text.Trim());
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (!ds.Tables[0].Columns[i].ColumnName.Trim().Equals(ColumnNames[i.ToString()].Trim()))
|
||||
{
|
||||
throw new Exception("导入文件的内容格式不正确,Excel栏目依次为:型号、规格、标准、电压等级、" + cbxYZID.SelectedItem.Text.Trim() + "!");
|
||||
}
|
||||
}
|
||||
if (ds.Tables[0].Columns.Count > 5)
|
||||
{
|
||||
if(!ds.Tables[0].Columns[5].ColumnName.Trim().Equals("调价代号"))
|
||||
throw new Exception("导入文件的内容格式不正确,Excel栏目依次为:型号、规格、标准、电压等级、" + cbxYZID.SelectedItem.Text.Trim() + "、调价代号!");
|
||||
}
|
||||
List<string> lstXLXHID = new List<string>();
|
||||
List<string> lstXLBZID = new List<string>();
|
||||
List<string> lstDYDJID = new List<string>();
|
||||
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
||||
TSQL SQL = new TSQL(dberp);
|
||||
SQL.Clear();
|
||||
SQL.Add(" select XLXHB_XLXHID from XLXHB where isnull(XLXHB_TYBZ,'N')<>'Y' order by XLXHB_XLXHID ");
|
||||
DataSet dsTmp = dberp.OpenDataSet(SQL);
|
||||
if (dsTmp.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
lstXLXHID.Clear();
|
||||
for (int i = 0; i < dsTmp.Tables[0].Rows.Count; i++)
|
||||
{
|
||||
if (!lstXLXHID.Contains(dsTmp.Tables[0].Rows[i][0].ToString().Trim().ToUpper()))
|
||||
lstXLXHID.Add(dsTmp.Tables[0].Rows[i][0].ToString().Trim().ToUpper());
|
||||
}
|
||||
}
|
||||
Dictionary<string, string> dicDRMXBZ = new Dictionary<string, string>();
|
||||
dicDRMXBZ.Clear();
|
||||
SQL.Clear();
|
||||
SQL.Add("select XLBZ_XLBZID,XLBZ_XLBZLXMC from XLBZ where 1 = 1 ");
|
||||
DataSet dsXLBZ = dberp.OpenDataSet(SQL);
|
||||
if (dsXLBZ.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < dsXLBZ.Tables[0].Rows.Count; i++)
|
||||
{
|
||||
dicDRMXBZ.Add(dsXLBZ.Tables[0].Rows[i]["XLBZ_XLBZID"].ToString().Trim(), dsXLBZ.Tables[0].Rows[i]["XLBZ_XLBZLXMC"].ToString().Trim());
|
||||
if (!lstXLBZID.Contains(dsXLBZ.Tables[0].Rows[i]["XLBZ_XLBZID"].ToString().Trim()))
|
||||
lstXLBZID.Add(dsXLBZ.Tables[0].Rows[i]["XLBZ_XLBZID"].ToString().Trim());
|
||||
}
|
||||
}
|
||||
SQL.Clear();
|
||||
SQL.Add(" select XLDYDJB_DYDJID from XLDYDJB where isnull(XLDYDJB_TYBZ,' ')<>'Y' order by XLDYDJB_XH ");
|
||||
dsTmp = dberp.OpenDataSet(SQL);
|
||||
if (dsTmp.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
lstDYDJID.Clear();
|
||||
for (int i = 0; i < dsTmp.Tables[0].Rows.Count; i++)
|
||||
{
|
||||
if (!lstDYDJID.Contains(dsTmp.Tables[0].Rows[i][0].ToString().Trim().ToUpper()))
|
||||
lstDYDJID.Add(dsTmp.Tables[0].Rows[i][0].ToString().Trim().ToUpper());
|
||||
}
|
||||
}
|
||||
|
||||
string sDefaultXLBZID = XLBJDUtils.GetDefaultXLBZID();
|
||||
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
||||
{
|
||||
if (!lstXLXHID.Contains(ds.Tables[0].Rows[i][0].ToString().Trim().ToUpper()))
|
||||
{
|
||||
throw new Exception("第" + (i + 2).ToString() + "行型号为空或不存在或已停用,不允许导入!");
|
||||
}
|
||||
string sXLBZID = ds.Tables[0].Rows[i][2].ToString().Trim();
|
||||
sXLBZID = XLBJDUtils.GetBZXLZBZID(sXLBZID, sDefaultXLBZID, dicDRMXBZ).ToUpper();
|
||||
if (!lstXLBZID.Contains(sXLBZID))
|
||||
{
|
||||
throw new Exception("第" + (i + 2).ToString() + "行标准为空或不存在或已停用,不允许导入!");
|
||||
}
|
||||
if (!lstDYDJID.Contains(ds.Tables[0].Rows[i][3].ToString().Trim().ToUpper()))
|
||||
{
|
||||
throw new Exception("第" + (i + 2).ToString() + "行电压等级为空或不存在或已停用,不允许导入!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadWJ(string sPath, ref DataSet aDataExcel)
|
||||
{
|
||||
string sMessage = "";
|
||||
aDataExcel = TExcelData.ReadExcel(sPath.Trim(), "", "", false, ref sMessage);
|
||||
if (!sMessage.Trim().Equals(""))
|
||||
{
|
||||
throw new Exception("文件读取失败!具体原因:" + sMessage);
|
||||
}
|
||||
}
|
||||
|
||||
private string sGetCellTest(DataRow Row, int ColumnIndex)
|
||||
{
|
||||
return Row[ColumnIndex].ToString().Trim().Replace("\r\n", "").Replace("\n", "");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user