2024-03-18 09:04:53 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Web.UI;
|
|
|
|
|
using System.Web.UI.WebControls;
|
|
|
|
|
using BLL;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
2024-03-18 10:42:10 +08:00
|
|
|
|
|
2024-03-18 09:04:53 +08:00
|
|
|
|
namespace FineUIPro.Web.CQMS.ManageReportNew
|
|
|
|
|
{
|
|
|
|
|
public partial class MonthReportEdit : PageBase
|
|
|
|
|
{
|
|
|
|
|
#region 定义项
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 主键
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string ReportId
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return (string)ViewState["ReportId"];
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
ViewState["ReportId"] = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string AddOrUpdate
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return (string)ViewState["AddOrUpdate"];
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
ViewState["AddOrUpdate"] = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 列表集合
|
|
|
|
|
private static List<Model.Report_CqmsTarget> detailsGrid1 = new List<Model.Report_CqmsTarget>();
|
|
|
|
|
#endregion
|
2024-03-18 10:42:10 +08:00
|
|
|
|
|
2024-03-18 09:04:53 +08:00
|
|
|
|
#region 加载页面
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载页面
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!IsPostBack)
|
|
|
|
|
{
|
|
|
|
|
this.EnableViewState = true;
|
|
|
|
|
this.lblProjectName.Text = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId).ProjectName;
|
|
|
|
|
this.ReportId = Request.Params["reportId"];
|
|
|
|
|
if (!string.IsNullOrEmpty(Request.Params["view"]))
|
|
|
|
|
{
|
|
|
|
|
this.Button1.Visible = false;
|
|
|
|
|
this.Button2.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(this.ReportId))
|
|
|
|
|
{
|
|
|
|
|
Model.Report_WeekAndMonthReport_New weekAndMonthReport = WeekAndMonthReportNewService.Detail(this.ReportId);
|
|
|
|
|
if (weekAndMonthReport != null)
|
|
|
|
|
{
|
|
|
|
|
if (weekAndMonthReport.SortId != null)
|
|
|
|
|
{
|
|
|
|
|
this.txtPeriod.Text = Convert.ToString(weekAndMonthReport.SortId);
|
|
|
|
|
}
|
|
|
|
|
if (weekAndMonthReport.StartDate != null)
|
|
|
|
|
{
|
|
|
|
|
this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", weekAndMonthReport.StartDate);
|
|
|
|
|
}
|
|
|
|
|
if (weekAndMonthReport.EndDate != null)
|
|
|
|
|
{
|
|
|
|
|
this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", weekAndMonthReport.EndDate);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
AddOrUpdate = "update";
|
|
|
|
|
|
|
|
|
|
#region 加载本月质量目标管理情况
|
|
|
|
|
detailsGrid1.Clear();
|
|
|
|
|
detailsGrid1 = (from x in Funs.DB.Report_CqmsTarget
|
|
|
|
|
where x.ReportId == this.ReportId
|
|
|
|
|
orderby x.SortId
|
|
|
|
|
select x).ToList();
|
|
|
|
|
if (detailsGrid1.Count>0)
|
|
|
|
|
{
|
|
|
|
|
Grid1.Hidden = false;
|
|
|
|
|
Grid1.DataSource = detailsGrid1;
|
|
|
|
|
Grid1.DataBind();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 加载文本框内容
|
|
|
|
|
var txtReportList = Funs.DB.Report_TextBoxContent.Where(x => x.ReportId == ReportId).ToList();
|
|
|
|
|
txtAre0.Text = txtReportList.FirstOrDefault(x => x.ContentType == "0").ContentText;
|
|
|
|
|
txtAre1.Text = txtReportList.FirstOrDefault(x => x.ContentType == "1").ContentText;
|
|
|
|
|
txtAre2.Text = txtReportList.FirstOrDefault(x => x.ContentType == "2").ContentText;
|
|
|
|
|
|
|
|
|
|
txtAre20.Text = txtReportList.FirstOrDefault(x => x.ContentType == "20").ContentText;
|
|
|
|
|
txtAre21.Text = txtReportList.FirstOrDefault(x => x.ContentType == "21").ContentText;
|
|
|
|
|
txtAre22.Text = txtReportList.FirstOrDefault(x => x.ContentType == "22").ContentText;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.txtStartDate.Text = string.IsNullOrEmpty(Request.Params["startdate"]) ? string.Format("{0:yyyy-MM-dd}", DateTime.Now) : Request.Params["startdate"];
|
|
|
|
|
this.txtEndDate.Text = string.IsNullOrEmpty(Request.Params["enddate"]) ? string.Format("{0:yyyy-MM-dd}", Convert.ToDateTime(this.txtStartDate.Text).AddMonths(1).AddDays(-1)) : Request.Params["enddate"];
|
|
|
|
|
//给个新的主键
|
|
|
|
|
ReportId = Guid.NewGuid().ToString();
|
|
|
|
|
AddOrUpdate = "add";
|
|
|
|
|
}
|
|
|
|
|
hidReportId.Value = ReportId;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 时间选择事件
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 开始时间选择事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void txtStartDate_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(this.txtStartDate.Text.Trim()))
|
|
|
|
|
{
|
|
|
|
|
string url = Request.Url.ToString();
|
|
|
|
|
if (url.Contains("?"))
|
|
|
|
|
{
|
|
|
|
|
url = Request.Url.ToString().Substring(0, Request.Url.ToString().LastIndexOf('?'));
|
|
|
|
|
}
|
|
|
|
|
Response.Redirect(url + "?startdate=" + txtStartDate.Text + "&enddate=" + txtEndDate.Text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 本月质量目标管理情况 Grid1方法
|
|
|
|
|
protected void btnAddGrid1_Click(object sender, EventArgs e) {
|
|
|
|
|
Grid1.Hidden = false;
|
|
|
|
|
|
|
|
|
|
JArray teamGroupData = Grid1.GetMergedData();
|
|
|
|
|
List<JObject> list = new List<JObject>();
|
|
|
|
|
foreach (JObject teamGroupRow in teamGroupData)
|
|
|
|
|
{
|
|
|
|
|
JObject values = teamGroupRow.Value<JObject>("values");
|
|
|
|
|
values.Add("Id", teamGroupRow.Value<string>("id"));
|
|
|
|
|
list.Add(values);
|
|
|
|
|
}
|
|
|
|
|
JObject defaultObj = new JObject
|
|
|
|
|
{ { "Id",Guid.NewGuid() },
|
|
|
|
|
{ "ReportId", ReportId },
|
|
|
|
|
{ "ProStage", "" },
|
|
|
|
|
{ "ProDescribe",""},
|
|
|
|
|
{ "TargetValue", "" },
|
|
|
|
|
{ "MonthPer","" },
|
|
|
|
|
{ "Remarks", "" },
|
|
|
|
|
{ "SortId","" },
|
|
|
|
|
{ "Delete1", String.Format("<a href=\"javascript:;\" onclick=\"{0}\"><img src=\"{1}\"/></a>", GetDeleteScriptGrid1(), IconHelper.GetResolvedIconUrl(Icon.Delete)) }
|
|
|
|
|
};
|
|
|
|
|
list.Add(defaultObj);
|
|
|
|
|
Grid1.DataSource = list;
|
|
|
|
|
Grid1.DataBind();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void Grid1_PreDataBound(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// 设置LinkButtonField的点击客户端事件
|
|
|
|
|
LinkButtonField deleteField = Grid1.FindColumn("Delete1") as LinkButtonField;
|
|
|
|
|
deleteField.OnClientClick = GetDeleteScriptGrid1();
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除提示
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private string GetDeleteScriptGrid1()
|
|
|
|
|
{
|
|
|
|
|
return Confirm.GetShowReference("删除选中行?", String.Empty, MessageBoxIcon.Question, Grid1.GetDeleteSelectedRowsReference(), String.Empty);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 保存
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存按钮
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Model.Report_WeekAndMonthReport_New report = new Model.Report_WeekAndMonthReport_New();
|
|
|
|
|
report.Id = ReportId;
|
|
|
|
|
report.ProjectId = this.CurrUser.LoginProjectId;
|
|
|
|
|
if (!string.IsNullOrEmpty(this.txtPeriod.Text.Trim()))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
report.SortId = this.txtPeriod.Text.Trim();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
ScriptManager.RegisterStartupScript(this, typeof(string), "_alert", "alert('周期输入格式不正确,请重新输入!')", true);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(this.txtStartDate.Text))
|
|
|
|
|
{
|
|
|
|
|
report.StartDate = Convert.ToDateTime(this.txtStartDate.Text);
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(this.txtEndDate.Text))
|
|
|
|
|
{
|
|
|
|
|
report.EndDate = Convert.ToDateTime(this.txtEndDate.Text);
|
|
|
|
|
}
|
|
|
|
|
report.CreateDate = DateTime.Now;
|
|
|
|
|
report.CreateMan = CurrUser.UserId;
|
|
|
|
|
|
|
|
|
|
#region 删除所有子表
|
|
|
|
|
//本月质量目标管理情况
|
|
|
|
|
CqmsTargetService.Delete(ReportId);
|
|
|
|
|
|
|
|
|
|
//所有文本框表
|
|
|
|
|
TextBoxContentService.Delete(ReportId);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 保存所有子表
|
|
|
|
|
//保存本月质量目标管理情况
|
|
|
|
|
saveTarget();
|
|
|
|
|
|
|
|
|
|
//保存文本框
|
|
|
|
|
saveTxtContent();
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
if (AddOrUpdate == "add")
|
|
|
|
|
{
|
|
|
|
|
WeekAndMonthReportNewService.Insert(report);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
WeekAndMonthReportNewService.Update(report);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ShowNotify("编辑成功!", MessageBoxIcon.Success);
|
|
|
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 保存本月质量目标管理情况
|
|
|
|
|
void saveTarget() {
|
|
|
|
|
List<Model.Report_CqmsTarget> detailLists = new List<Model.Report_CqmsTarget>();
|
|
|
|
|
JArray teamGroupData = Grid1.GetMergedData();
|
|
|
|
|
foreach (JObject teamGroupRow in teamGroupData) {
|
|
|
|
|
JObject values = teamGroupRow.Value<JObject>("values");
|
|
|
|
|
int rowIndex = teamGroupRow.Value<int>("index");
|
|
|
|
|
Model.Report_CqmsTarget newDetail = new Model.Report_CqmsTarget
|
|
|
|
|
{
|
|
|
|
|
//Id = values.Value<string>("Id"),
|
|
|
|
|
ReportId = ReportId,
|
|
|
|
|
ProStage = values.Value<string>("ProStage"),
|
|
|
|
|
ProDescribe = values.Value<string>("ProDescribe"),
|
|
|
|
|
TargetValue = values.Value<string>("TargetValue"),
|
|
|
|
|
MonthPer = values.Value<string>("MonthPer"),
|
|
|
|
|
Remarks = values.Value<string>("Remarks"),
|
|
|
|
|
SortId = rowIndex + 1
|
|
|
|
|
};
|
|
|
|
|
if (Grid1.Rows[rowIndex].DataKeys.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
newDetail.Id = Grid1.Rows[rowIndex].DataKeys[0].ToString();
|
|
|
|
|
}
|
|
|
|
|
detailLists.Add(newDetail);
|
|
|
|
|
}
|
|
|
|
|
if (detailLists.Count>0)
|
|
|
|
|
{
|
|
|
|
|
Funs.DB.Report_CqmsTarget.InsertAllOnSubmit(detailLists);
|
|
|
|
|
Funs.DB.SubmitChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存文本框内容
|
|
|
|
|
/// </summary>
|
|
|
|
|
void saveTxtContent() {
|
|
|
|
|
var txtContentList = new List<Model.Report_TextBoxContent>();
|
|
|
|
|
#region 给实体赋值
|
|
|
|
|
var model0 = new Model.Report_TextBoxContent();
|
|
|
|
|
model0.Id = Guid.NewGuid().ToString();
|
|
|
|
|
model0.ReportId = ReportId;
|
|
|
|
|
model0.ContentType = "0";
|
|
|
|
|
model0.ContentText = txtAre0.Text;
|
|
|
|
|
txtContentList.Add(model0);
|
|
|
|
|
|
|
|
|
|
var model1 = new Model.Report_TextBoxContent();
|
|
|
|
|
model1.Id = Guid.NewGuid().ToString();
|
|
|
|
|
model1.ReportId = ReportId;
|
|
|
|
|
model1.ContentType = "1";
|
|
|
|
|
model1.ContentText = txtAre1.Text;
|
|
|
|
|
txtContentList.Add(model1);
|
|
|
|
|
|
|
|
|
|
var model2 = new Model.Report_TextBoxContent();
|
|
|
|
|
model2.Id = Guid.NewGuid().ToString();
|
|
|
|
|
model2.ReportId = ReportId;
|
|
|
|
|
model2.ContentType = "2";
|
|
|
|
|
model2.ContentText = txtAre2.Text;
|
|
|
|
|
txtContentList.Add(model2);
|
|
|
|
|
|
|
|
|
|
var model20 = new Model.Report_TextBoxContent();
|
|
|
|
|
model20.Id = Guid.NewGuid().ToString();
|
|
|
|
|
model20.ReportId = ReportId;
|
|
|
|
|
model20.ContentType = "20";
|
|
|
|
|
model20.ContentText = txtAre20.Text;
|
|
|
|
|
txtContentList.Add(model20);
|
|
|
|
|
|
|
|
|
|
var model21 = new Model.Report_TextBoxContent();
|
|
|
|
|
model21.Id = Guid.NewGuid().ToString();
|
|
|
|
|
model21.ReportId = ReportId;
|
|
|
|
|
model21.ContentType = "21";
|
|
|
|
|
model21.ContentText = txtAre21.Text;
|
|
|
|
|
txtContentList.Add(model21);
|
|
|
|
|
|
|
|
|
|
var model22 = new Model.Report_TextBoxContent();
|
|
|
|
|
model22.Id = Guid.NewGuid().ToString();
|
|
|
|
|
model22.ReportId = ReportId;
|
|
|
|
|
model22.ContentType = "22";
|
|
|
|
|
model22.ContentText = txtAre22.Text;
|
|
|
|
|
txtContentList.Add(model22);
|
|
|
|
|
#endregion
|
|
|
|
|
Funs.DB.Report_TextBoxContent.InsertAllOnSubmit(txtContentList);
|
|
|
|
|
Funs.DB.SubmitChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|