200 lines
7.2 KiB
C#
200 lines
7.2 KiB
C#
using BLL;
|
|
using Model;
|
|
using System;
|
|
using System.Linq;
|
|
using System.Text.RegularExpressions;
|
|
using System.Collections.Generic;
|
|
using Model.APIItem.SYHSE;
|
|
using Newtonsoft.Json;
|
|
using System.Configuration;
|
|
using Microsoft.Office.Core;
|
|
using SgManager.AI;
|
|
using System.ServiceModel.Syndication;
|
|
using System.Collections;
|
|
|
|
namespace FineUIPro.Web.SYHSE
|
|
{
|
|
public partial class SYProjectSave : PageBase
|
|
{
|
|
|
|
public string SYProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["SYProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["SYProjectId"] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
var project = Funs.DB.SYHSEData_Project.FirstOrDefault(x => x.ProjectId == CurrUser.LoginProjectId);
|
|
if (project == null)
|
|
{
|
|
SYHSEData_Project p = new SYHSEData_Project();
|
|
p.SYProjectId = Guid.NewGuid().ToString();
|
|
p.ProjectId = CurrUser.LoginProjectId;
|
|
Funs.DB.SYHSEData_Project.InsertOnSubmit(p);
|
|
Funs.DB.SubmitChanges();
|
|
SYProjectId = p.SYProjectId;
|
|
}
|
|
else
|
|
{
|
|
SYProjectId = project.SYProjectId;
|
|
txtPeopleNum.Text = project.PeopleNum;
|
|
txtSafePeopleNum.Text = project.SafePeopleNum;
|
|
txtPeopleNum.Text = project.PeopleNum;
|
|
if (project.InstallationTotal.HasValue)
|
|
{
|
|
txtInstallationTotal.Text = project.InstallationTotal.Value.ToString();
|
|
}
|
|
if (project.InstallationRun.HasValue)
|
|
{
|
|
txtInstallationRun.Text = project.InstallationRun.Value.ToString();
|
|
}
|
|
if (project.InstallationStop.HasValue)
|
|
{
|
|
txtInstallationStop.Text = project.InstallationStop.Value.ToString();
|
|
}
|
|
if (project.InstallationOverHaul.HasValue)
|
|
{
|
|
txtInstallationOverHaul.Text = project.InstallationOverHaul.Value.ToString();
|
|
}
|
|
if (!string.IsNullOrEmpty(project.State))
|
|
{
|
|
drpState.SelectedValue= project.State;
|
|
}
|
|
txtProduct.Text = project.Product;
|
|
txtRawMaterial.Text = project.RawMaterial;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存数据
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
this.SaveData();
|
|
ShowNotify("保存数据成功!", MessageBoxIcon.Success);
|
|
}
|
|
|
|
private void SaveData()
|
|
{
|
|
var project = Funs.DB.SYHSEData_Project.FirstOrDefault(x => x.ProjectId == CurrUser.LoginProjectId);
|
|
|
|
project.PeopleNum = txtPeopleNum.Text;
|
|
project.SafePeopleNum = txtSafePeopleNum.Text;
|
|
project.PeopleNum = txtPeopleNum.Text;
|
|
if (!string.IsNullOrEmpty(txtInstallationTotal.Text))
|
|
{
|
|
project.InstallationTotal = int.Parse(txtInstallationTotal.Text);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(txtInstallationRun.Text))
|
|
{
|
|
project.InstallationRun = int.Parse(txtInstallationRun.Text);
|
|
}
|
|
if (!string.IsNullOrEmpty(txtInstallationStop.Text))
|
|
{
|
|
project.InstallationStop = int.Parse(txtInstallationStop.Text);
|
|
}
|
|
if (!string.IsNullOrEmpty(txtInstallationOverHaul.Text))
|
|
{
|
|
project.InstallationOverHaul = int.Parse(txtInstallationOverHaul.Text);
|
|
}
|
|
if (!string.IsNullOrEmpty(txtProduct.Text))
|
|
{
|
|
project.Product = txtProduct.Text;
|
|
}
|
|
if (!string.IsNullOrEmpty(txtRawMaterial.Text))
|
|
{
|
|
project.RawMaterial = txtRawMaterial.Text;
|
|
}
|
|
if (!string.IsNullOrEmpty(drpState.SelectedValue))
|
|
{
|
|
project.State = drpState.SelectedValue;
|
|
}
|
|
Funs.DB.SubmitChanges();
|
|
syncData();
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 附件上传
|
|
/// <summary>
|
|
/// 上传附件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAttachUrl_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(SYProjectId))
|
|
{
|
|
SaveData();
|
|
}
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?Type=0&toKeyId={0}&path=FileUpload/ProjectAttachUrl&menuId={1}", this.SYProjectId, BLL.Const.SeverProjectSetMenuId)));
|
|
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
public void syncData()
|
|
{
|
|
var project = Funs.DB.SYHSEData_Project.FirstOrDefault(x => x.ProjectId == CurrUser.LoginProjectId);
|
|
DataProjectItem item = new DataProjectItem();
|
|
item.SYProjectId = project.SYProjectId;
|
|
item.ProjectId = project.ProjectId;
|
|
item.UnitId = project.UnitId;
|
|
item.PeopleNum = project.PeopleNum;
|
|
item.SafePeopleNum = project.SafePeopleNum;
|
|
item.RawMaterial = project.RawMaterial;
|
|
item.Product = project.Product;
|
|
item.InstallationTotal = project.InstallationTotal;
|
|
item.InstallationRun = project.InstallationRun;
|
|
item.InstallationStop = project.InstallationStop;
|
|
item.InstallationOverHaul = project.InstallationOverHaul;
|
|
item.State = project.State;
|
|
item.FullColorPic = AttachFileService.getFileUrl(SYProjectId);
|
|
|
|
string contenttype = "application/json;charset=utf-8";
|
|
string urlFileUpLoad = ConfigurationManager.AppSettings["QHSE_URL"] + "api/FileUpload/Post";
|
|
if (!string.IsNullOrEmpty(item.FullColorPic))
|
|
{
|
|
string rootUrl = ConfigurationManager.AppSettings["localRoot"];
|
|
|
|
var urls = item.FullColorPic.Split(',');
|
|
string urlRes = "";
|
|
foreach (var u in urls)
|
|
{
|
|
urlRes += APIGetHttpService.HttpUploadFile(urlFileUpLoad, rootUrl+u,null).Trim('"') +",";
|
|
}
|
|
item.FullColorPic = urlRes.TrimEnd(',');
|
|
}
|
|
string url = ConfigurationManager.AppSettings["QHSE_URL"] + "api/SYHSEData/SaveProject";
|
|
|
|
string messages = APIGetHttpService.Http(url, "POST", contenttype, null, JsonConvert.SerializeObject(item));
|
|
|
|
}
|
|
|
|
protected void WindowAtt_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
syncData();
|
|
}
|
|
}
|
|
} |