private void InitPage() { OleDbConnection conn = new OleDbConnection(Dal.OleDbHlper.ConnectionString); conn.Open(); //获取当前活动类型编码 string strActivityType = Session["ActivityType"].ToString(); //获取当前活动ID int iActivityID = BLL.Activity.GetActivityID(strActivityType, conn); string PrizeID = Request["PrizeID"].ToString(); txtPrizeID.Text = PrizeID; Dal.Models.Prize prize = BLL.Prize.GetPrize(Convert.ToInt32(PrizeID), conn); txtMultipleVoteRound.Text = prize.MultipleVoteRound.ToString(); lblMultipleVoteRound.Text = txtMultipleVoteRound.Text == "" ? "1" : txtMultipleVoteRound.Text; labPrizeName.Text = prize.PrizeName.ToString(); string PrizeType = Request["PrizeType"].ToString(); string prizeLevel = ""; if (PrizeType == "0301" || PrizeType == "0304")//综合奖多轮投、专项奖多轮投 { int sum = 0; Dal.Models.Prize prizeList = BLL.Prize.GetPrize(Convert.ToInt32(PrizeID), conn); if (lblMultipleVoteRound.Text.Trim() == "1")//第一轮都三等奖的,名额全部显示 { lblPrizeNum.Text = prizeList.AwardCount.ToString(); } else if (lblMultipleVoteRound.Text.Trim() == "2") { sum = prizeList.FirstPrize.Value + prizeList.SecondPrize.Value; lblPrizeNum.Text = sum.ToString(); } else if (lblMultipleVoteRound.Text.Trim() == "3") { sum = prizeList.FirstPrize.Value; lblPrizeNum.Text = sum.ToString(); } } else if (PrizeType == "0302")//单项奖 { prizeLevel = "0404"; lblPrizeNum.Text = BLL.Prize.GetPrizeLevel(Convert.ToInt32(PrizeID), prizeLevel, conn).LevelLimitNumber.ToString(); } else if (PrizeType == "0303")//中小创 { prizeLevel = "0405"; lblPrizeNum.Text = BLL.Prize.GetPrizeLevel(Convert.ToInt32(PrizeID), prizeLevel, conn).LevelLimitNumber.ToString(); } conn.Close(); }
public static void SetPrizeLevel( Dal.Models.Prize prize, List <int> LstPrizeLimitNum, OleDbConnection conn, OleDbTransaction tran = null) { if (prize == null || LstPrizeLimitNum == null || LstPrizeLimitNum.Count < 1) { throw new NoNullAllowedException("参数错误!"); } switch (prize.PrizeTypeCode) { case "0301": //当奖项为综合奖时 case "0304": if (LstPrizeLimitNum.Count < 3) { throw new NoNullAllowedException("参数错误!"); } for (int i = 0; i < LstPrizeLimitNum.Count; i++) { SetPrizeLevel(new Dal.Models.PrizeLevel() { LevelCode = "040" + (i + 1).ToString(), PrizeID = prize.PrizeID, LevelLimitNumber = LstPrizeLimitNum[i] }, conn, tran); } break; case "0302": //当奖项为单项奖时 SetPrizeLevel(new Dal.Models.PrizeLevel() { LevelCode = "0404", PrizeID = prize.PrizeID, LevelLimitNumber = LstPrizeLimitNum[0] }, conn, tran); break; case "0303": //当奖项为中小创时 SetPrizeLevel(new Dal.Models.PrizeLevel() { LevelCode = "0405", PrizeID = prize.PrizeID, LevelLimitNumber = LstPrizeLimitNum[0] }, conn, tran); break; default: break; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Dal.Models.TemplateInfo tempInfo = (Dal.Models.TemplateInfo)Session["TemplateInfo"]; OleDbConnection conn = new OleDbConnection(Dal.OleDbHlper.ConnectionString); conn.Open(); Dal.Models.Declaration decl = BLL.Declaration.GetDeclaration(Convert.ToInt32(tempInfo.DeclarationID), conn); Dal.Models.Prize Prize = BLL.Prize.GetPrize(Convert.ToInt32(decl.PrizeID), conn); rdlPrize.Text = Prize.PrizeName; conn.Close(); } }
public static void SetOrdinal( Dal.Models.Prize prize, OleDbConnection conn, OleDbTransaction tran = null) { if (prize == null || prize.PrizeID == null || prize.SpecialtyID == null) { throw new Exception("参数错误!"); } List <Dal.Models.Prize> lstPrize = GetPrizeList( prize.SpecialtyID.Value, conn, tran).Where(p => p.PrizeID != prize.PrizeID).ToList(); if (prize.Ordinal == null || prize.Ordinal > lstPrize.Count) { lstPrize.Add(prize); } else if (prize.Ordinal <= 0) { lstPrize.Insert(0, prize); } else { lstPrize.Insert(prize.Ordinal.Value - 1, prize); } string strSql = " UPDATE Prize set Ordinal = ? where PrizeID = ? "; for (int i = 0; i < lstPrize.Count; i++) { Dal.OleDbHlper.ExecuteNonQuery(strSql, conn, CommandType.Text, tran , new OleDbParameter("@Ordinal", OleDbType.VarWChar) { Value = i + 1 } , new OleDbParameter("@PrizeID", OleDbType.Integer) { Value = lstPrize[i].PrizeID.Value } ); } }
public static int CheckPrize(Dal.Models.Prize prize, OleDbConnection conn, OleDbTransaction tran) { if (string.IsNullOrEmpty(prize.PrizeName) || prize.SpecialtyID == null || prize.SpecialtyID == null) { throw new Exception("参数错误!"); } Dal.Models.Specialty specialty = Specialty.GetSpecialty(prize.SpecialtyID.Value, conn, tran); // 所选专业不存在 if (specialty == null) { throw new Exception("所选专业不存在!"); } if ((specialty.ChildCount ?? 0) > 0) { throw new Exception("奖项创建失败,该专业下已存在子专业,无法创建奖项。"); } // 同一专业中,奖项不允许重名 Dal.Models.Prize prizeOriginal = GetPrize(prize.PrizeName, prize.SpecialtyID.Value, conn, tran); if (prize.PrizeID != prizeOriginal.PrizeID) { throw new Exception("同一专业中,奖项不允许重名!"); } //奖项类别为空时,默认类别为综合奖 if (string.IsNullOrEmpty(prize.PrizeTypeCode) || !(new string[] { "0301", "0302", "0303", "0304" }).Contains(prize.PrizeTypeCode)) { prize.PrizeTypeCode = "0301"; } if (string.IsNullOrEmpty(prize.TemplateCode)) { prize.TemplateCode = Specialty.GetTempletCode(prize.SpecialtyID.Value, conn, tran); } return(specialty.ActivityID.Value); }
public static int EnablePrizeVote(Dal.Models.Prize prize, OleDbConnection conn, OleDbTransaction tran) { StringBuilder sbSql = new StringBuilder(); sbSql.Append(" UPDATE Prize "); sbSql.Append(" SET IsStopVote = ? "); sbSql.Append(" WHERE PrizeID = ? "); int iResult = Dal.OleDbHlper.ExecuteNonQuery( sbSql.ToString(), conn, CommandType.Text, tran , new OleDbParameter("@IsStopVote", OleDbType.Boolean) { Value = false } , new OleDbParameter("@PrizeID", OleDbType.Integer) { Value = prize.PrizeID } ); return(iResult); }
public static int SetPrize( Dal.Models.Prize prize, List <int> LstPrizeLimitNum, OleDbConnection conn, OleDbTransaction tran) { if (prize == null || string.IsNullOrEmpty(prize.PrizeName) || prize.SpecialtyID == null) { throw new Exception("参数错误!"); } Dal.Models.Specialty specialty = Specialty.GetSpecialty(prize.SpecialtyID.Value, conn, tran); // 所选专业不存在 if (specialty == null) { throw new Exception("所选专业不存在!"); } if ((specialty.ChildCount ?? 0) > 0) { throw new Exception("奖项创建失败,该专业下已存在子专业,无法创建奖项。"); } // 同一专业中,奖项不允许重名 Dal.Models.Prize prizeOriginal = GetPrize(prize.PrizeName, prize.SpecialtyID.Value, conn, tran); if (prizeOriginal != null && prize.PrizeID != prizeOriginal.PrizeID) { throw new Exception("同一专业中,奖项不允许重名!"); } //奖项类别为空时,默认类别为综合奖 if (string.IsNullOrEmpty(prize.PrizeTypeCode) || !(new string[] { "0301", "0302", "0303", "0304" }).Contains(prize.PrizeTypeCode)) { prize.PrizeTypeCode = "0301"; } if (prize.ParticipantLimit == null) { prize.ParticipantLimit = Convert.ToInt32( SysConstant.GetConstant(prize.PrizeTypeCode, conn, tran).CorrelationValue); } if (string.IsNullOrEmpty(prize.TemplateCode)) { prize.TemplateCode = specialty.TemplateCode; } StringBuilder sbSql = new StringBuilder(); if (prize.PrizeID == null) { sbSql.Append(" INSERT INTO Prize ( "); sbSql.Append(" PrizeName"); sbSql.Append(" ,SpecialtyID "); sbSql.Append(" ,PrizeTypeCode "); sbSql.Append(" ,TemplateCode "); sbSql.Append(" ,IsMultipleVoting "); sbSql.Append(" ,VoteType "); sbSql.Append(" ,ParticipantLimit "); sbSql.Append(" ,AppendixDiscription "); sbSql.Append(" ,CreateTime "); sbSql.Append(" ,LastUpdateTime "); sbSql.Append(" ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, GETDATE(), GETDATE() ) "); int iResult = Dal.OleDbHlper.ExecuteNonQuery( sbSql.ToString(), conn, CommandType.Text, tran , new OleDbParameter("@PrizeName", OleDbType.VarWChar) { Value = prize.PrizeName } , new OleDbParameter("@SpecialtyID", OleDbType.Integer) { Value = prize.SpecialtyID } , new OleDbParameter("@PrizeTypeCode", OleDbType.VarWChar) { Value = prize.PrizeTypeCode } , new OleDbParameter("@TemplateCode", OleDbType.VarWChar) { Value = prize.TemplateCode } , new OleDbParameter("@IsMultipleVoting", OleDbType.Boolean) { Value = prize.IsMultipleVoting } , new OleDbParameter("@VoteType", OleDbType.VarWChar) { Value = prize.VoteType } , new OleDbParameter("@ParticipantNumber", OleDbType.Integer) { Value = prize.ParticipantLimit } , new OleDbParameter("@AppendixDiscription", OleDbType.VarWChar) { Value = prize.AppendixDiscription } ); prize.PrizeID = GetPrize(prize.PrizeName, prize.SpecialtyID.Value, conn, tran).PrizeID; } else { sbSql.Append(" UPDATE Prize "); sbSql.Append(" SET PrizeName = ? "); sbSql.Append(" ,IsMultipleVoting = ? "); sbSql.Append(" ,VoteType = ? "); sbSql.Append(" ,ParticipantLimit = ? "); sbSql.Append(" ,AppendixDiscription = ? "); sbSql.Append(" ,LastUpdateTime = GETDATE() "); sbSql.Append(" WHERE PrizeID = ? "); int iResult = Dal.OleDbHlper.ExecuteNonQuery( sbSql.ToString(), conn, CommandType.Text, tran , new OleDbParameter("@PrizeName", OleDbType.VarWChar) { Value = prize.PrizeName } , new OleDbParameter("@IsMultipleVoting", OleDbType.Boolean) { Value = prize.IsMultipleVoting } , new OleDbParameter("@VoteType", OleDbType.VarWChar) { Value = prize.VoteType } , new OleDbParameter("@ParticipantLimit", OleDbType.Integer) { Value = prize.ParticipantLimit } , new OleDbParameter("@AppendixDiscription", OleDbType.VarWChar) { Value = prize.AppendixDiscription } , new OleDbParameter("@PrizeID", OleDbType.Integer) { Value = prize.PrizeID } ); } //奖项数量 SetPrizeLevel(prize, LstPrizeLimitNum, conn, tran); SetOrdinal(prize, conn, tran); return(prize.PrizeID.Value); }
protected void btnExport_Click(object sender, EventArgs e) { OleDbConnection conn = new OleDbConnection(Dal.OleDbHlper.ConnectionString); conn.Open(); Dal.Models.UserInfo user = (Dal.Models.UserInfo)Session["UserInfo"]; string strActivityType = Session["ActivityType"].ToString(); Dal.Models.Activity activity = BLL.Activity.GetActivity(strActivityType, conn); if (activity == null) { Response.Redirect("~/View/Mutual/HomePage.aspx"); conn.Close(); return; } Dal.Models.Prize prize = BLL.Prize.GetPrize(Convert.ToInt32(hfPrizeID.Value), conn); List <Dal.Models.VoteResult> lstVoteResult = BLL.Vote.GetVoteResult(prize.PrizeID.Value, prize.MultipleVoteRound ?? 1, conn); DataTable dtExpert = Dal.DataTableExtensions.ToDataTable(lstVoteResult); string root = System.Web.HttpContext.Current.Request.PhysicalApplicationPath; string TempletFileName = root + "Content/Template/投票.xls"; //模板文件 string ReportFileName = Server.MapPath("~/Content/Temp/ExcelTemp/" + prize.PrizeName + "投票结果.xls"); //导出文件 try { NPOI.HSSF.UserModel.HSSFWorkbook wk = new NPOI.HSSF.UserModel.HSSFWorkbook(); NPOI.SS.UserModel.ISheet ws = wk.CreateSheet(prize.PrizeName + "投票结果"); NPOI.SS.UserModel.IRow row = null; NPOI.SS.UserModel.ICellStyle style = wk.CreateCellStyle(); style.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; style.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; style.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; style.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; style.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; row = ws.CreateRow(0); row.HeightInPoints = 35; SetNewCell(row, 0, "排序", style); SetNewCell(row, 1, "项目编码", style); SetNewCell(row, 2, "项目名称", style); SetNewCell(row, 3, "申报单位", style); SetNewCell(row, 4, "申报奖项", style); SetNewCell(row, 5, "奖项类别", style); SetNewCell(row, 6, "投票方式", style); if (prize.PrizeTypeCode == "0302" || prize.PrizeTypeCode == "0303" || ((prize.VoteType == "2202" || prize.VoteType == "2203") && prize.MultipleVoteRound == 1)) { SetNewCell(row, 7, "推荐", style); SetNewCell(row, 8, "不推荐", style); SetNewCell(row, 9, "缓评", style); SetNewCell(row, 10, "转出", style); } else if (prize.VoteType == "2202" && prize.MultipleVoteRound == 2) { SetNewCell(row, 7, "一等奖", style); SetNewCell(row, 8, "二等奖", style); SetNewCell(row, 9, "三等奖", style); } else if (prize.VoteType == "2201" && (prize.PrizeTypeCode == "0301" || prize.PrizeTypeCode == "0304")) { SetNewCell(row, 7, "一等奖", style); SetNewCell(row, 8, "二等奖", style); SetNewCell(row, 9, "三等奖", style); SetNewCell(row, 10, "不推荐", style); SetNewCell(row, 11, "缓评", style); SetNewCell(row, 12, "转出", style); } else { if (prize.MultipleVoteRound == 2) { SetNewCell(row, 7, "一等奖、二等奖", style); SetNewCell(row, 8, "三等奖", style); } else { SetNewCell(row, 7, "一等奖", style); SetNewCell(row, 8, "二等奖", style); } } for (int i = 0; i < dtExpert.Rows.Count; i++) { row = ws.CreateRow(i + 1); SetNewCell(row, 0, dtExpert.Rows[i]["Ordinal"].ToString(), style); SetNewCell(row, 1, dtExpert.Rows[i]["DeclarationCode"].ToString(), style); SetNewCell(row, 2, dtExpert.Rows[i]["DeclarationName"].ToString(), style); SetNewCell(row, 3, dtExpert.Rows[i]["OrganizationName"].ToString(), style); SetNewCell(row, 4, dtExpert.Rows[i]["PrizeName"].ToString(), style); SetNewCell(row, 5, dtExpert.Rows[i]["PrizeType"].ToString(), style); SetNewCell(row, 6, dtExpert.Rows[i]["VoteTypeText"].ToString(), style); if (prize.PrizeTypeCode == "0302" || prize.PrizeTypeCode == "0303" || ((prize.VoteType == "2202" || prize.VoteType == "2203") && prize.MultipleVoteRound == 1)) { SetNewCell(row, 7, dtExpert.Rows[i]["Recommended"].ToString(), style); SetNewCell(row, 8, dtExpert.Rows[i]["NotRecommended"].ToString(), style); SetNewCell(row, 9, dtExpert.Rows[i]["SlowRating"].ToString(), style); SetNewCell(row, 10, dtExpert.Rows[i]["TurnOut"].ToString(), style); } else if (prize.VoteType == "2202" && prize.MultipleVoteRound == 2) { SetNewCell(row, 7, dtExpert.Rows[i]["FirstPrize"].ToString(), style); SetNewCell(row, 8, dtExpert.Rows[i]["SecondPrize"].ToString(), style); SetNewCell(row, 9, dtExpert.Rows[i]["ThirdPrize"].ToString(), style); } else if (prize.VoteType == "2201" && (prize.PrizeTypeCode == "0301" || prize.PrizeTypeCode == "0304")) { SetNewCell(row, 7, dtExpert.Rows[i]["FirstPrize"].ToString(), style); SetNewCell(row, 8, dtExpert.Rows[i]["SecondPrize"].ToString(), style); SetNewCell(row, 9, dtExpert.Rows[i]["ThirdPrize"].ToString(), style); SetNewCell(row, 10, dtExpert.Rows[i]["NotRecommended"].ToString(), style); SetNewCell(row, 11, dtExpert.Rows[i]["SlowRating"].ToString(), style); SetNewCell(row, 12, dtExpert.Rows[i]["TurnOut"].ToString(), style); } else { SetNewCell(row, 7, dtExpert.Rows[i]["Recommended"].ToString(), style); SetNewCell(row, 8, dtExpert.Rows[i]["NotRecommended"].ToString(), style); } } ws.ForceFormulaRecalculation = true; //先删除上一个临时文件 if (File.Exists(ReportFileName)) { FileInfo fi = new FileInfo(ReportFileName); if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1) { fi.Attributes = FileAttributes.Normal; } File.Delete(ReportFileName); } //创建临时文件写入数据 using (FileStream filess = File.OpenWrite(ReportFileName)) { wk.Write(filess); } } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); return; } System.IO.FileInfo filet = new System.IO.FileInfo(ReportFileName); Response.Clear(); Response.Charset = "GB2312"; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(prize.PrizeName + "投票结果.xls")); Response.AddHeader("Content-Length", filet.Length.ToString()); Response.ContentType = "application/ms-excel"; Response.WriteFile(filet.FullName); Response.End(); conn.Close(); }
protected void Page_Load(object sender, EventArgs e) { try { OleDbConnection conn = new OleDbConnection(Dal.OleDbHlper.ConnectionString); conn.Open(); OleDbTransaction trans = conn.BeginTransaction(); DeclarationName.Text = Decl.DeclarationName; DeclarationUnit.Text = Org.OrganizationName; litDeclarationUnit.Text = Org.OrganizationName; SurveylitDeclarationUnit.Text = Org.OrganizationName; txtMaiDeclarationUnit.Text = Org.OrganizationName; Dal.Models.UserInfo user = (Dal.Models.UserInfo)Session["UserInfo"]; txtUserType.Text = user.UserType; Dal.Models.Prize prize = BLL.Prize.GetPrize(Convert.ToInt32(Decl.PrizeID), conn, trans); uPrize.InnerText = prize.PrizeName; Dal.Models.Specialty spec = BLL.Specialty.GetSpecialty(Convert.ToInt32(prize.SpecialtyID), conn, trans); IsAllowUpdate.Value = spec.IsAllowUpdate.ToString(); List <Dal.Models.TemplateConstant> sys = BLL.SysConstant.GetSysConstantListOfConstantDiscription(prize.TemplateCode, conn, trans); List <Dal.Models.Declaration_Data> decl = BLL.Declaration.GetDeclarationDivisionList(Convert.ToInt32(Decl.DeclarationID), sys[1].KeyValue, sys[0].KeyValue, conn, trans); TemplateCode.Value = prize.TemplateCode; txtdeclID.Text = Decl.DeclarationID.ToString(); if (prize.TemplateCode == "0216" || prize.TemplateCode == "0217" || prize.TemplateCode == "0218") { if (!string.IsNullOrEmpty(decl[0].Data)) { txtCooperationUnit2.Text = decl[0].Data; } if (!string.IsNullOrEmpty(decl[2].Data)) { txtUndertakeWork2.Text = decl[2].Data; } if (!string.IsNullOrEmpty(decl[3].Data)) { txtCooperationUnit3.Text = decl[3].Data; } if (!string.IsNullOrEmpty(decl[5].Data)) { txtUndertakeWork3.Text = decl[5].Data; } if (!string.IsNullOrEmpty(decl[6].Data)) { txtCooperationUnit4.Text = decl[6].Data; } if (!string.IsNullOrEmpty(decl[8].Data)) { txtUndertakeWork4.Text = decl[8].Data; } if (!string.IsNullOrEmpty(decl[9].Data)) { txtCooperationUnit5.Text = decl[9].Data; } if (!string.IsNullOrEmpty(decl[11].Data)) { txtUndertakeWork5.Text = decl[11].Data; } } else { if (!string.IsNullOrEmpty(decl[0].Data)) { txtDeclarationUnit2.Text = decl[0].Data; SurveylitDeclarationUnit2.Text = decl[0].Data; if (!string.IsNullOrEmpty(decl[2].Data)) { Division2.Value = decl[2].Data; SetSurveyCollaborativePhase("SurveyCollaborativePhase2_", decl[2].Data.Split(',')); } } if (!string.IsNullOrEmpty(decl[3].Data)) { txtDeclarationUnit3.Text = decl[3].Data; SurveylitDeclarationUnit3.Text = decl[3].Data; if (!string.IsNullOrEmpty(decl[5].Data)) { Division3.Value = decl[5].Data; SetSurveyCollaborativePhase("SurveyCollaborativePhase3_", decl[5].Data.Split(',')); } } if (!string.IsNullOrEmpty(decl[6].Data)) { txtDeclarationUnit4.Text = decl[6].Data; SurveylitDeclarationUnit4.Text = decl[6].Data; if (!string.IsNullOrEmpty(decl[8].Data)) { Division4.Value = decl[8].Data; SetSurveyCollaborativePhase("SurveyCollaborativePhase4_", decl[8].Data.Split(',')); } } if (!string.IsNullOrEmpty(decl[9].Data)) { txtDeclarationUnit5.Text = decl[9].Data; SurveylitDeclarationUnit5.Text = decl[9].Data; if (!string.IsNullOrEmpty(decl[11].Data)) { Division5.Value = decl[11].Data; SetSurveyCollaborativePhase("SurveyCollaborativePhase5_", decl[11].Data.Split(',')); } } } trans.Commit(); conn.Close(); } catch { } }
protected void ExportAward_Click(object sender, EventArgs e) { int iPrizeID = 0; int.TryParse(hfPrizeID.Value, out iPrizeID); OleDbConnection conn = new OleDbConnection(Dal.OleDbHlper.ConnectionString); conn.Open(); List <Dal.Models.AwardResult> list = BLL.Vote.GetAwardResultReport(iPrizeID, conn); Dal.Models.Prize prize = BLL.Prize.GetPrize(iPrizeID, conn); string ReportFileName = System.Web.HttpContext.Current.Server.MapPath("~/Content/Temp/ExcelTemp/投票结果_" + prize.PrizeName + ".xls"); try { NPOI.HSSF.UserModel.HSSFWorkbook wk = new NPOI.HSSF.UserModel.HSSFWorkbook(); NPOI.SS.UserModel.ISheet ws = wk.CreateSheet("投票结果"); NPOI.SS.UserModel.IRow row = null; NPOI.SS.UserModel.ICellStyle style = wk.CreateCellStyle(); style.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; style.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; style.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; style.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; style.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; row = ws.CreateRow(0); row.HeightInPoints = 35; SetNewCell(row, 0, "排名", style); //增加同名奖内部排序 SetNewCell(row, 1, "同名奖内部排序", style); SetNewCell(row, 2, "项目名称", style); SetNewCell(row, 3, "申报单位", style); //SetNewCell(row, 3, "申报奖项", style); SetNewCell(row, 4, "获奖结果", style); ws.SetColumnWidth(0, 2000); //设置同名奖内部排序列宽 ws.SetColumnWidth(1, 3500); ws.SetColumnWidth(2, 10000); ws.SetColumnWidth(3, 10000); ws.SetColumnWidth(4, 4000); for (int i = 0; i < list.Count(); i++) { row = ws.CreateRow(i + 1); SetNewCell(row, 0, list[i].Ordinal.ToString(), style); //写入同名奖内部排序 SetNewCell(row, 1, list[i].InnerOrdinal.ToString(), style); SetNewCell(row, 2, list[i].DeclarationName.ToString(), style); SetNewCell(row, 3, list[i].OrganizationName.ToString(), style); //SetNewCell(row, 3, list[i].PrizeName.ToString(), style); //SetNewCell(row, 3, BLL.Vote.GetAwardsStatus(list[i].VoteCode.ToString(), list[i].PrizeLevelCode), style); SetNewCell(row, 4, list[i].AwardCodeText, style); } //添加专家签名 row = ws.CreateRow(list.Count() + 2); SetNewCell(row, 1, "专家签名:"); //添加日期 row = ws.CreateRow(list.Count() + 6); SetNewCell(row, 3, "日期:"); ws.ForceFormulaRecalculation = true; //先删除上一个临时文件 if (File.Exists(ReportFileName)) { FileInfo fi = new FileInfo(ReportFileName); if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1) { fi.Attributes = FileAttributes.Normal; } File.Delete(ReportFileName); } //创建临时文件写入数据 using (FileStream filess = File.OpenWrite(ReportFileName)) { wk.Write(filess); } } catch (Exception ex) { Response.Write(JsonConvert.SerializeObject(ex.Message)); if (conn != null && conn.State != ConnectionState.Closed) { conn.Close(); } conn.Dispose(); return; } if (conn != null && conn.State != ConnectionState.Closed) { conn.Close(); } conn.Dispose(); System.IO.FileInfo filet = new System.IO.FileInfo(ReportFileName); Response.Clear(); Response.Charset = "GB2312"; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.AddHeader("Content-Disposition", "attachment; filename=AwardResult_" + DateTime.Now.ToFileTime().ToString() + ".xls"); Response.AddHeader("Content-Length", filet.Length.ToString()); Response.ContentType = "application/ms-excel"; Response.WriteFile(filet.FullName); Response.End(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { OleDbConnection conn = new OleDbConnection(Dal.OleDbHlper.ConnectionString); conn.Open(); List <Dal.Models.SysConstant> lstConstant = BLL.SysConstant.GetConstantList("09", conn); Dal.Models.Prize prize = BLL.Prize.GetPrize(Convert.ToInt32(Decl.PrizeID), conn); conn.Close(); try { PeopleNum.Text = prize.ParticipantLimit.ToString(); } catch { PeopleNum.Text = "0"; } DropDownList ddl; for (int i = 1; i <= 15; i++) { ddl = ((DropDownList)tblParticipant.FindControl("IDType" + i.ToString())); SetDropDownList(ddl, lstConstant); } if (ParticipantList != null) { int j = 0; for (int i = 1; i <= 15; i++) { TextBox ParticipantName = (TextBox)tblParticipant.Rows[i].FindControl("ParticipantName" + i.ToString()); TextBox AcademicTitle = (TextBox)tblParticipant.Rows[i].FindControl("AcademicTitle" + i.ToString()); TextBox Speciality = (TextBox)tblParticipant.Rows[i].FindControl("Speciality" + i.ToString()); TextBox Duties = (TextBox)tblParticipant.Rows[i].FindControl("Duties" + i.ToString()); DropDownList IDType = (DropDownList)tblParticipant.Rows[i].FindControl("IDType" + i.ToString()); TextBox IDNumber = (TextBox)tblParticipant.Rows[i].FindControl("IDNumber" + i.ToString()); TextBox Workplace = (TextBox)tblParticipant.Rows[i].FindControl("Workplace" + i.ToString()); ParticipantName.Attributes.Add("data", "Participant"); AcademicTitle.Attributes.Add("data", "Participant"); Speciality.Attributes.Add("data", "Participant"); Duties.Attributes.Add("data", "Participant"); IDType.Attributes.Add("data", "Participant"); IDNumber.Attributes.Add("data", "Participant"); Workplace.Attributes.Add("data", "Participant"); j = i - 1; if (j < ParticipantList.Count) { AcademicTitle.Text = ParticipantList[j].AcademicTitle; Speciality.Text = ParticipantList[j].Speciality; Duties.Text = ParticipantList[j].Duties; IDType.SelectedValue = ParticipantList[j].IDType; IDNumber.Text = ParticipantList[j].IDNumber; Workplace.Text = ParticipantList[j].Workplace; ParticipantName.Text = ParticipantList[j].ParticipantName; } } } } }
protected void btnNext_Click(object sender, EventArgs e) { Dal.Models.UserInfo user = (Dal.Models.UserInfo)Session["UserInfo"]; // 创建申报项目 Dal.Models.Declaration decl = null; bool bChanged = false; string strTemplateCode = ""; DateTime dtm; if (!DateTime.TryParse(txtDeclarateDate.Text, out dtm)) { hdMsg.Value = "项目申报时间格式错误!"; return; } int iPrizeID = Convert.ToInt32(Request["rdlPrize"]); if (iPrizeID == 0 && rdlPrize.SelectedValue != "") { iPrizeID = Convert.ToInt32(rdlPrize.SelectedValue); } if (iPrizeID == 0) { hdMsg.Value = "请选择奖项!"; return; } OleDbConnection conn = new OleDbConnection(Dal.OleDbHlper.ConnectionString); conn.Open(); string strActivityType = Request.Cookies["ActivityType"].Value; Dal.Models.Activity actActivated = BLL.Activity.GetActivity(strActivityType, conn); string strDeclarationCode = ""; if (ViewState["DeclarationID"] != null) { decl = BLL.Declaration.GetDeclaration(Convert.ToInt32(ViewState["DeclarationID"]), conn); strDeclarationCode = decl.DeclarationCode; } else { decl = new Dal.Models.Declaration(); decl.UserID = user.UserID; decl.ActivityID = actActivated.ActivityID; } if (decl.DeclareDate == null || decl.DeclareDate.Value != dtm) { bChanged = true; decl.DeclareDate = dtm; } if (string.IsNullOrEmpty(decl.RecommendFrom) || decl.RecommendFrom != ChooseAssociation.SelectedValue) { bChanged = true; decl.RecommendFrom = ChooseAssociation.SelectedValue; } if (decl.PrizeID == null || decl.PrizeID != iPrizeID) { bChanged = true; decl.PrizeID = iPrizeID; } if (string.IsNullOrEmpty(decl.DeclarationName) || decl.DeclarationName != txtProjectName.Text.Trim()) { bChanged = true; decl.DeclarationName = txtProjectName.Text.Trim(); } Dal.Models.Prize prize = BLL.Prize.GetPrize(decl.PrizeID.Value, conn); strTemplateCode = prize.TemplateCode; int iSpecilID = prize.SpecialtyID.Value; int actID = prize.ActivityID.Value; Dal.Models.Schedule dSchedule = BLL.Schedule.GetSpecialtySchedule(iSpecilID, conn); if (dSchedule == null || !dSchedule.IsDeclarationStart.Value) { hdMsg.Value = "未在专业申报时间内,不能创建!"; conn.Close(); return; } string strSituation = ""; if (!string.IsNullOrEmpty(Request["Situation"])) { strSituation = Request["Situation"].Replace("'", "").Replace("\"", ""); } if (bChanged == true && (strSituation == Dal.Models.EnumSituation.Declaration.ToString() || strSituation == "")) { OleDbTransaction trans = conn.BeginTransaction(); try { BLL.Declaration.Declarate(ref decl, conn, trans); string strImportDeclarationID = ImportDeclarationData.SelectedValue; if (strImportDeclarationID != "0" && strImportDeclarationID != "") { string strDeclarationCode2 = BLL.Declaration.GetDeclaration(Convert.ToInt32(strImportDeclarationID), conn, trans).DeclarationCode; BLL.Declaration.ImportDeclarate(decl.DeclarationID.Value, Convert.ToInt32(strImportDeclarationID), conn, trans); BLL.Declaration.ImportUploadFile(decl.DeclarationID.Value, Convert.ToInt32(strImportDeclarationID), decl.DeclarationCode, strDeclarationCode2, conn, trans); } trans.Commit(); ViewState["DeclarationID"] = decl.DeclarationID.Value; } catch (Exception ex) { ViewState.Remove("DeclarationID"); trans.Rollback(); hdMsg.Value = ex.Message; return; } } // 获取申报项目的模板首页 string strPartCode = strTemplateCode.Substring(2, 2) + "01"; // 根据首页获取模板 TempInfo = BLL.Declaration.GetTemplateInfo(strPartCode, conn); TempInfo.DeclarationID = (int)ViewState["DeclarationID"]; TempInfo.DeclarationCode = strDeclarationCode; if (!string.IsNullOrEmpty(strSituation)) { TempInfo.Situation = (Dal.Models.EnumSituation)Enum.Parse(typeof(Dal.Models.EnumSituation), strSituation, true); } else { TempInfo.Situation = (Dal.Models.EnumSituation)Enum.Parse(typeof(Dal.Models.EnumSituation), "Declara", true); } conn.Close(); if (TempInfo != null) { Session.Add("TemplateInfo", TempInfo); // 跳转到模板页 if (strSituation == "ExpertReview" || strSituation == "Delete" || strSituation == "Auditing") { Server.Transfer(TempInfo.NewTemplateUrl); } else { Server.Transfer(TempInfo.TemplateUrl); } } }
protected void Page_Load(object sender, EventArgs e) { Dal.Models.UserInfo user = (Dal.Models.UserInfo)Session["UserInfo"]; if (user == null) { Response.Redirect("~/View/Mutual/UserEntry.aspx"); } if (!IsPostBack) { btnNext.Attributes.Add("OnClick", "return UserAddVerify()"); // 设定专业 Dal.Models.Specialty spec = null; Dal.Models.Prize prize = null; OleDbConnection conn = new OleDbConnection(Dal.OleDbHlper.ConnectionString); conn.Open(); string strActivityType = Request.Cookies["ActivityType"].Value; Dal.Models.Activity actActivated = BLL.Activity.GetActivity(strActivityType, conn); if (actActivated == null) { hdMsg.Value = "当前活动已关闭,请联系活动管理人员!"; return; } // 设置推荐协会 if (ConfigurationManager.AppSettings["ActivityType"] != "0102") { RecommendationAssociation.Visible = false; } else { List <Dal.Models.UserInfo> lstAssociation = BLL.User.GetlstAssociationUser(conn); ChooseAssociation.DataSource = lstAssociation; ChooseAssociation.DataTextField = "UserName"; ChooseAssociation.DataValueField = "UserID"; ChooseAssociation.DataBind(); } int iDeclarationID = 0; int.TryParse(Request["DeclarationID"], out iDeclarationID); hdDeclarationID.Value = iDeclarationID.ToString(); Dal.Models.Declaration decl = BLL.Declaration.GetDeclaration(iDeclarationID, conn); if (decl == null) { // 获取菜单传递过来的参数 spec = BLL.Specialty.GetSpecialty(actActivated.ActivityID.Value, Request["SepcCode"], conn); if (spec == null) { List <Dal.Models.Specialty> lst = BLL.Specialty.GetSpecialtyList(actActivated.ActivityID.Value, true, conn); spec = lst[0]; } // 设定封页台头 litTitle.Text = BLL.SysConstant.GetConstant(spec.TemplateCode, conn).ConstantDiscription; // 设定奖项列表 List <Dal.Models.Specialty> lstSpecialty = BLL.Specialty.GetDirectlyChildList(spec.SpecialtyID.Value, conn); List <Dal.Models.Prize> lstPrize = null; if (lstSpecialty.Count == 0) { lblSpecil.Visible = false; ddlSpecialty.Visible = false; ddlChildSpecialty.Visible = false; // 设定奖项列表 lstPrize = BLL.Prize.GetPrizeList(spec.SpecialtyID.Value, conn); } else { ddlSpecialty.Visible = true; List <Dal.Models.Specialty> lstChildSpecialty = null; lstSpecialty = lstSpecialty.Where(s => BLL.Prize.Count(s.SpecialtyID.Value, conn) > 0 || BLL.Specialty.Count(actActivated.ActivityID.Value, s.SpecialtyID, conn) > 0 ).ToList(); ddlSpecialty.DataSource = lstSpecialty; ddlSpecialty.DataTextField = "SpecialtyName"; ddlSpecialty.DataValueField = "SpecialtyID"; ddlSpecialty.DataBind(); ddlSpecialty.SelectedIndex = 0; if (lstSpecialty.Count > 0) { lstChildSpecialty = BLL.Specialty.GetDirectlyChildList(lstSpecialty[0].SpecialtyID.Value, conn); if (lstChildSpecialty.Count == 0) { ddlChildSpecialty.Visible = false; // 设定奖项列表 lstPrize = BLL.Prize.GetPrizeList(lstSpecialty[0].SpecialtyID.Value, conn); } else { ddlChildSpecialty.Visible = true; ddlChildSpecialty.DataSource = lstChildSpecialty; ddlChildSpecialty.DataTextField = "SpecialtyName"; ddlChildSpecialty.DataValueField = "SpecialtyID"; ddlChildSpecialty.DataBind(); ddlSpecialty.SelectedIndex = 0; // 设定奖项列表 lstPrize = BLL.Prize.GetPrizeList(lstChildSpecialty[0].SpecialtyID.Value, conn); } } } if (lstPrize != null && lstPrize.Count > 0) { // 绑定奖项列表 rdlPrize.DataSource = lstPrize; rdlPrize.DataTextField = "PrizeName"; rdlPrize.DataValueField = "PrizeID"; rdlPrize.DataBind(); rdlPrize.SelectedIndex = 0; // 根据奖项获取模版 string strTempCode = lstPrize.Where(p => p.PrizeID.Value == Convert.ToInt32(rdlPrize.SelectedValue)).ToList()[0].TemplateCode; Dal.Models.Organization org = BLL.User.GetOrganization(user.UserID.Value, conn); // 绑定导入数据 List <Dal.Models.Declaration> lstDeclaration = BLL.Declaration.GetDeclarationList(user, actActivated.ActivityID.Value, conn); lstDeclaration = lstDeclaration.Where(d => d.PrizeID == lstPrize[0].PrizeID).ToList(); if (lstDeclaration.Count() > 0) { ImportDeclarationData.DataSource = lstDeclaration; ImportDeclarationData.DataTextField = "DeclarationName"; ImportDeclarationData.DataValueField = "DeclarationID"; ImportDeclarationData.DataBind(); ImportDeclarationData.Items.Insert(0, new ListItem("<-- 不导入 -->", "0")); ImportDeclarationData.SelectedIndex = 0; } else { ImportData.Visible = false; } if (org != null) { // 设定单位信息 txtOrganizationName.Text = org.OrganizationName; } txtDeclarateDate.Text = DateTime.Today.ToString("yyyy-MM-dd"); } else { hdMsg.Value = "该专业下暂无奖项,无法申报!"; return; } } else { // 隐藏控件 ddlSpecialty.Visible = false; ddlChildSpecialty.Visible = false; lblSpecil.Visible = false; prize = BLL.Prize.GetPrize(decl.PrizeID.Value, conn); spec = BLL.Specialty.GetSpecialty(prize.SpecialtyID.Value, conn); ViewState["DeclarationID"] = decl.DeclarationID.Value; // 设定封页台头 litTitle.Text = BLL.SysConstant.GetConstant(prize.TemplateCode, conn).ConstantDiscription; // 设定封页台头 txtProjectName.Text = decl.DeclarationName; txtDeclarateDate.Text = decl.DeclareDate.Value.ToString("yyyy-MM-dd"); Dal.Models.Organization org = BLL.User.GetOrganization(decl.UserID.Value, conn); if (org != null) { // 设定单位信息 txtOrganizationName.Text = org.OrganizationName; } // 设定奖项列表 List <Dal.Models.Prize> lstPrize = BLL.Prize.GetPrizeList(spec.SpecialtyID.Value, conn); foreach (Dal.Models.Prize item in lstPrize) { rdlPrize.Items.Add(new System.Web.UI.WebControls.ListItem( item.PrizeName, item.PrizeID.Value.ToString()) { Enabled = item.TemplateCode == prize.TemplateCode }); } rdlPrize.SelectedValue = prize.PrizeID.Value.ToString(); if (decl.RecommendFrom == null || decl.RecommendFrom == "0" || decl.RecommendFrom == "") { ChooseAssociation.SelectedValue = "0"; litChooseAssociation.Text = "未有推荐协会"; } else { ChooseAssociation.SelectedValue = decl.RecommendFrom.ToString(); litChooseAssociation.Text = BLL.User.GetUserInfo(Convert.ToInt32(decl.RecommendFrom), conn).UserName; } // 隐藏导入数据控件 ImportData.Visible = false; // 生成二维码 //string imgUrl = BLL.Declaration.CreatQRcode(decl.DeclarationCode, conn); //// 显示二维码 //HtmlTableRow tr = new HtmlTableRow(); //HtmlTableCell td1 = new HtmlTableCell("td"); //HtmlTableCell td2 = new HtmlTableCell("td"); //td1.InnerHtml = "<label style='margin-top: 20px;'>二维码:</label>"; //td1.Style.Add("width", "30%"); //td2.InnerHtml = "<img src='../../Content/Temp/" + decl.DeclarationCode + "/QRcode" + decl.DeclarationCode + ".jpg' style='width:150px;height:150px;' />"; //td2.ColSpan = 2; //tr.Cells.Add(td1); //tr.Cells.Add(td2); //tbInformation.Rows.Add(tr); } //接受场景 if (!string.IsNullOrEmpty(Request["Situation"])) { txtSituation.Text = Request["Situation"].Replace("'", ""); litProjectName.Text = decl.DeclarationName; litDeclarateDate.Text = decl.DeclareDate.Value.ToString("yyyy-MM-dd"); litrdlPrize.Text = prize.PrizeName; } conn.Close(); } }