376 lines
15 KiB
C#
376 lines
15 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Linq;
|
|
|
|
namespace FineUIPro.Web.SES
|
|
{
|
|
public partial class SSREdit : PageBase
|
|
{
|
|
#region 加载
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
|
string view = Request.Params["view"];
|
|
if (view == "1")
|
|
{
|
|
this.btnSave.Hidden = true;
|
|
}
|
|
else
|
|
{
|
|
GetButtonPower();//按钮权限
|
|
}
|
|
|
|
BLL.DepartService.InitDropDownList(this.drpDepartmentId, true);
|
|
BLL.Sys_UserService.InitUserDropDownList(this.drpRequisitionerId, true);
|
|
//BLL.Sys_UserService.InitUserDropDownList(this.drpContractAdmin, true);
|
|
this.drpContractAdmin.DataTextField = "UserName";
|
|
this.drpContractAdmin.DataValueField = "UserId";
|
|
this.drpContractAdmin.DataSource = BLL.Sys_UserService.getUserListByRoleId(BLL.Const.Role_ContractAdministratorId, true);
|
|
this.drpContractAdmin.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpContractAdmin);
|
|
|
|
string SSRId = Request.Params["SSRId"];
|
|
if (!string.IsNullOrEmpty(SSRId))
|
|
{
|
|
Model.SSR ssr = BLL.SSRService.GetSSRById(SSRId);
|
|
if (ssr != null)
|
|
{
|
|
this.txtSES_No.Text = ssr.SES_No;
|
|
this.txtWorkOrder.Text = ssr.WorkOrder;
|
|
this.txtOp.Text = ssr.Op;
|
|
txtNetwork.Text = ssr.Network;
|
|
txtnop.Text = ssr.Nop;
|
|
if (!string.IsNullOrEmpty(ssr.RequisitionerId))
|
|
{
|
|
this.drpRequisitionerId.SelectedValue = ssr.RequisitionerId;
|
|
}
|
|
if (!string.IsNullOrEmpty(ssr.DepartmentId))
|
|
{
|
|
this.drpDepartmentId.SelectedValue = ssr.DepartmentId;
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrEmpty(ssr.RequisitionerId))
|
|
{
|
|
var user = BLL.Sys_UserService.GetUsersByUserId(ssr.RequisitionerId);
|
|
if(user!=null)
|
|
{
|
|
this.drpDepartmentId.SelectedValue = user.DepartId;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (ssr.SubmmisionDate.HasValue)
|
|
{
|
|
this.txtSubmmisionDate.Text = string.Format("{0:yyyy-MM-dd}", ssr.SubmmisionDate);
|
|
}
|
|
if (ssr.ReturnDate.HasValue)
|
|
{
|
|
this.txtReturnDate.Text = ssr.ReturnDate.Value.ToString("G");
|
|
}
|
|
if (ssr.CompletionDate.HasValue)
|
|
{
|
|
this.txtCompletionDate.Text = string.Format("{0:yyyy-MM-dd}", ssr.CompletionDate);
|
|
}
|
|
this.txtContractNo.Text = ssr.ContractNo;
|
|
this.txtAddress.Text = ssr.Address;
|
|
this.txtRemark.Text = ssr.Remark;
|
|
if (ssr.InputDate.HasValue)
|
|
{
|
|
this.txtEntryDate.Text = ssr.InputDate.Value.ToString("G");
|
|
}
|
|
if (ssr.NotRetrunDuration.HasValue)
|
|
{
|
|
this.txtNotReturnDay.Text = ssr.NotRetrunDuration.ToString();
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(ssr.ContractAdmin))
|
|
{
|
|
this.drpContractAdmin.SelectedValue = ssr.ContractAdmin;
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.txtEntryDate.Text = DateTime.Now.ToString("G");
|
|
GetPage();
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 保存
|
|
/// <summary>
|
|
/// 验证
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void PageManager1_CustomEvent(object sender, CustomEventArgs e)
|
|
{
|
|
if (e.EventArgument == "SaveConfirm_OK")
|
|
{
|
|
SaveData();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (!string.IsNullOrEmpty(txtCompletionDate.Text) && !string.IsNullOrEmpty(txtSubmmisionDate.Text))
|
|
{
|
|
if (Convert.ToDateTime(txtCompletionDate.Text) > Convert.ToDateTime(txtSubmmisionDate.Text))
|
|
{
|
|
PageContext.RegisterStartupScript(Confirm.GetShowReference("Completion Date Cannot be greater than Claim Sheet Receive,Are you sure to submit?",
|
|
String.Empty,
|
|
MessageBoxIcon.Question,
|
|
PageManager1.GetCustomEventReference(false, "SaveConfirm_OK"),
|
|
PageManager1.GetCustomEventReference("SaveConfirm_Cancel1")));
|
|
}
|
|
else
|
|
{
|
|
SaveData();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SaveData();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存数据
|
|
/// </summary>
|
|
private void SaveData()
|
|
{
|
|
string SSRId = Request.Params["SSRId"];
|
|
Model.SSR ssr = new Model.SSR();
|
|
ssr.SES_No = this.txtSES_No.Text.Trim();
|
|
ssr.WorkOrder = this.txtWorkOrder.Text.Trim();
|
|
ssr.Op = this.txtOp.Text.Trim();
|
|
ssr.Network = txtNetwork.Text.Trim();
|
|
ssr.Nop = txtnop.Text.Trim();
|
|
if (this.drpRequisitionerId.SelectedValue != BLL.Const._Null)
|
|
{
|
|
ssr.RequisitionerId = this.drpRequisitionerId.SelectedValue;
|
|
ssr.RequisitionerName = this.drpRequisitionerId.SelectedItem.Text;
|
|
}
|
|
if (this.drpDepartmentId.SelectedValue != BLL.Const._Null)
|
|
{
|
|
ssr.DepartmentId = this.drpDepartmentId.SelectedValue;
|
|
ssr.DepartmentName = this.drpDepartmentId.SelectedItem.Text;
|
|
}
|
|
ssr.SubmmisionDate = Funs.GetNewDateTime(this.txtSubmmisionDate.Text.Trim());
|
|
ssr.ReturnDate = Funs.GetNewDateTime(this.txtReturnDate.Text.Trim());
|
|
ssr.CompletionDate = Funs.GetNewDateTime(this.txtCompletionDate.Text.Trim());
|
|
ssr.ContractNo = this.txtContractNo.Text.Trim();
|
|
ssr.Address = this.txtAddress.Text.Trim();
|
|
ssr.Remark = this.txtRemark.Text.Trim();
|
|
ssr.InputDate = Funs.GetNewDateTime(this.txtEntryDate.Text.Trim());
|
|
ssr.NotRetrunDuration = Funs.GetNewInt(this.txtNotReturnDay.Text.Trim());
|
|
if (this.drpContractAdmin.SelectedValue != BLL.Const._Null)
|
|
{
|
|
ssr.ContractAdmin = this.drpContractAdmin.SelectedValue;
|
|
}
|
|
if (!string.IsNullOrEmpty(SSRId))
|
|
{
|
|
ssr.SSRId = SSRId;
|
|
BLL.SSRService.UpdateSSR(ssr);
|
|
BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "Modify SSR!");
|
|
ShowNotify("Save successfully!", MessageBoxIcon.Success);
|
|
}
|
|
else
|
|
{
|
|
var isExist = BLL.SSRService.GetSSRBySESNo(txtSES_No.Text.Trim());
|
|
if (isExist == null)
|
|
{
|
|
ssr.SSRId = SQLHelper.GetNewID(typeof(Model.SSR));
|
|
BLL.SSRService.AddSSR(ssr);
|
|
BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "Add SSR!");
|
|
ShowNotify("Save successfully!", MessageBoxIcon.Success);
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("Ses No:"+ txtSES_No.Text.Trim() + " Already exists,Save failed!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
#endregion
|
|
|
|
#region 权限设置
|
|
/// <summary>
|
|
/// 菜单按钮权限
|
|
/// </summary>
|
|
private void GetButtonPower()
|
|
{
|
|
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.UserId, BLL.Const.SSRMenuId);
|
|
if (buttonList.Count() > 0)
|
|
{
|
|
if (buttonList.Contains(BLL.Const.BtnSave))
|
|
{
|
|
this.btnSave.Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void drpRequisitionerId_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (!string.IsNullOrEmpty(this.drpRequisitionerId.SelectedValue) && this.drpRequisitionerId.SelectedValue != BLL.Const._Null)
|
|
{
|
|
var user = BLL.Sys_UserService.GetUsersByUserId(this.drpRequisitionerId.SelectedValue);
|
|
if (user != null)
|
|
{
|
|
this.txtAddress.Text = user.Address;
|
|
if (!string.IsNullOrEmpty(user.DepartId))
|
|
{
|
|
this.drpDepartmentId.SelectedValue = user.DepartId;
|
|
}
|
|
else
|
|
{
|
|
this.drpDepartmentId.SelectedIndex = 0;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.txtAddress.Text = string.Empty;
|
|
this.drpDepartmentId.SelectedIndex = 0;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
///选择承包商送单日期加载未返回天数
|
|
///未返回天数:=今天的时间-承包商送单日期
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void txtSubmmisionDate_TextChanged(object sender, EventArgs e)
|
|
{
|
|
if (!string.IsNullOrEmpty(this.txtSubmmisionDate.Text.Trim()))
|
|
{
|
|
if (!string.IsNullOrEmpty(txtReturnDate.Text))
|
|
{
|
|
this.txtNotReturnDay.Text = (Convert.ToDateTime(txtReturnDate.Text.Trim()) - Convert.ToDateTime(this.txtSubmmisionDate.Text.Trim())).Days.ToString();
|
|
}
|
|
else
|
|
{
|
|
this.txtNotReturnDay.Text = (DateTime.Now - Convert.ToDateTime(this.txtSubmmisionDate.Text.Trim())).Days.ToString();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.txtNotReturnDay.Text = string.Empty;
|
|
}
|
|
}
|
|
|
|
protected void txtSES_No_TextChanged(object sender, EventArgs e)
|
|
{
|
|
GetPage();
|
|
}
|
|
|
|
private void GetPage()
|
|
{
|
|
if (!string.IsNullOrEmpty(this.txtSES_No.Text.Trim()))
|
|
{
|
|
var ses = BLL.SESReportService.GetSESReportBySESNo(this.txtSES_No.Text.Trim());
|
|
if (ses != null)
|
|
{
|
|
this.txtContractNo.Text = ses.FO;
|
|
if (this.txtWorkOrder.Text == "")
|
|
{
|
|
this.txtWorkOrder.Text = ses.Work_Order.HasValue ? ses.Work_Order.ToString() : "";
|
|
}
|
|
if (this.txtNetwork.Text == "")
|
|
{
|
|
this.txtNetwork.Text = ses.Network;
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(ses.Requisitioner))
|
|
{
|
|
var user = BLL.Sys_UserService.GetUserByAccount(ses.Requisitioner);
|
|
if (user != null)
|
|
{
|
|
this.drpRequisitionerId.SelectedValue = user.UserId;
|
|
this.txtAddress.Text = user.Address;
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(ses.Work_Center))
|
|
{
|
|
var depart = BLL.DepartService.GetDepartByName(ses.Work_Center);
|
|
if (depart != null)
|
|
{
|
|
this.drpDepartmentId.SelectedValue = depart.DepartId;
|
|
}
|
|
}
|
|
if (ses.Claim_sheets_receive.HasValue)
|
|
{
|
|
this.txtSubmmisionDate.Text = string.Format("{0:yyyy-MM-dd}", ses.Claim_sheets_receive);
|
|
if (!string.IsNullOrEmpty(txtReturnDate.Text))
|
|
{
|
|
this.txtNotReturnDay.Text = (Convert.ToDateTime(txtReturnDate.Text.Trim()) - Convert.ToDateTime(this.txtSubmmisionDate.Text.Trim())).Days.ToString();
|
|
}
|
|
else
|
|
{
|
|
this.txtNotReturnDay.Text = (DateTime.Now - Convert.ToDateTime(this.txtSubmmisionDate.Text.Trim())).Days.ToString();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.txtNotReturnDay.Text = string.Empty;
|
|
}
|
|
|
|
var con = BLL.SESRelatedDataService.GetSESRelatedDataByFoNo(ses.FO);
|
|
if (con != null)
|
|
{
|
|
if (!string.IsNullOrEmpty(con.Contract_Admin))
|
|
{
|
|
this.drpContractAdmin.SelectedValue = con.Contract_Admin;
|
|
}
|
|
else
|
|
{
|
|
this.drpContractAdmin.SelectedIndex = 0;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.drpContractAdmin.SelectedIndex = 0;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.txtWorkOrder.Text = string.Empty;
|
|
txtNetwork.Text = string.Empty;
|
|
this.drpRequisitionerId.SelectedIndex = 0;
|
|
this.drpDepartmentId.SelectedIndex = 0;
|
|
this.txtSubmmisionDate.Text = string.Empty;
|
|
this.drpContractAdmin.SelectedIndex = 0;
|
|
this.txtContractNo.Text = string.Empty;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.txtWorkOrder.Text = string.Empty;
|
|
txtNetwork.Text = string.Empty;
|
|
this.drpRequisitionerId.SelectedIndex = 0;
|
|
this.drpDepartmentId.SelectedIndex = 0;
|
|
this.txtSubmmisionDate.Text = string.Empty;
|
|
this.drpContractAdmin.SelectedIndex = 0;
|
|
this.txtContractNo.Text = string.Empty;
|
|
}
|
|
}
|
|
}
|
|
} |