using BLL; using Model; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; namespace FineUIPro.Web.ProjectData { public partial class MasterProjectDataUsage : PageBase { #region 公共字段 /// /// 主键 /// public string UseId { get { return (string)ViewState["UseId"]; } set { ViewState["UseId"] = value; } } ///// ///// 主数据项目Id ///// //public string ProId //{ // get // { // return (string)ViewState["ProId"]; // } // set // { // ViewState["ProId"] = value; // } //} #endregion protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //this.ProId = Request.Params["ProId"]; this.UseId = Request.Params["UseId"]; BindGrid(); if (!string.IsNullOrEmpty(UseId)) { var usage = ProjectMasterDataUsageService.GetProjectMasterDataUsageById(UseId); //var usage = ProjectMasterDataUsageService.GetProjectMasterDataUsageByProId(ProId); this.txtPro_code.Text = usage.Pro_code; this.txtPro_name.Text = usage.Pro_name; this.txtProjectcode.Text = usage.Projectcode; this.txtProjectname.Text = usage.Projectname; this.rblIsRelate.SelectedValue = usage.Is_relate ? "1" : "0"; //this.rblIsUse.SelectedValue = usage.Is_use ? "1" : "0"; this.rblReasonType.SelectedValue = usage.ReasonType; this.txtReason.Text = usage.Reason; //this.txtSituation.Text = usage.Situation; //this.txtReason.Text = usage.Reason; //this.txtRemark.Text = usage.Remark; //this.rblIsUse.Readonly = true; //if (this.rblIsRelate.SelectedValue == "0") //{ // this.txtReason.Required = true; // this.txtReason.ShowRedStar = true; //} //if (this.rblIsUse.SelectedValue == "1") //{ // this.Next.Hidden = true; //} if (usage.Is_relate) { this.Next.Hidden = true; this.Toolbar1.Hidden = true; this.txtReason.Required = false; this.txtReason.ShowRedStar = false; } else { this.Next.Hidden = false; this.txtReason.Required = true; this.txtReason.ShowRedStar = true; } string handleMan = this.drpHandleMan.Value; if (!string.IsNullOrWhiteSpace(usage.HandleMan)) { //this.cbNext.SelectedValue = "1"; this.drpHandleMan.Value = usage.HandleMan; this.drpHandleMan.Text = usage.HandleManName; bool isAuditer = usage.HandleMan == this.CurrUser.UserId || this.CurrUser.UserId == Const.hfnbdId || this.CurrUser.UserId == Const.sysglyId; if (usage.HandleState == null) { if (isAuditer) { this.Audit.Hidden = false; this.rblHandleState.SelectedValue = "1"; } else { this.Next.Hidden = true; this.Toolbar1.Hidden = true; } } if (usage.HandleState != null) { this.Toolbar1.Hidden = true; this.Next.Hidden = true; } } } } } #region 人员下拉框绑定数据 /// /// 绑定数据 /// private void BindGrid() { string unitId = CommonService.GetThisUnitId(); string strSql = @"SELECT UserId,UserName,UserCode,role.RoleName" + @" FROM Sys_User AS users LEFT JOIN Sys_Role AS role ON users.RoleId= role.RoleId" + @" WHERE users.IsPost=1 AND role.IsAuditFlow=1 AND users.IsOffice =1 AND UnitId ='" + unitId + "'"; List listStr = new List(); if (!string.IsNullOrEmpty(this.txtUserName.Text.Trim())) { strSql += " AND (UserName LIKE @Name OR UserCode LIKE @Name OR role.RoleName LIKE @Name)"; listStr.Add(new SqlParameter("@Name", "%" + this.txtUserName.Text.Trim() + "%")); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); Grid1.RecordCount = tb.Rows.Count; var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); } #region 查询 /// /// 下拉框查询 /// /// /// protected void TextBox_TextChanged(object sender, EventArgs e) { this.drpHandleMan.Values = null; this.BindGrid(); } #endregion #endregion /// /// 是否使用触发事件 /// /// /// protected void rblIsUse_SelectedIndexChanged(object sender, EventArgs e) { //string isUse = this.rblIsUse.SelectedValue; //if (isUse == "0") //{ // this.txtReason.Required = true; // this.txtReason.ShowRedStar = true; // this.Next.Hidden = false; //} //else //{ // this.Next.Hidden = true; // this.txtReason.Required = false; // this.txtReason.ShowRedStar = false; //} } /// /// 下一步触发事件 /// /// /// protected void cbNext_SelectedIndexChanged(object sender, EventArgs e) { if (this.cbNext.SelectedValue == "1") { //this.Audit.Hidden = false; this.HandleMan.Hidden = false; this.drpHandleMan.Required = true; this.drpHandleMan.ShowRedStar = true; } else { //this.Audit.Hidden = true; this.HandleMan.Hidden = true; this.drpHandleMan.Required = false; this.drpHandleMan.ShowRedStar = false; } } protected void btnSave_Click(object sender, EventArgs e) { //var model = ProjectMasterDataUsageService.GetProjectMasterDataUsageByProId(ProId); Project_MasterDataUsage usage = new Project_MasterDataUsage(); //usage.Id = model.Id; usage.Id = this.UseId; //usage.Is_use = this.rblIsUse.SelectedValue == "1"; usage.ReasonType = this.rblReasonType.SelectedValue; usage.Reason = this.txtReason.Text.Trim(); //usage.Situation = this.txtSituation.Text.Trim(); //usage.Reason = this.txtReason.Text.Trim(); //usage.Remark = this.txtRemark.Text.Trim(); //usage.HandleMan = this.drpHandleMan.Value; //usage.HandleManName = this.drpHandleMan.Text; string handleMan = this.drpHandleMan.Value; string handleManName = this.drpHandleMan.Text; if (!string.IsNullOrWhiteSpace(handleMan)) {// bool isAuditer = handleMan == this.CurrUser.UserId || this.CurrUser.UserId == Const.hfnbdId || this.CurrUser.UserId == Const.sysglyId; usage.HandleMan = handleMan; usage.HandleManName = handleManName; if (isAuditer) { usage.HandleState = this.rblHandleState.SelectedValue; //usage.HandleMan = this.CurrUser.UserId; //usage.HandleManName = this.CurrUser.UserName; usage.HandleDate = DateTime.Now; } } else { usage.HandleState = this.rblHandleState.SelectedValue; usage.HandleDate = DateTime.Now; } //if (this.cbNext.SelectedValue == "0") //{ //} ProjectMasterDataUsageService.UpdateProjectMasterDataUsage(usage); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } protected void WindowAtt_Close(object sender, WindowCloseEventArgs e) { } } }