using BLL; using System; using System.Linq; namespace FineUIPro.Web.CQMS.QuantityManagement { public partial class DayInputEdit : PageBase { #region 定义变量 /// /// 主键 /// public string DayInputId { get { return (string)ViewState["DayInputId"]; } set { ViewState["DayInputId"] = value; } } #endregion #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { GetButtonPower(); this.DayInputId = Request.Params["DayInputId"]; BLL.DrawingService.InitDrawingDropDownList(drpDrawingNo, this.CurrUser.LoginProjectId, true); var DayInput = BLL.DayInputService.GetDayInputById(this.DayInputId); if (DayInput != null) { Model.QuantityManagement_Base b = BLL.BaseService.GetBaseById(DayInput.BaseId); if (b != null) { Model.QuantityManagement_Drawing drawing = BLL.DrawingService.GetDrawingById(b.DrawingId); this.DayInputId = DayInput.DayInputId; if (drawing != null) { this.txtWorkSection.Text = drawing.WorkSection; this.drpDrawingNo.SelectedValue = b.DrawingId; this.txtDrawingName.Text = drawing.DrawingName; } BLL.BaseService.InitPartDropDownList(this.drpPart, b.DrawingId, true); this.drpPart.SelectedValue = b.Part; BLL.BaseService.InitProjectContentDropDownList(this.drpProjectContent, b.DrawingId, b.Part, true); this.drpProjectContent.SelectedValue = b.BaseId; this.txtUnit.Text = b.Unit; if (b.Amount != null) { this.txtAmount.Text = b.Amount.ToString(); } this.txtWorkTeam.Text = b.WorkTeam; if (DayInput.Date != null) { this.txtDate.Text = string.Format("{0:yyyy-MM-dd}", DayInput.Date); } if (DayInput.DayAmount != null) { this.txtDayAmount.Text = DayInput.DayAmount.ToString(); } } } else { this.txtDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); } } } #endregion protected void drpDrawingNo_SelectedIndexChanged(object sender, EventArgs e) { Model.QuantityManagement_Drawing drawing = BLL.DrawingService.GetDrawingById(this.drpDrawingNo.SelectedValue); if (drawing != null) { this.txtWorkSection.Text = drawing.WorkSection; this.txtDrawingName.Text = drawing.DrawingName; BLL.BaseService.InitPartDropDownList(this.drpPart, drawing.DrawingId, true); this.drpPart.SelectedValue = BLL.Const._Null; } else { this.txtWorkSection.Text = string.Empty; this.txtDrawingName.Text = string.Empty; this.drpPart.Items.Clear(); Funs.FineUIPleaseSelect(this.drpPart); this.drpPart.SelectedValue = BLL.Const._Null; } this.drpProjectContent.Items.Clear(); Funs.FineUIPleaseSelect(this.drpProjectContent); this.drpProjectContent.SelectedValue = BLL.Const._Null; this.txtUnit.Text = string.Empty; this.txtAmount.Text = string.Empty; this.txtWorkTeam.Text = string.Empty; } protected void drpPart_SelectedIndexChanged(object sender, EventArgs e) { if (this.drpPart.SelectedValue != BLL.Const._Null) { BLL.BaseService.InitProjectContentDropDownList(this.drpProjectContent, this.drpDrawingNo.SelectedValue, this.drpPart.SelectedValue, true); this.drpProjectContent.SelectedValue = BLL.Const._Null; } else { this.drpProjectContent.Items.Clear(); Funs.FineUIPleaseSelect(this.drpProjectContent); this.drpProjectContent.SelectedValue = BLL.Const._Null; } this.txtUnit.Text = string.Empty; this.txtAmount.Text = string.Empty; this.txtWorkTeam.Text = string.Empty; } protected void drpProjectContent_SelectedIndexChanged(object sender, EventArgs e) { if (this.drpProjectContent.SelectedValue != BLL.Const._Null) { Model.QuantityManagement_Base b = BLL.BaseService.GetBaseById(this.drpProjectContent.SelectedValue); if (b != null) { this.txtUnit.Text = b.Unit; if (b.Amount != null) { this.txtAmount.Text = b.Amount.ToString(); } this.txtWorkTeam.Text = b.WorkTeam; } } else { this.drpProjectContent.Items.Clear(); Funs.FineUIPleaseSelect(this.drpProjectContent); this.drpProjectContent.SelectedValue = BLL.Const._Null; this.txtUnit.Text = string.Empty; this.txtAmount.Text = string.Empty; this.txtWorkTeam.Text = string.Empty; } } #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (this.drpDrawingNo.SelectedValue == BLL.Const._Null) { Alert.ShowInTop("请选择图号", MessageBoxIcon.Warning); return; } if (this.drpPart.SelectedValue == BLL.Const._Null) { Alert.ShowInTop("请选择部位", MessageBoxIcon.Warning); return; } if (this.drpProjectContent.SelectedValue == BLL.Const._Null) { Alert.ShowInTop("请选择项目内容", MessageBoxIcon.Warning); return; } Model.QuantityManagement_DayInput newDayInput = new Model.QuantityManagement_DayInput(); newDayInput.ProjectId = this.CurrUser.LoginProjectId; newDayInput.BaseId = this.drpProjectContent.SelectedValue; newDayInput.Date = Funs.GetNewDateTimeOrNow(this.txtDate.Text.Trim()); newDayInput.DayAmount = Funs.GetNewDecimal(this.txtDayAmount.Text.Trim()); if (string.IsNullOrEmpty(this.DayInputId)) { newDayInput.DayInputId = SQLHelper.GetNewID(typeof(Model.QuantityManagement_DayInput)); newDayInput.CompileMan = this.CurrUser.UserId; newDayInput.CompileDate = DateTime.Now; //var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == newDayInput.DayInputId); //if (sour == null || string.IsNullOrEmpty(sour.AttachUrl)) //{ // Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning); // return; //} BLL.DayInputService.AddDayInput(newDayInput); } else { newDayInput.DayInputId = this.DayInputId; //var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == this.DayInputId); //if (sour == null || string.IsNullOrEmpty(sour.AttachUrl)) //{ // Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning); // return; //} var oldDayInput = Funs.DB.QuantityManagement_DayInput.Where(u => u.DayInputId == this.DayInputId).FirstOrDefault(); if (oldDayInput == null) { newDayInput.CompileMan = this.CurrUser.UserId; newDayInput.CompileDate = DateTime.Now; BLL.DayInputService.AddDayInput(newDayInput); } else { newDayInput.CompileMan = oldDayInput.CompileMan; newDayInput.CompileDate = oldDayInput.CompileDate; BLL.DayInputService.UpdateDayInput(newDayInput); } } ShowNotify("保存成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } #endregion #region 获取按钮权限 /// /// 获取按钮权限 /// /// /// private void GetButtonPower() { if (Request.Params["value"] == "0") { return; } var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.DayInputMenuId); if (buttonList.Count() > 0) { if (buttonList.Contains(BLL.Const.BtnSave)) { this.btnSave.Hidden = false; } } } #endregion } }