using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using BLL; namespace FineUIPro.Web.WeldingProcess.WeldingManage { public partial class DailyReportCompleteEdit : PageBase { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { LoadData(); string completeId = Request.Params["completeId"]; BLL.Base_UnitService.InitUnitDropDownList(this.drpUnit, false, BLL.Const.UnitType_5, Resources.Lan.PleaseSelect);//单位 var teamGroup = BLL.Welder_TeamGroupService.GetAllTeamGroupList(CurrUser.LoginProjectId, ""); drpTeamGroup.DataValueField = "Value"; drpTeamGroup.DataTextField = "Text"; drpTeamGroup.DataSource = teamGroup; drpTeamGroup.DataBind(); Funs.FineUIPleaseSelect(drpTeamGroup, ""); if (!string.IsNullOrEmpty(completeId)) { var daily = BLL.DailyReportCompleteService.GetDailyReportComplete(completeId); if (daily != null) { var user = BLL.Sys_UserService.GetUsersByUserId(daily.ReportMan); drpUnit.SelectedValue = daily.UnitId; if (user != null) { txtReportMan.Text = user.UserName; } else { txtReportMan.Text = this.CurrUser.UserName; } drpTeamGroup.SelectedValue = daily.TeamGroupId; if (daily.DailyReportDate.HasValue) { this.txtDailyReportDate.Text = string.Format("{0:yyyy-MM-dd}", daily.DailyReportDate); } if (daily.IsComplete == true) { chkIsComplete.Checked = true; } else { chkIsComplete.Checked = false; } } else { txtReportMan.Text = this.CurrUser.UserName; } } } } /// /// 加载页面 /// private void LoadData() { btnClose.OnClientClick = ActiveWindow.GetHideReference(); } /// /// 提交按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.DailyReportCompleteMenuId, Const.BtnSave)) { string completeId = Request.Params["completeId"]; if (drpTeamGroup.SelectedValue == null || drpTeamGroup.SelectedValue == "") { Alert.ShowInParent("施工班组不能为空!"); return; } string param = completeId != null ? completeId.ToString() : ""; if (BLL.DailyReportCompleteService.IsExistDailyReportComplete(this.CurrUser.LoginProjectId, param, drpTeamGroup.SelectedValue,Convert.ToDateTime(txtDailyReportDate.Text).Date)) { Alert.ShowInParent("该施工班组这天的日报情况已存在!"); return; } else { Model.Pipeline_DailyReportComplete newR = new Model.Pipeline_DailyReportComplete(); newR.ProjectId = this.CurrUser.LoginProjectId; newR.UnitId = drpUnit.SelectedValue; newR.ReportMan=this.CurrUser.UserId; newR.TeamGroupId = drpTeamGroup.SelectedValue; newR.DailyReportDate=Convert.ToDateTime(txtDailyReportDate.Text).Date; newR.IsComplete=chkIsComplete.Checked; if (this.chkIsComplete.Checked) { newR.IsComplete = true; } else { newR.IsComplete = false; } if (string.IsNullOrEmpty(completeId)) { string newKeyID = SQLHelper.GetNewID(typeof(Model.Pipeline_DailyReportComplete)); newR.DailyReportCompleteId = newKeyID; BLL.DailyReportCompleteService.AddDailyReportComplete(newR); BLL.Sys_LogService.AddLog(Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.DailyReportCompleteMenuId, Const.BtnAdd, newKeyID); } else { newR.DailyReportCompleteId = completeId; BLL.DailyReportCompleteService.UpdateDailyReportComplete(newR); BLL.Sys_LogService.AddLog(Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.DailyReportCompleteMenuId, Const.BtnModify, completeId); } PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } } else { ShowNotify("您没有这个权限,请与管理员联系!"); } } } }