2026821
This commit is contained in:
@@ -0,0 +1,307 @@
|
||||
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_MODEL.Page;
|
||||
using GThinking.N_MISPRO.Data;
|
||||
using System.Collections.Generic;
|
||||
using GThinking.N_MISPRO.Utility;
|
||||
using GThinking.N_CONTROL;
|
||||
using GThinking.N_MISPROAS;
|
||||
|
||||
namespace GThinking.N_XLXSBJ
|
||||
{
|
||||
public partial class XLBJD_YZZDRInfo : SingleCardBase
|
||||
{
|
||||
XLBJD_YZZDR entity = new XLBJD_YZZDR();
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.UMID = 100860000;
|
||||
this.UMName = "报价单因子值导入";
|
||||
base.CurMaster = Master;
|
||||
this.CurEntity = entity;
|
||||
this.PageHeight = 180;
|
||||
this.PageWidth = 420;
|
||||
|
||||
this.Master.EnableAttachBtn = false;
|
||||
this.Master.EnableCancelBtn = false;
|
||||
this.Master.EnableCopyBtn = false;
|
||||
this.Master.EnableDeleteBtn = false;
|
||||
this.Master.EnableEditBtn = false;
|
||||
this.Master.EnableInsertBtn = false;
|
||||
this.Master.EnablePrintBtn = false;
|
||||
this.Master.EnableRefreshBtn = false;
|
||||
this.Master.EnableSaveBtn = false;
|
||||
Server.ScriptTimeout = 3600;
|
||||
fupdPost.FileSaveType = gtAsyncFileUpload.DFileSaveType.SaveToPath;
|
||||
if (AppRuntime.BitType == AppBitType.Bit32)
|
||||
fupdPost.Filter = "XLS";
|
||||
else // AppBitType.Bit64
|
||||
fupdPost.Filter = "XLS,XLSX";
|
||||
base.InitPage();
|
||||
Server.ScriptTimeout = 3600;
|
||||
btnUn.Style["display"] = "none";
|
||||
if (PageParam.GetRTrimString("KJF") == "Y")
|
||||
{
|
||||
lblTitle.Text = "导入格式为:序号、型号、规格、标准、电压等级、颜色、计量单位、报价数量、" + PageParam.GetRTrimString("YZID").Split('|')[1];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#region 控件事件
|
||||
|
||||
protected void btnQX_Click(object sender, EventArgs e)
|
||||
{
|
||||
CloseWindow();
|
||||
}
|
||||
|
||||
protected void btnUnDis_Click(object sender, EventArgs e)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
ExcelColumnValid(aDataExcel);
|
||||
UpdateBJDYZZ(dberp, sSQL, aDataExcel);
|
||||
dberp.CommitTrans();
|
||||
ShowMessage("导入成功!");
|
||||
CloseWindow();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
lblTitle.Text = "";
|
||||
dberp.RollbackTrans();
|
||||
ShowMessage(ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
System.IO.File.Delete(fupdPost.FilePath.Trim());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 自定义函数
|
||||
|
||||
private void UpdateBJDYZZ(TDatabase dberp, TSQL SQL, DataSet ds)
|
||||
{
|
||||
string sBJDID = PageParam.GetRTrimString("BJDID");
|
||||
string sYZID = PageParam.GetRTrimString("YZID");
|
||||
DateTime dtNow = DateTime.Now;
|
||||
int VnewID = CMISproDataBase.GetMaxXH("DBERP", "V_BJDYZZ", "V_BJDYZZ_ID", "") + 1;
|
||||
Dictionary<string, string> DicYZLM = new Dictionary<string, string>();
|
||||
foreach (string sYZ in sYZID.Split(','))
|
||||
{
|
||||
string sTYZID = sYZ.Split('|')[0];
|
||||
string sYZLM = sYZ.Split('|')[1];
|
||||
DicYZLM.Add(sTYZID, sYZLM);
|
||||
}
|
||||
SQL.Clear();
|
||||
SQL.Add(" insert into V_BJDYZZ (V_BJDYZZ_ID,V_BJDYZZ_TIMESTAMP,V_BJDYZZ_BJDID,V_BJDYZZ_BJDXH ");
|
||||
foreach (string sKey in DicYZLM.Keys)
|
||||
{
|
||||
SQL.Add(" ,V_BJDYZZ_YZZ" + sKey.Substring(2));
|
||||
}
|
||||
SQL.Add(" ) ");
|
||||
SQL.Add(" values(:V_BJDYZZ_ID,:V_BJDYZZ_TIMESTAMP,:V_BJDYZZ_BJDID,:V_BJDYZZ_BJDXH");
|
||||
foreach (string sKey in DicYZLM.Keys)
|
||||
{
|
||||
SQL.Add(" ,:V_BJDYZZ_YZZ" + sKey.Substring(2));
|
||||
}
|
||||
SQL.Add(" )");
|
||||
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
||||
{
|
||||
int index = 8;
|
||||
double dXH = CMISproConvert.StrToFloat(ds.Tables[0].Rows[i][0].ToString().Trim());
|
||||
SQL.ParamByName("V_BJDYZZ_ID").Value = VnewID;
|
||||
SQL.ParamByName("V_BJDYZZ_TIMESTAMP").Value = dtNow;
|
||||
SQL.ParamByName("V_BJDYZZ_BJDID").Value = sBJDID;
|
||||
SQL.ParamByName("V_BJDYZZ_BJDXH").Value = dXH;
|
||||
foreach (string sKey in DicYZLM.Keys)
|
||||
{
|
||||
if (PageParam.GetRTrimString("KJF") == "Y")
|
||||
{ //研发自测:王正阳 2026/07/16 21:42:18
|
||||
double dSL = CMISproConvert.StrToFloat(ds.Tables[0].Rows[i][7].ToString().Trim());
|
||||
double dYZ = CMISproConvert.StrToFloat(ds.Tables[0].Rows[i][index].ToString().Trim());
|
||||
if (dSL == 0)
|
||||
{
|
||||
SQL.ParamByName("V_BJDYZZ_YZZ" + sKey.Substring(2)).Value = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
SQL.ParamByName("V_BJDYZZ_YZZ" + sKey.Substring(2)).Value =Math.Round(dYZ / dSL, 6);
|
||||
}
|
||||
}
|
||||
else
|
||||
SQL.ParamByName("V_BJDYZZ_YZZ" + sKey.Substring(2)).Value = CMISproConvert.StrToFloat(ds.Tables[0].Rows[i][index].ToString().Trim());
|
||||
index++;
|
||||
}
|
||||
dberp.ExecSQL(SQL);
|
||||
}
|
||||
|
||||
SQL.Clear();
|
||||
SQL.Add(" merge into XLXSBJDYZZ0 tag ");
|
||||
SQL.Add(" using ( ");
|
||||
SQL.Add(" select V_BJDYZZ_BJDID,V_BJDYZZ_BJDXH ");
|
||||
foreach (string sKey in DicYZLM.Keys)
|
||||
{
|
||||
SQL.Add(" ,V_BJDYZZ_YZZ" + sKey.Substring(2));
|
||||
}
|
||||
SQL.Add(" from V_BJDYZZ where V_BJDYZZ_ID = :pID and V_BJDYZZ_BJDID = :pBJDID ");
|
||||
SQL.Add(" ) sor ");
|
||||
SQL.Add(" on (XLXSBJDYZZ0_BJDID = V_BJDYZZ_BJDID and XLXSBJDYZZ0_XH = V_BJDYZZ_BJDXH ) ");
|
||||
SQL.Add(" when matched then update set ");
|
||||
int iindex = 0;
|
||||
foreach (string sKey in DicYZLM.Keys)
|
||||
{
|
||||
if (iindex>0)
|
||||
SQL.Add(" ,XLXSBJDYZZ0_YZZ" + sKey.Substring(2) + " = V_BJDYZZ_YZZ" + sKey.Substring(2));
|
||||
else
|
||||
SQL.Add(" XLXSBJDYZZ0_YZZ" + sKey.Substring(2) + " = V_BJDYZZ_YZZ" + sKey.Substring(2));
|
||||
iindex++;
|
||||
}
|
||||
SQL.ParamByName("pID").Value = VnewID;
|
||||
SQL.ParamByName("pBJDID").Value = sBJDID;
|
||||
dberp.ExecSQL(SQL);
|
||||
|
||||
SQL.Clear();
|
||||
SQL.Add(" delete from V_BJDYZZ where V_BJDYZZ_ID = :pID and V_BJDYZZ_BJDID = :pBJDID ");
|
||||
SQL.ParamByName("pID").Value = VnewID;
|
||||
SQL.ParamByName("pBJDID").Value = sBJDID;
|
||||
dberp.ExecSQL(SQL);
|
||||
|
||||
if (dberp.DriverName == "ORACLE")
|
||||
{
|
||||
if (dberp.InTransaction)
|
||||
{
|
||||
dberp.CommitTrans();
|
||||
|
||||
dberp.BeginTrans();
|
||||
}
|
||||
}
|
||||
|
||||
#region 配置信息
|
||||
|
||||
string sBJU002 = GetOption("BJU002");
|
||||
string sBJU003 = GetOption("BJU003");
|
||||
int startBJDXH = 1;
|
||||
string sErrMsg = "";
|
||||
|
||||
SQL.Clear();
|
||||
SQL.Add("select XLXSBJD_BJFLID,XLXSBJFL_BJJCLLX,XLXSBJFL_LJJCLLX,XLXSBJFL_CPBJMRXSWS,XLXSBJFL_ZDXJJCLLX,XLXSBJFL_JYF,XLXSBJFL_YFWLID,XLXSBJFL_BJHYF ");
|
||||
SQL.Add(" from XLXSBJD ");
|
||||
SQL.Add(" left join XLXSBJFL on XLXSBJFL_BJFLID=XLXSBJD_BJFLID");
|
||||
SQL.Add(" where XLXSBJD_BJDID=:pBJDID");
|
||||
SQL.ParamByName("pBJDID").Value = sBJDID;
|
||||
DataSet dsBJD = dberp.OpenDataSet(SQL);
|
||||
if (dsBJD.Tables[0].Rows.Count == 0)
|
||||
{
|
||||
throw new Exception("报价单记录不存在!");
|
||||
}
|
||||
|
||||
int iXSWS = string.IsNullOrEmpty(sBJU002) ? 5 : CMISproConvert.StrToInt(sBJU002);
|
||||
if (iXSWS < 0)
|
||||
iXSWS = 0;
|
||||
else if (iXSWS > 8)
|
||||
iXSWS = 8;
|
||||
|
||||
string sBJFLID = dsBJD.Tables[0].Rows[0]["XLXSBJD_BJFLID"].ToString().Trim();
|
||||
string sJCLLX = dsBJD.Tables[0].Rows[0]["XLXSBJFL_BJJCLLX"].ToString().Trim();
|
||||
string sLJJCLLX = dsBJD.Tables[0].Rows[0]["XLXSBJFL_LJJCLLX"].ToString().Trim();
|
||||
string sCPBJMRXSWS = dsBJD.Tables[0].Rows[0]["XLXSBJFL_CPBJMRXSWS"].ToString().Trim();
|
||||
string sZDXJJCLLX = dsBJD.Tables[0].Rows[0]["XLXSBJFL_ZDXJJCLLX"].ToString().Trim();
|
||||
string sJYF = dsBJD.Tables[0].Rows[0]["XLXSBJFL_JYF"].ToString().Trim();
|
||||
string sYFWLID = dsBJD.Tables[0].Rows[0]["XLXSBJFL_YFWLID"].ToString().Trim();
|
||||
string sBJHYF = dsBJD.Tables[0].Rows[0]["XLXSBJFL_BJHYF"].ToString().Trim();
|
||||
|
||||
#endregion
|
||||
|
||||
XLBJDUtils.UpdateBJDMX(dberp, SQL, sBJFLID, sBJDID, iXSWS, sJCLLX, sLJJCLLX, sCPBJMRXSWS, "", startBJDXH);
|
||||
if (XLBJDUtils.ExistXSCPML())
|
||||
{
|
||||
XLBJDUtils.UpdateBJDMX_CPMLMC(sBJDID, "", startBJDXH - 1, true, ref sErrMsg);
|
||||
if (!sErrMsg.Equals(""))
|
||||
{
|
||||
throw new Exception(sErrMsg);
|
||||
}
|
||||
}
|
||||
|
||||
if (dberp.DriverName == "ORACLE")
|
||||
{
|
||||
if (dberp.InTransaction)
|
||||
{
|
||||
dberp.CommitTrans();
|
||||
|
||||
dberp.BeginTrans();
|
||||
}
|
||||
}
|
||||
|
||||
XLBJDUtils.UpdateZDXJGS(dberp, SQL, sBJDID, sBJFLID, sBJU002, "", startBJDXH);
|
||||
XLBJDUtils.UpdateJSJGS(dberp, SQL, sBJDID, sBJFLID, sBJU002, "", startBJDXH);
|
||||
XLBJDCalcUtils.Check_UpdBJSLYZZ(dberp, SQL, sBJDID, sBJFLID, sBJU002, sBJU003);
|
||||
XLBJDUtils.UpdateXLXSBJD(dberp, SQL, sBJDID, sJCLLX, sLJJCLLX, sZDXJJCLLX, sJYF, "", "", sYFWLID, sBJHYF);
|
||||
}
|
||||
|
||||
private void ExcelColumnValid(DataSet ds)
|
||||
{
|
||||
Dictionary<string, string> ColumnNames = new Dictionary<string, string>();
|
||||
|
||||
ColumnNames.Clear();
|
||||
ColumnNames.Add("0", "序号");
|
||||
ColumnNames.Add("1", "型号");
|
||||
ColumnNames.Add("2", "规格");
|
||||
ColumnNames.Add("3", "标准");
|
||||
ColumnNames.Add("4", "电压等级");
|
||||
ColumnNames.Add("5", "颜色");
|
||||
ColumnNames.Add("6", "计量单位");
|
||||
ColumnNames.Add("7", "报价数量");
|
||||
int i = 8;
|
||||
string sYZID = PageParam.GetRTrimString("YZID");
|
||||
foreach (string sYZ in sYZID.Split(','))
|
||||
{
|
||||
string sYZLM = sYZ.Split('|')[1];
|
||||
ColumnNames.Add(i.ToString().Trim(), sYZLM);
|
||||
i++;
|
||||
}
|
||||
foreach (KeyValuePair<string, string> kpv in ColumnNames)
|
||||
{
|
||||
if (!ds.Tables[0].Columns[CMISproConvert.StrToInt(kpv.Key.Trim())].ColumnName.Trim().Equals(kpv.Value.Trim()))
|
||||
{
|
||||
throw new Exception(string.Format("({0})列标题错误,该列为({1})", ds.Tables[0].Columns[CMISproConvert.StrToInt(kpv.Key.Trim())].ColumnName.Trim() + 1, kpv.Value.Trim()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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("文件读取失败!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user