using BLL; using Newtonsoft.Json.Linq; using System; using System.Data; using System.Data.SqlClient; using System.Collections.Generic; using System.Linq; using System.Web.UI.WebControls; using AspNet = System.Web.UI.WebControls; namespace FineUIPro.Web.CQMS.Meeting { public partial class MonthMeetingEdit : PageBase { /// /// 主键 /// public string MeetingId { get { return (string)ViewState["MeetingId"]; } set { ViewState["MeetingId"] = value; } } /// /// 办理类型 /// public string State { get { return (string)ViewState["State"]; } set { ViewState["State"] = value; } } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { MeetingId = Request.Params["MeetingId"]; this.drpHandleType.DataTextField = "Text"; this.drpHandleType.DataValueField = "Value"; BLL.UnitService.GetUnit(this.drpUnit, this.CurrUser.LoginProjectId, true); this.HideOptions.Hidden = true; this.rblIsAgree.Hidden = true; BLL.SitePerson_PersonService.InitProjectUserListByProjectUnitTypeDropDownList(this.drpAttentPerson, this.CurrUser.LoginProjectId, Const.ProjectUnitType_1 + "," + Const.ProjectUnitType_2, true); if (!string.IsNullOrEmpty(MeetingId)) { Model.Meeting_CQMSMeeting CQMSMeeting = BLL.CQMS_MeetingService.GetCQMSMeetingById(MeetingId); hdId.Text = this.MeetingId; if (!string.IsNullOrEmpty(CQMSMeeting.UnitId)) { this.drpUnit.SelectedValue = CQMSMeeting.UnitId; BindHostMan(); if (!string.IsNullOrEmpty(CQMSMeeting.HostMan)) { this.drpHostMan.SelectedValueArray = CQMSMeeting.HostMan.Split(','); } } txtMeetingCode.Text = CQMSMeeting.MeetingCode; if (CQMSMeeting.MeetingDate != null) { this.txtMeetingDate.Text = string.Format("{0:yyyy-MM-dd}", CQMSMeeting.MeetingDate); } txtPlace.Text = CQMSMeeting.Place; if (!string.IsNullOrEmpty(CQMSMeeting.AttentPerson)) { this.drpAttentPerson.SelectedValueArray = CQMSMeeting.AttentPerson.Split(','); } this.txtMeetingTheme.Text = CQMSMeeting.MeetingTheme; this.txtMeetingContents.Text = CQMSMeeting.MeetingContents; gvApprove.DataSource = BLL.CQMS_MeetingApproveService.getListData(this.MeetingId); gvApprove.DataBind(); if (!string.IsNullOrEmpty(CQMSMeeting.State)) { State = CQMSMeeting.State; } else { State = BLL.Const.CQMSMeeting_Compile; this.HideOptions.Hidden = true; this.rblIsAgree.Hidden = true; } if (State != BLL.Const.CQMSMeeting_Complete.ToString()) { drpHandleType.DataSource = BLL.CQMS_MeetingService.GetDHandleTypeByState(State); drpHandleType.DataBind(); } if (State == BLL.Const.CQMSMeeting_Compile || State == BLL.Const.CQMSMeeting_ReCompile) { this.HideOptions.Visible = false; this.rblIsAgree.Visible = false; this.drpHandleMan.Enabled = true; } else { this.HideOptions.Hidden = false; this.rblIsAgree.Hidden = false; } if (State == Const.CQMSMeeting_Audit) { this.drpHandleMan.Enabled = false; } if (State == BLL.Const.CQMSMeeting_Complete || !string.IsNullOrEmpty(Request.Params["see"])) { this.btnSave.Visible = false; this.btnSubmit.Visible = false; this.next.Hidden = true; } drpHandleType_SelectedIndexChanged(null, null); } else { if (!string.IsNullOrEmpty(this.CurrUser.UnitId)) { this.drpUnit.SelectedValue = this.CurrUser.UnitId; BindHostMan(); } drpHandleType.DataSource = BLL.CQMS_MeetingService.GetDHandleTypeByState(BLL.Const.CQMSMeeting_Compile); drpHandleType.DataBind(); drpHandleType_SelectedIndexChanged(null, null); this.txtMeetingDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); } } } private void BindHostMan() { if (this.drpUnit.SelectedValue != BLL.Const._Null) { this.drpHostMan.DataTextField = "PersonName"; this.drpHostMan.DataValueField = "PersonId"; this.drpHostMan.DataSource = BLL.SitePerson_PersonService.GetSitePerson_PersonListByUnitIdsRoleIds(this.CurrUser.LoginProjectId, this.drpUnit.SelectedValue, null); this.drpHostMan.DataBind(); Funs.FineUIPleaseSelect(this.drpHostMan); this.drpHostMan.SelectedValue = BLL.Const._Null; string prefix = BLL.ProjectService.GetProjectCodeByProjectId(this.CurrUser.LoginProjectId) + "-" + BLL.UnitService.GetUnitCodeByUnitId(this.drpUnit.SelectedValue) + "-ZLYLH-"; txtMeetingCode.Text = BLL.SQLHelper.RunProcNewId("SpGetThreeNumber", "Meeting_CQMSMeeting", "MeetingCode", this.CurrUser.LoginProjectId, prefix); } else { this.drpHostMan.Items.Clear(); Funs.FineUIPleaseSelect(this.drpHostMan); txtMeetingCode.Text = string.Empty; } } protected void Grid1_Sort(object sender, GridSortEventArgs e) { } protected void WindowAtt_Close(object sender, WindowCloseEventArgs e) { } /// /// 时间转换 /// /// /// public string ConvertDate(object date) { if (date != null) { return string.Format("{0:yyyy-MM-dd}", Convert.ToDateTime(date)); } else { return null; } } /// /// 把状态转换代号为文字形式 /// /// /// protected string ConvertState(object state) { if (state != null) { if (state.ToString() == BLL.Const.CQMSMeeting_ReCompile) { return "重新编制"; } else if (state.ToString() == BLL.Const.CQMSMeeting_Compile) { return "编制"; } else if (state.ToString() == BLL.Const.CQMSMeeting_Audit) { return "总包质量经理审批"; } else if (state.ToString() == BLL.Const.CQMSMeeting_Complete) { return "审批完成"; } else { return ""; } } return ""; } protected void imgBtnFile_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(hdId.Text)) { hdId.Text = SQLHelper.GetNewID(); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=1&toKeyId={0}&path=FileUpload/CQMS/Meeting&menuId={1}", hdId.Text, BLL.Const.CQMSMonthMeetingMenuId))); } /// /// 同意审核单选框改变事件 /// /// /// protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e) { this.drpHandleMan.Enabled = true; string State = BLL.CQMS_MeetingService.GetCQMSMeetingById(this.MeetingId).State; if (this.RadioButtonList1.SelectedValue.Equals("true")) { if (State == Const.CQMSMeeting_Audit) { this.drpHandleMan.Items.Clear(); Funs.FineUIPleaseSelect(this.drpHandleMan); this.drpHandleMan.Enabled = false; this.drpHandleMan.SelectedValue = BLL.Const._Null; } this.drpHandleType.SelectedIndex = 0; } else { this.drpHandleMan.Items.Clear(); Funs.FineUIPleaseSelect(drpHandleMan); this.drpHandleType.SelectedIndex = 1; ListItem item = new ListItem(); var user = BLL.Person_PersonsService.GetPerson_PersonsById(BLL.CQMS_MeetingApproveService.GetAuditMan(this.MeetingId, BLL.Const.CQMSMeeting_Compile).ApproveMan); item.Value = user.PersonId; item.Text = user.PersonName; this.drpHandleMan.Items.Add(item); this.drpHandleMan.SelectedIndex = 1; } } /// /// 办理步骤下拉框改变事件 /// /// /// protected void drpHandleType_SelectedIndexChanged(object sender, EventArgs e) { this.drpHandleMan.Items.Clear(); Funs.FineUIPleaseSelect(this.drpHandleMan); if (this.drpHandleType.SelectedValue == BLL.Const.CQMSMeeting_Complete) { this.drpHandleMan.Enabled = false; } else if (this.drpHandleType.SelectedValue == BLL.Const.CQMSMeeting_ReCompile) { this.drpHandleMan.Enabled = true; string userId = (from x in Funs.DB.Meeting_CQMSMeetingApprove where x.MeetingId == MeetingId && x.ApproveType == BLL.Const.CQMSMeeting_Compile select x.ApproveMan).First(); ListItem lis = new ListItem(BLL.Person_PersonsService.GetPersonsNameById(userId), userId); this.drpHandleMan.Items.Add(lis); this.drpHandleMan.SelectedIndex = 0; } else { this.drpHandleMan.Enabled = true; if (this.drpHandleType.SelectedValue == BLL.Const.CQMSMeeting_Audit) { SitePerson_PersonService.InitProjectUserListByProjectUnitTypeDropDownList(drpHandleMan, this.CurrUser.LoginProjectId, Const.ProjectUnitType_1, false); } else { SitePerson_PersonService.InitProjectUserListByProjectUnitTypeDropDownList(drpHandleMan, this.CurrUser.LoginProjectId, Const.ProjectUnitType_1, false); } this.drpHandleMan.SelectedIndex = 0; } } protected void btnSave_Click(object sender, EventArgs e) { if (validate()) { SaveCQMSMeeting("save"); } } /// /// 保存 /// public void SaveCQMSMeeting(string saveType) { Model.Meeting_CQMSMeeting CQMSMeeting = new Model.Meeting_CQMSMeeting(); CQMSMeeting.ProjectId = this.CurrUser.LoginProjectId; CQMSMeeting.UnitId = this.drpUnit.SelectedValue; CQMSMeeting.MeetingType = "M"; CQMSMeeting.MeetingCode = this.txtMeetingCode.Text.Trim(); CQMSMeeting.MeetingDate = Funs.GetNewDateTimeOrNow(this.txtMeetingDate.Text.Trim()); CQMSMeeting.Place = this.txtPlace.Text.Trim(); int num = 0; string hostMan = string.Empty; foreach (var item in this.drpHostMan.SelectedValueArray) { if (item != Const._Null) { hostMan += item + ","; num++; } } if (!string.IsNullOrEmpty(hostMan)) { CQMSMeeting.HostMan = hostMan.Substring(0, hostMan.Length - 1); } string attentPerson = string.Empty; foreach (var item in this.drpAttentPerson.SelectedValueArray) { if (item != Const._Null) { attentPerson += item + ","; num++; } } if (!string.IsNullOrEmpty(attentPerson)) { CQMSMeeting.AttentPerson = attentPerson.Substring(0, attentPerson.Length - 1); } CQMSMeeting.AttentPersonNum = num; CQMSMeeting.MeetingTheme = this.txtMeetingTheme.Text.Trim(); CQMSMeeting.MeetingContents = this.txtMeetingContents.Text; if (saveType == "submit") { CQMSMeeting.State = this.drpHandleType.SelectedValue; } else { Model.Meeting_CQMSMeeting CQMSMeeting1 = CQMS_MeetingService.GetCQMSMeetingById(MeetingId); if (CQMSMeeting1 != null) { if (string.IsNullOrEmpty(CQMSMeeting1.State)) { CQMSMeeting.State = BLL.Const.CQMSMeeting_Compile; } else { CQMSMeeting.State = CQMSMeeting1.State; } } else { CQMSMeeting.State = BLL.Const.CQMSMeeting_Compile; } } if (!string.IsNullOrEmpty(MeetingId)) { CQMSMeeting.MeetingId = MeetingId; CQMS_MeetingService.UpdateCQMSMeeting(CQMSMeeting); if (saveType == "submit") { Model.Meeting_CQMSMeetingApprove approve1 = BLL.CQMS_MeetingApproveService.GetCQMSMeetingApproveByMeetingId(MeetingId); approve1.ApproveDate = DateTime.Now; approve1.ApproveIdea = this.txtOpinions.Text.Trim(); approve1.IsAgree = Convert.ToBoolean(this.RadioButtonList1.SelectedValue); BLL.CQMS_MeetingApproveService.UpdateCQMSMeetingApprove(approve1); if (this.drpHandleMan.SelectedValue != BLL.Const._Null) { Model.Meeting_CQMSMeetingApprove approve = new Model.Meeting_CQMSMeetingApprove(); approve.MeetingId = CQMSMeeting.MeetingId; approve.ApproveMan = this.drpHandleMan.SelectedValue; approve.ApproveType = this.drpHandleType.SelectedValue; BLL.CQMS_MeetingApproveService.AddCQMSMeetingApprove(approve); } if (this.drpHandleType.SelectedValue == Const.CQMSMeeting_Complete) //审批完成 { var getSitePerson = (from x in Funs.DB.SitePerson_Person join z in Funs.DB.Project_ProjectUnit on x.UnitId equals z.UnitId where x.ProjectId == this.CurrUser.LoginProjectId && x.States == Const.ProjectPersonStates_1 && x.RoleIds != null && z.UnitType == Const.ProjectUnitType_2 select new { x.PersonId, RoleNames = BLL.RoleService.getRoleNamesRoleIds(x.RoleIds) }).AsEnumerable(); var list = getSitePerson.Where(x => !x.RoleNames.Contains("安全")); foreach (var item in list) { Model.Meeting_CQMSMeetingApprove approve = new Model.Meeting_CQMSMeetingApprove(); approve.MeetingId = CQMSMeeting.MeetingId; approve.ApproveMan = item.PersonId; approve.ApproveType = "S"; BLL.CQMS_MeetingApproveService.AddCQMSMeetingApprove(approve); } } } } else { if (string.IsNullOrEmpty(hdId.Text)) { CQMSMeeting.MeetingId = SQLHelper.GetNewID(); } else { CQMSMeeting.MeetingId = hdId.Text; } CQMSMeeting.CompileMan = this.CurrUser.PersonId; CQMSMeeting.CompileDate = DateTime.Now; CQMS_MeetingService.AddCQMSMeeting(CQMSMeeting); if (saveType == "submit") { Model.Meeting_CQMSMeetingApprove approve1 = new Model.Meeting_CQMSMeetingApprove(); approve1.MeetingId = CQMSMeeting.MeetingId; approve1.ApproveMan = this.CurrUser.PersonId; approve1.ApproveType = BLL.Const.CQMSMeeting_Compile; approve1.ApproveDate = DateTime.Now; BLL.CQMS_MeetingApproveService.AddCQMSMeetingApprove(approve1); Model.Meeting_CQMSMeetingApprove approve = new Model.Meeting_CQMSMeetingApprove(); approve.MeetingId = CQMSMeeting.MeetingId; if (this.drpHandleMan.SelectedValue != BLL.Const._Null) { approve.ApproveMan = this.drpHandleMan.SelectedValue; } approve.ApproveType = this.drpHandleType.SelectedValue; BLL.CQMS_MeetingApproveService.AddCQMSMeetingApprove(approve); } else { Model.Meeting_CQMSMeetingApprove approve1 = new Model.Meeting_CQMSMeetingApprove(); approve1.MeetingId = CQMSMeeting.MeetingId; approve1.ApproveMan = this.CurrUser.PersonId; approve1.ApproveType = BLL.Const.CQMSMeeting_Compile; BLL.CQMS_MeetingApproveService.AddCQMSMeetingApprove(approve1); } } LogService.AddSys_Log(CurrUser, CQMSMeeting.MeetingCode, CQMSMeeting.MeetingId, Const.CQMSMonthMeetingMenuId, "修改质量月例会"); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } /// /// 表格数据验证 /// private bool validate() { bool res = false; string err = string.Empty; if (this.drpUnit.SelectedValue == BLL.Const._Null) { err += "请选择单位!"; } if (this.drpHostMan.SelectedValue == BLL.Const._Null && this.drpHostMan.SelectedValueArray.Length == 1) { err += "请选择主持人!"; } if (this.drpAttentPerson.SelectedValue == BLL.Const._Null && this.drpAttentPerson.SelectedValueArray.Length == 1) { err += "请选择参加人员!"; } //var att = BLL.AttachFileService.GetAttachFileByToKeyId(this.hdId.Text); //if (att == null) //{ // err += "请上传文件!"; //} if (!string.IsNullOrWhiteSpace(err)) { Alert.ShowInTop(err, MessageBoxIcon.Warning); } else { res = true; } return res; } protected void btnSubmit_Click(object sender, EventArgs e) { if (validate()) { if (this.drpHandleMan.Enabled == true && this.drpHandleMan.SelectedValue == BLL.Const._Null) { Alert.ShowInTop("请选择办理人!", MessageBoxIcon.Warning); return; } SaveCQMSMeeting("submit"); } } private string GetStringByArray(string[] array) { string str = string.Empty; foreach (var item in array) { if (item != BLL.Const._Null) { str += item + ","; } } if (!string.IsNullOrEmpty(str)) { str = str.Substring(0, str.LastIndexOf(",")); } return str; } protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e) { BindHostMan(); } } }