提交代码
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
using BLL;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace FineUIPro.Web.TestRun.DriverPrepare
|
||||
@@ -16,7 +18,6 @@ namespace FineUIPro.Web.TestRun.DriverPrepare
|
||||
{
|
||||
GetButtonPower();
|
||||
BindGrid();
|
||||
btnNew.OnClientClick = Window1.GetShowReference("SchemePlanEdit.aspx") + "return false;";
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@@ -25,21 +26,10 @@ namespace FineUIPro.Web.TestRun.DriverPrepare
|
||||
//加载列表
|
||||
public void BindGrid()
|
||||
{
|
||||
string strSql = @"select * , u.UserName from DriverPrepare_SchemePlan chec"
|
||||
+ @" left join sys_User u on u.userId = chec.CompileMan where chec.ProjectId=@projectId";
|
||||
string strSql = @"select * from DriverPrepare_SchemePlanItem chec"
|
||||
+ @" left join DriverPrepare_SchemePlan u on u.SchemePlanId = chec.SchemePlanId where u.ProjectId=@projectId";
|
||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
listStr.Add(new SqlParameter("@projectId", this.CurrUser.LoginProjectId));
|
||||
if (!string.IsNullOrEmpty(this.SSchemePlanName.Text))
|
||||
{
|
||||
strSql += " AND SchemePlanName like @SchemePlanName";
|
||||
listStr.Add(new SqlParameter("@SchemePlanName", "%" + this.SSchemePlanName.Text.Trim() + "%"));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(this.SSchemePlanCode.Text))
|
||||
{
|
||||
strSql += " AND SchemePlanCode like @SchemePlanCode";
|
||||
listStr.Add(new SqlParameter("@SchemePlanCode", "%" + this.SSchemePlanCode.Text.Trim() + "%"));
|
||||
}
|
||||
|
||||
SqlParameter[] parameter = listStr.ToArray();
|
||||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||||
@@ -51,65 +41,6 @@ namespace FineUIPro.Web.TestRun.DriverPrepare
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 分页
|
||||
/// <summary>
|
||||
/// 分页索引事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
||||
{
|
||||
BindGrid();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页下拉框事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
||||
BindGrid();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
||||
{
|
||||
Grid1.SortDirection = e.SortDirection;
|
||||
Grid1.SortField = e.SortField;
|
||||
BindGrid();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 搜索
|
||||
/// <summary>
|
||||
/// 搜索
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnSearch_Click(object sender, EventArgs e)
|
||||
{
|
||||
BindGrid();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 关闭弹出窗口
|
||||
/// <summary>
|
||||
/// 关闭弹出窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
||||
{
|
||||
BindGrid();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 编辑
|
||||
protected void btnMenuModify_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -136,7 +67,7 @@ namespace FineUIPro.Web.TestRun.DriverPrepare
|
||||
Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SchemePlanEdit.aspx?id={0}", Grid1.SelectedRowID, "编辑 - ")));
|
||||
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("SchemePlanItemAdd.aspx?SchemePlanItemId={0}", Grid1.SelectedRowID, "编辑 - ")));
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -147,11 +78,7 @@ namespace FineUIPro.Web.TestRun.DriverPrepare
|
||||
{
|
||||
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
||||
{
|
||||
var DriverDataIdInfo = BLL.DriverPrepareSchemePlanService.GetDriverPlanById(Grid1.SelectedRowID);
|
||||
if (DriverDataIdInfo != null)
|
||||
{
|
||||
BLL.DriverPrepareSchemePlanService.DeleteDriverPlan(Grid1.SelectedRowID);
|
||||
}
|
||||
BLL.DriverPrepareSchemePlanItemService.DeleteSchemePlanItemById(Grid1.SelectedRowID);
|
||||
}
|
||||
BindGrid();
|
||||
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
|
||||
@@ -159,22 +86,6 @@ namespace FineUIPro.Web.TestRun.DriverPrepare
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Grid行点击事件
|
||||
/// <summary>
|
||||
/// Grid行点击事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
||||
{
|
||||
string id = Grid1.DataKeys[e.RowIndex][0].ToString();
|
||||
if (e.CommandName == "AttachUrl")
|
||||
{
|
||||
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/TestRun/DriverPrepare/SchemePlan&menuId={1}", id, BLL.Const.SchemePlanMenuId)));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 权限设置
|
||||
/// <summary>
|
||||
/// 权限设置
|
||||
@@ -200,5 +111,160 @@ namespace FineUIPro.Web.TestRun.DriverPrepare
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 搜索
|
||||
/// <summary>
|
||||
/// 搜索
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnNew_Click(object sender, EventArgs e)
|
||||
{
|
||||
string window = String.Format("SchemePlanItemAdd.aspx", "新增 - ");
|
||||
PageContext.RegisterStartupScript(Window2.GetSaveStateReference(hdItemsString.ClientID) + Window2.GetShowReference(window));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 关闭弹出窗口
|
||||
/// <summary>
|
||||
/// 关闭弹出窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
||||
{
|
||||
BindGrid();
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 选择事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnSelect_Click(object sender, EventArgs e)
|
||||
{
|
||||
//JArray mergedData = Grid1.GetMergedData();
|
||||
//string names = string.Empty;
|
||||
//foreach (JObject mergedRow in mergedData)
|
||||
//{
|
||||
// string status = mergedRow.Value<string>("status");
|
||||
// JObject values = mergedRow.Value<JObject>("values");
|
||||
// names += values.Value<string>("SolutionName").ToString() + ",";
|
||||
//}
|
||||
//if (!string.IsNullOrEmpty(names))
|
||||
//{
|
||||
// hdItemsString.Text = names.Substring(0, names.Length - 1);
|
||||
//}
|
||||
Model.DriverPrepare_SchemePlan plan = BLL.DriverPrepareSchemePlanService.GetDriverPlanByProjectId(this.CurrUser.LoginProjectId);
|
||||
string schemePlanId = string.Empty;
|
||||
if (plan != null)
|
||||
{
|
||||
schemePlanId = plan.SchemePlanId;
|
||||
}
|
||||
string window = String.Format("SchemePlanItemSelect.aspx?SchemePlanId={0}", schemePlanId, "选择 - ");
|
||||
PageContext.RegisterStartupScript(Window1.GetShowReference(window));
|
||||
}
|
||||
|
||||
#region 导出按钮
|
||||
/// 导出按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnOut_Click(object sender, EventArgs e)
|
||||
{
|
||||
string rootPath = Server.MapPath("~/");
|
||||
string initTemplatePath = string.Empty;
|
||||
string uploadfilepath = string.Empty;
|
||||
string newUrl = string.Empty;
|
||||
string filePath = string.Empty;
|
||||
initTemplatePath = Const.SchemePlanTemplateUrl;
|
||||
uploadfilepath = rootPath + initTemplatePath;
|
||||
Model.DriverPrepare_SchemePlan plan = BLL.DriverPrepareSchemePlanService.GetDriverPlanByProjectId(this.CurrUser.LoginProjectId);
|
||||
if (plan != null)
|
||||
{
|
||||
string projectName = BLL.ProjectService.GetProjectNameByProjectId(plan.ProjectId);
|
||||
newUrl = uploadfilepath.Replace(".xlsx", "(" + projectName + ")" + ".xlsx");
|
||||
File.Copy(uploadfilepath, newUrl);
|
||||
// 第一步:读取文件流
|
||||
NPOI.SS.UserModel.IWorkbook workbook;
|
||||
using (FileStream stream = new FileStream(newUrl, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
workbook = new NPOI.XSSF.UserModel.XSSFWorkbook(stream);
|
||||
}
|
||||
// 创建单元格样式
|
||||
NPOI.SS.UserModel.ICellStyle cellStyle = workbook.CreateCellStyle();
|
||||
cellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
|
||||
cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
|
||||
var font = workbook.CreateFont();
|
||||
font.FontHeightInPoints = 11;
|
||||
cellStyle.SetFont(font);
|
||||
NPOI.SS.UserModel.ICellStyle cellStyle0 = workbook.CreateCellStyle();
|
||||
cellStyle0.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle0.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle0.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle0.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle0.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
|
||||
cellStyle0.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
|
||||
var font0 = workbook.CreateFont();
|
||||
font0.FontHeightInPoints = 12;
|
||||
font0.IsBold = true;
|
||||
cellStyle0.SetFont(font0);
|
||||
// 第二步:创建新数据行
|
||||
NPOI.SS.UserModel.ISheet sheet = workbook.GetSheetAt(0);
|
||||
NPOI.SS.UserModel.IRow row = sheet.GetRow(0);
|
||||
NPOI.SS.UserModel.ICell cell;
|
||||
cell = row.GetCell(0);
|
||||
cell.CellStyle = cellStyle0;
|
||||
cell.SetCellValue(projectName + "试车方案");
|
||||
var items = BLL.DriverPrepareSchemePlanItemService.GetSchemePlanItemByschemePlanId(plan.SchemePlanId);
|
||||
int i = 2;
|
||||
foreach (var item in items)
|
||||
{
|
||||
// 第二步:创建新数据行
|
||||
row = sheet.CreateRow(i);
|
||||
// 添加数据
|
||||
cell = row.CreateCell(0);
|
||||
cell.CellStyle = cellStyle;
|
||||
cell.SetCellValue((i-1).ToString());
|
||||
cell = row.CreateCell(1);
|
||||
cell.CellStyle = cellStyle;
|
||||
cell.SetCellValue(item.SolutionName);
|
||||
cell = row.CreateCell(2);
|
||||
cell.CellStyle = cellStyle;
|
||||
cell.SetCellValue(string.Empty);
|
||||
cell = row.CreateCell(3);
|
||||
cell.CellStyle = cellStyle;
|
||||
cell.SetCellValue(string.Empty);
|
||||
i++;
|
||||
}
|
||||
// 第三步:写入文件流
|
||||
using (FileStream stream = new FileStream(newUrl, FileMode.Create, FileAccess.Write))
|
||||
{
|
||||
workbook.Write(stream);
|
||||
workbook.Close();
|
||||
}
|
||||
string fileName = Path.GetFileName(newUrl);
|
||||
FileInfo info = new FileInfo(newUrl);
|
||||
long fileSize = info.Length;
|
||||
Response.Clear();
|
||||
Response.ContentType = "application/x-zip-compressed";
|
||||
Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
||||
Response.AddHeader("Content-Length", fileSize.ToString());
|
||||
Response.TransmitFile(newUrl, 0, fileSize);
|
||||
Response.Flush();
|
||||
Response.Close();
|
||||
File.Delete(newUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert.ShowInTop("当前无记录,无法导出!", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user