226 lines
9.1 KiB
C#
226 lines
9.1 KiB
C#
using System;
|
||
using System.Text;
|
||
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 GThinking.N_MISPRO;
|
||
using GThinking.N_PUBLIC;
|
||
using GThinking.N_MISPRO.Utility;
|
||
using GThinking.N_CONTROL;
|
||
using GThinking.N_MISPRO.TableCache;
|
||
using GThinking.N_MISPRO.MISPROAS;
|
||
|
||
namespace GThinking.U20261363_N_XLXSBJ
|
||
{
|
||
public partial class XLBJD_WBBJDMX_MRDYWHList : SingleGridBase
|
||
{
|
||
XLBJD_WBBJDMX_MRDYWH entity = new XLBJD_WBBJDMX_MRDYWH();
|
||
XLBJD_WBBJDMX_MRDYWH_M queryentity = new XLBJD_WBBJDMX_MRDYWH_M();
|
||
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
this.UMID = 100860174;
|
||
this.UMName = "外部线缆产品导入";
|
||
this.CurMaster = Master;
|
||
this.ModuleGV = grdGrid;
|
||
this.CurEntity = entity;
|
||
this.CurQueryEntity = queryentity;
|
||
this.sURLTarget = "XLBJD_WBBJDMX_MRDYWHInfo.aspx";
|
||
this.sQueryURLTarget = "XLBJD_WBBJDMX_MRDYWHQuery.aspx";
|
||
this.PageHeight = 500;
|
||
this.PageWidth = 700;
|
||
|
||
base.DataKeyNames = new string[] { "XLXHID", "ZXJMS", "ZXJMZ" };
|
||
|
||
base.InitPage();
|
||
|
||
if (!IsPostBack)
|
||
{
|
||
Master_OnStandardQuery(null, null);
|
||
}
|
||
}
|
||
|
||
#region 模板事件
|
||
protected override void Master_OnStandardQuery(object sender, EventArgs e)
|
||
{
|
||
base.InitEntityByCondition();
|
||
entity.EntityTable.QuerySelSql = GetSql();
|
||
base.Master_OnStandardQuery(sender, e);
|
||
entity.GridDataBind(grdGrid, tSession);
|
||
}
|
||
|
||
protected override void moduleGV_PageIndexChanging(object sender, GridViewPageEventArgs e)
|
||
{
|
||
base.InitEntityByCondition();
|
||
entity.EntityTable.QuerySelSql = GetSql();
|
||
base.moduleGV_PageIndexChanging(sender, e);
|
||
grdGrid.SelectedIndex = -1;
|
||
}
|
||
|
||
protected override void moduleGV_RowDataBound(object sender, GridViewRowEventArgs e)
|
||
{
|
||
if (e.Row.RowType == DataControlRowType.DataRow)
|
||
{
|
||
LinkPageParam.AddString("XLXHID", grdGrid.DataKeys[e.Row.RowIndex]["XLXHID"].ToString().Trim());
|
||
LinkPageParam.AddString("ZXJMS", grdGrid.DataKeys[e.Row.RowIndex]["ZXJMS"].ToString().Trim());
|
||
LinkPageParam.AddString("ZXJMZ", grdGrid.DataKeys[e.Row.RowIndex]["ZXJMZ"].ToString().Trim());
|
||
}
|
||
base.moduleGV_RowDataBound(sender, e);
|
||
}
|
||
|
||
protected override void BeforeDelete(TDatabase db, ref bool ActionIsDone)
|
||
{
|
||
entity.Param.Add("XLXHID", grdGrid.DataKeys[grdGrid.SelectedIndex]["XLXHID"].ToString().Trim());
|
||
entity.Param.Add("ZXJMS", grdGrid.DataKeys[grdGrid.SelectedIndex]["ZXJMS"].ToString().Trim());
|
||
entity.Param.Add("ZXJMZ", grdGrid.DataKeys[grdGrid.SelectedIndex]["ZXJMZ"].ToString().Trim());
|
||
base.BeforeDelete(db, ref ActionIsDone);
|
||
}
|
||
|
||
protected override bool Master_AfterDeleteAction(object sender, EventArgs e)
|
||
{
|
||
|
||
if (!base.Master_AfterDeleteAction(sender, e))
|
||
{ return false; }
|
||
base.InitEntityByCondition();
|
||
entity.EntityTable.QuerySelSql = GetSql();
|
||
entity.GridDataBind(grdGrid, tSession);
|
||
grdGrid.SelectedIndex = -1;
|
||
return true;
|
||
}
|
||
#endregion
|
||
|
||
#region 自定义函数
|
||
|
||
private string GetSql()
|
||
{
|
||
StringBuilder strSQL = new StringBuilder();
|
||
strSQL.AppendLine(" select XLXHID,ZXJMS,ZXJMZ,DYDJID ");
|
||
strSQL.AppendLine(" from MRDYWH ");
|
||
strSQL.AppendLine(" where 1=1");
|
||
//型号模糊
|
||
if (!CurQueryEntity.FieldByName("XLXHIDJQPP").Value.ToString().Trim().ToUpper().Equals("TRUE"))
|
||
{
|
||
if (!string.IsNullOrEmpty(CurQueryEntity.FieldByName("XLXHID").Value.Trim()))
|
||
{
|
||
strSQL.AppendLine(" \r\n and XLXHID like :pXLXHID ");
|
||
entity.Param.Add("pXLXHID", "%" + CurQueryEntity.FieldByName("XLXHID").Value.Trim() + "%");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
string sXLXHID = CurQueryEntity.FieldByName("XLXHID").Value.Trim();
|
||
if (!string.IsNullOrEmpty(sXLXHID))
|
||
{
|
||
string[] sTemp = sXLXHID.Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||
if (sTemp.Length >= 2)
|
||
{
|
||
strSQL.AppendLine(" \r\n and " + CMISproDataBase.GetWhereEqual("XLXHID", sXLXHID));
|
||
}
|
||
else
|
||
{
|
||
strSQL.AppendLine(" \r\n and XLXHID = :pXLXHID ");
|
||
entity.Param.Add("pXLXHID", sXLXHID);
|
||
}
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(CurQueryEntity.FieldByName("DYDJID").Value.Trim()))
|
||
{
|
||
strSQL.AppendLine(" and " + CMISproDataBase.GetWhereEqual("DYDJID", CurQueryEntity.FieldByName("DYDJID").Value.Trim()));
|
||
}
|
||
strSQL.AppendLine(" order by XLXHID,ZXJMS,ZXJMZ ");
|
||
return strSQL.ToString();
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 控件事件
|
||
|
||
protected void btnDR_OnClick(object sender, EventArgs e)
|
||
{
|
||
TPageParams tpp = new TPageParams();
|
||
tpp.UrlPath = "XLBJD_WBBJDMX_MRDYWHDRInfo.aspx";
|
||
tpp.AddString("ClientExportFileURL", txtExportFileURL.ClientID.Trim());
|
||
OpenDialog(tpp);
|
||
}
|
||
|
||
protected void btnDR_MenuItemClick(object sender, string ItemIndex)
|
||
{
|
||
int index = Int32.Parse(ItemIndex);
|
||
switch (index)
|
||
{
|
||
case 0:
|
||
btnDC(sender, null);
|
||
break;
|
||
}
|
||
}
|
||
|
||
protected void btnDC(object sender, EventArgs e)
|
||
{
|
||
//定义文件名和临时路径
|
||
string sFILENAME = "模版导出.xls";
|
||
string m_tmpFilePath = FileService.CombineTempPath(Guid.NewGuid().ToString() + sFILENAME);
|
||
|
||
//创建DataTable并定义列结构
|
||
DataTable dt = new DataTable();
|
||
dt.TableName = "sheet1";
|
||
dt.Columns.Add("型号", typeof(string));
|
||
dt.Columns.Add("主芯截面始", typeof(string));
|
||
dt.Columns.Add("主芯截面止", typeof(string));
|
||
dt.Columns.Add("电压等级", typeof(string));
|
||
|
||
//创建DataSet并关联DataTable,供Excel生成工具使用
|
||
DataSet ds = new DataSet();
|
||
ds.Tables.Add(dt);
|
||
string sError = "";
|
||
|
||
NpoiCellData cd = new NpoiCellData();
|
||
cd.CellComment = new System.Collections.Generic.Dictionary<string, string>();
|
||
|
||
//配置工作表数据类型(NpoiSheetData)
|
||
NpoiSheetData sd = new NpoiSheetData();
|
||
sd.ColumnType = new System.Collections.Generic.Dictionary<string, NpoiColumnType>();
|
||
sd.ColumnType.Add("A", NpoiColumnType.String);
|
||
sd.ColumnType.Add("B", NpoiColumnType.String);
|
||
sd.ColumnType.Add("C", NpoiColumnType.String);
|
||
sd.ColumnType.Add("D", NpoiColumnType.String);
|
||
|
||
//配置单元格样式
|
||
sd.ColumnStyle = new System.Collections.Generic.Dictionary<string, NpoiColumnStyle>();
|
||
NpoiColumnStyle ct = new NpoiColumnStyle();
|
||
ct.DataFormat = "@"; // Excel文本格式
|
||
sd.ColumnStyle.Add("A", ct);
|
||
sd.ColumnStyle.Add("B", ct);
|
||
sd.ColumnStyle.Add("C", ct);
|
||
sd.ColumnStyle.Add("D", ct);
|
||
|
||
//冻结Excel工作表的第一行标题,方便用户滚动查看数据。
|
||
sd.FreezePaneRows = 1;
|
||
//生成Excel文件
|
||
TExcelData.CreateExcel_NPOI(m_tmpFilePath, ds, true, cd, sd, ref sError);
|
||
|
||
if (string.IsNullOrEmpty(sError))
|
||
{
|
||
System.IO.FileInfo file = new System.IO.FileInfo(m_tmpFilePath);
|
||
string URL = Page.ResolveClientUrl("~") + "/N_MODEL/Dialog/TempFileDownload.ashx?TempFileName=" + file.Name + "&FileName=外部报价单默认电压导入" + file.Extension;
|
||
string jsript = @"var JLDCDiv = document.createElement('div');JLDCDiv.style.width=0;JLDCDiv.style.height=0;JLDCDiv.id = 'DivifrDownLoad';"
|
||
+ " var ele=document.documentElement||document.body;ele.appendChild(JLDCDiv);var iJLDCfrm = document.createElement('iframe');iJLDCfrm.id = 'iJLDCfrmDownLoad';iJLDCfrm.src = '" + URL + "';"
|
||
+ "iJLDCfrm.style.width = 0;iJLDCfrm.style.height = 0; JLDCDiv.appendChild(iJLDCfrm);";
|
||
AJAXRunScript(this, "OPENJLDC", jsript);
|
||
}
|
||
else
|
||
{
|
||
ShowMessage("导出模板失败!");
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
}
|