Basf_FCL/FCL/FineUIPro.Web/SES/SESEvaluateList.aspx.cs

186 lines
7.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using BLL;
using Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.SES
{
public partial class SESEvaluateList : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
}
//#region 绑定数据
/// <summary>
/// 绑定CPTlist
/// </summary>
private void BindGrid()
{
List<FC_SESRelatedData> fcSESList = new List<FC_SESRelatedData>();
//Expression<Func<FC_SESRelatedData, bool>> express = PredicateExtensions.True<FC_SESRelatedData>();
var sesList = from a in Funs.DB.FC_SESRelatedData
where !(from b in Funs.DB.FC_Score select b.Contract_No).Contains(a.FO_NO)
select a;
fcSESList = sesList.ToList();
hidRowNum.Value = fcSESList.Count.ToString();
this.RepeaterList.DataSource = fcSESList;
this.RepeaterList.DataBind();
}
/// <summary>
/// 保存
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btuSave_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(hidRowValue.Value))
{
string pullPath = BLL.Funs.RootPath + "File\\" + DateTime.Now.ToString("yyyyMMddhhmmss") + "\\";
List<Model.AttachFile> fileList = new List<Model.AttachFile>();
List<FC_Score> fsList = new List<FC_Score>();
FC_Score fsModel = new FC_Score();
List<string> lsScore = hidRowValue.Value.Split('|').ToList();
for (int i = 0; i < RepeaterList.Items.Count; i++)
{
Model.AttachFile fileModel = new Model.AttachFile();
System.Web.UI.WebControls.FileUpload fup = RepeaterList.Items[i].FindControl("fileUpload") as System.Web.UI.WebControls.FileUpload;
System.Web.UI.WebControls.HiddenField hidFoNo = RepeaterList.Items[i].FindControl("hidFoNo") as System.Web.UI.WebControls.HiddenField;
//文件路径
string filePath = fup.PostedFile.FileName;
if (!string.IsNullOrEmpty(filePath))
{
//获取文件名称
string fileName = filePath.Substring(filePath.LastIndexOf("\\") + 1);
if (!Directory.Exists(pullPath))
{
Directory.CreateDirectory(pullPath);
}
string filePathUrl = pullPath + fileName;
fup.SaveAs(filePathUrl);
fileModel.AttachFileId = Guid.NewGuid().ToString();
fileModel.ToKeyId = hidFoNo.Value;
fileModel.AttachUrl = filePathUrl;
fileList.Add(fileModel);
}
}
foreach (var item in lsScore)
{
string[] fsValue = item.Split(',');
if (fsValue.Length > 6)
{
var fo = BLL.SESRelatedDataService.GetSESRelatedDataByFoNo(fsValue[0]);
string fotype = string.Empty;
if (fo != null && fo.FOTypeId != null && fo.FOTypeId != "")
{
var t = BLL.FOTypeService.GetFoTypeById(fo.FOTypeId);
if (t != null)
{
fotype = t.FOType;
}
}
var tar_homelyModel = Funs.DB.TAR_HonestyTimelyView.FirstOrDefault(p => p.Contract_No == fsValue[0]);
var homelyModel = Funs.DB.HonestyTimelyView.FirstOrDefault(p => p.Contract_No == fsValue[0]);
fsModel = new FC_Score();
fsModel.Contract_No = fsValue[0];
fsModel.Score1 = !string.IsNullOrEmpty(fsValue[1]) ? decimal.Parse(fsValue[1]) : 0;
fsModel.Score2 = !string.IsNullOrEmpty(fsValue[2]) ? decimal.Parse(fsValue[2]) : 0;
fsModel.Score3 = !string.IsNullOrEmpty(fsValue[3]) ? decimal.Parse(fsValue[3]) : 0;
fsModel.Score4 = !string.IsNullOrEmpty(fsValue[4]) ? decimal.Parse(fsValue[4]) : 0;
fsModel.Score5 = !string.IsNullOrEmpty(fsValue[5]) ? decimal.Parse(fsValue[5]) : 0;
fsModel.Score6 = !string.IsNullOrEmpty(fsValue[6]) ? decimal.Parse(fsValue[6]) : 0;
fsModel.UserId = CurrUser.UserId;
fsModel.Role = CurrUser.RoleId;
fsModel.DateIn = DateTime.Now;
if (homelyModel != null && homelyModel.Honesty != null)
{
fsModel.Honesty = homelyModel.Honesty;
}
if (fotype.Trim() == "FC")
{
if (homelyModel.Timely != null)
{
fsModel.Timely = homelyModel.Timely;
}
}
else if (fotype.Trim() == "TAR")
{
if (tar_homelyModel.Timely != null)
{
fsModel.Timely = tar_homelyModel.Timely;
}
}
else
{
fsModel.Timely = Convert.ToDecimal(5.0);
}
if (fileList.Count(p => p.ToKeyId == fsModel.Contract_No) > 0)
{
fsModel.FileID = fileList.Where(p => p.ToKeyId == fsModel.Contract_No).Select(p => p.AttachFileId).FirstOrDefault();
}
fsList.Add(fsModel);
}
}
if (fileList.Count > 0)
{
Funs.DB.AttachFile.InsertAllOnSubmit(fileList);
}
if (fsList.Count > 0)
{
Funs.DB.FC_Score.InsertAllOnSubmit(fsList);
}
Funs.DB.SubmitChanges();
}
//BindGrid();
ShowNotify("Successful operation", MessageBoxIcon.Success);
}
/// <summary>
/// 当前登录人信息。
/// </summary>
private Model.Sys_User CurrUser
{
get
{
if (Session["CurrUser"] == null) return null;
return (Model.Sys_User)Session["CurrUser"];
}
}
/// <summary>
/// 显示通知对话框
/// </summary>
/// <param name="message"></param>
/// <param name="messageIcon"></param>
private void ShowNotify(string message, MessageBoxIcon messageIcon)
{
Notify n = new Notify();
n.Target = Target.Top;
n.Message = message;
n.MessageBoxIcon = messageIcon;
n.PositionX = Position.Center;
n.PositionY = Position.Top;
n.DisplayMilliseconds = 3000;
n.ShowHeader = false;
n.Show();
}
}
}