365 lines
		
	
	
		
			14 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			365 lines
		
	
	
		
			14 KiB
		
	
	
	
		
			C#
		
	
	
	
| using BLL;
 | |
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Data;
 | |
| using System.Data.SqlClient;
 | |
| using System.Linq;
 | |
| 
 | |
| namespace FineUIPro.Web.TestRun.DriverRun
 | |
| {
 | |
|     public partial class DriverRun : PageBase
 | |
|     {
 | |
|         #region 加载
 | |
|         protected void Page_Load(object sender, EventArgs e)
 | |
|         {
 | |
|             if (!IsPostBack)
 | |
|             {
 | |
|                 GetButtonPower();
 | |
|                 BindGrid();
 | |
|                 btnNew.OnClientClick = Window1.GetShowReference("DriverRunEdit.aspx") + "return false;";
 | |
|                 BLL.UnitService.InitUnitDownList(this.drpUnitId, this.CurrUser.LoginProjectId, true);
 | |
|                 ListItem[] list1 = new ListItem[3];
 | |
|                 list1[0] = new ListItem("未开始", "1");
 | |
|                 list1[1] = new ListItem("进行中", "2");
 | |
|                 list1[2] = new ListItem("已完成", "3");
 | |
|                 this.drpStatus.DataTextField = "Text";
 | |
|                 this.drpStatus.DataValueField = "Value";
 | |
|                 this.drpStatus.DataSource = list1;
 | |
|                 this.drpStatus.DataBind();
 | |
|                 Funs.FineUIPleaseSelect(this.drpStatus);
 | |
|                 ListItem[] list2 = new ListItem[3];
 | |
|                 list2[0] = new ListItem("低", "1");
 | |
|                 list2[1] = new ListItem("中", "2");
 | |
|                 list2[2] = new ListItem("高", "3");
 | |
|                 this.drpPriority.DataTextField = "Text";
 | |
|                 this.drpPriority.DataValueField = "Value";
 | |
|                 this.drpPriority.DataSource = list2;
 | |
|                 this.drpPriority.DataBind();
 | |
|                 Funs.FineUIPleaseSelect(this.drpPriority);
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 数据绑定
 | |
|         //加载列表
 | |
|         public void BindGrid()
 | |
|         {
 | |
|             string strSql = @"SELECT driverRun.DriverRunId,
 | |
|                                      driverRun.ProjectId,
 | |
|                                      driverRun.Code,
 | |
|                                      driverRun.UnitId,
 | |
|                                      driverRun.State,
 | |
|                                      driverRun.Implement,
 | |
|                                      driverRun.Descriptions,
 | |
|                                      driverRun.AttachUrl,
 | |
|                                      driverRun.InstallationId,
 | |
|                                      driverRun.InstallationNames,
 | |
|                                      driverRun.Objective,
 | |
|                                      driverRun.NeedCompletedDate,
 | |
|                                      driverRun.RealCompletedDate,
 | |
|                                      case driverRun.Status when '1' then '未开始' when '2' then '进行中' when '3' then '已完成' else '' end as Status,
 | |
|                                      case driverRun.Priority when '1' then '低' when '2' then '中' when '3' then '高' else '' end as Priority,
 | |
|                                      driverRun.Remark,
 | |
|                                      Unit.UnitName AS UnitName"
 | |
|                             + @" FROM DriverRun_DriverRun AS driverRun"
 | |
|                             + @" LEFT JOIN Base_Unit AS Unit ON Unit.UnitId = driverRun.UnitId WHERE driverRun.ProjectId=@projectId";
 | |
|             List<SqlParameter> listStr = new List<SqlParameter>();
 | |
|             listStr.Add(new SqlParameter("@projectId", this.CurrUser.LoginProjectId));
 | |
|             if (!string.IsNullOrEmpty(this.drpUnitId.SelectedValue) && this.drpUnitId.SelectedValue != BLL.Const._Null)
 | |
|             {
 | |
|                 strSql += " AND driverRun.UnitId=@unitId";
 | |
|                 listStr.Add(new SqlParameter("@unitId", this.drpUnitId.SelectedValue));
 | |
|             }
 | |
|             if (!string.IsNullOrEmpty(this.drpStatus.SelectedValue) && this.drpStatus.SelectedValue != BLL.Const._Null)
 | |
|             {
 | |
|                 strSql += " AND driverRun.Status=@Status";
 | |
|                 listStr.Add(new SqlParameter("@Status", this.drpStatus.SelectedValue));
 | |
|             }
 | |
|             if (!string.IsNullOrEmpty(this.drpPriority.SelectedValue) && this.drpPriority.SelectedValue != BLL.Const._Null)
 | |
|             {
 | |
|                 strSql += " AND driverRun.Priority=@Priority";
 | |
|                 listStr.Add(new SqlParameter("@Priority", this.drpPriority.SelectedValue));
 | |
|             }
 | |
|             SqlParameter[] parameter = listStr.ToArray();
 | |
|             DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
 | |
|             Grid1.RecordCount = tb.Rows.Count;
 | |
|             //tb = GetFilteredTable(Grid1.FilteredData, tb);
 | |
|             var table = this.GetPagedDataTable(Grid1, tb);
 | |
|             Grid1.DataSource = table;
 | |
|             Grid1.DataBind();
 | |
|             for (int i = 0; i < Grid1.Rows.Count; i++)
 | |
|             {
 | |
|                 Model.DriverRun_DriverRun driverRun = BLL.DriverRunService.GetDriverRunById(Grid1.Rows[i].DataKeys[0].ToString());
 | |
|                 if (driverRun != null)
 | |
|                 {
 | |
|                     if (driverRun.Priority == "2")
 | |
|                     {
 | |
|                         Grid1.Rows[i].RowCssClass = "yellow";
 | |
|                     }
 | |
|                     else if (driverRun.Priority == "3")
 | |
|                     {
 | |
|                         Grid1.Rows[i].RowCssClass = "red";
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 分页
 | |
|         /// <summary>
 | |
|         /// 分页索引事件
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
 | |
|         {
 | |
|             BindGrid();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 分页下拉框事件
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
 | |
|             BindGrid();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 排序
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
 | |
|         {
 | |
|             Grid1.SortDirection = e.SortDirection;
 | |
|             Grid1.SortField = e.SortField;
 | |
|             BindGrid();
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 搜索
 | |
|         //搜索按钮事件
 | |
|         protected void btnSearch_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             BindGrid();
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 关闭弹出窗口
 | |
|         /// <summary>
 | |
|         /// 关闭弹出窗口
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Window1_Close(object sender, WindowCloseEventArgs e)
 | |
|         {
 | |
|             BindGrid();
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 编辑
 | |
|         protected void btnMenuModify_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             EditData();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Grid行双击事件
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
 | |
|         {
 | |
|             EditData();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 编辑
 | |
|         /// </summary>
 | |
|         private void EditData()
 | |
|         {
 | |
|             if (Grid1.SelectedRowIndexArray.Length == 0)
 | |
|             {
 | |
|                 Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning);
 | |
|                 return;
 | |
|             }
 | |
|             string id = Grid1.SelectedRowID;
 | |
|             Model.DriverRun_DriverRun data = BLL.DriverRunService.GetDriverRunById(id);
 | |
|             Model.DriverRun_DriverRunApprove approve = BLL.DriverRunApproveService.GetDriverRunApproveByDriverRunId(id);
 | |
|             if (approve != null)
 | |
|             {
 | |
|                 if (!string.IsNullOrEmpty(approve.ApproveMan))
 | |
|                 {
 | |
|                     if (this.CurrUser.UserId == approve.ApproveMan || CurrUser.UserId == Const.sysglyId)
 | |
|                     {
 | |
|                         PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DriverRunEdit.aspx?id={0}", id, "编辑 - ")));
 | |
|                         return;
 | |
|                     }
 | |
|                     else if (data.State == BLL.Const.DriverRun_Complete)
 | |
|                     {
 | |
|                         PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DriverRunView.aspx?id={0}", id, "编辑 - ")));
 | |
|                         return;
 | |
|                     }
 | |
|                     else
 | |
|                     {
 | |
|                         Alert.ShowInTop("您不是当前办理人,无法编辑,请右键查看!", MessageBoxIcon.Warning);
 | |
|                         return;
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 Alert.ShowInTop("流程闭环,请右键查看!", MessageBoxIcon.Warning);
 | |
|                 return;
 | |
|             }
 | |
|            
 | |
|         }
 | |
| 
 | |
|         protected void btnMenuView_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             if (Grid1.SelectedRowIndexArray.Length == 0)
 | |
|             {
 | |
|                 Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
 | |
|                 return;
 | |
|             }
 | |
|             string id = Grid1.SelectedRowID;
 | |
|             Model.DriverRun_DriverRun data = BLL.DriverRunService.GetDriverRunById(id);
 | |
|             if (data != null)
 | |
|             {
 | |
|                 PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DriverRunView.aspx?id={0}", id, "编辑 - ")));
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 删除
 | |
|         protected void btnMenuDel_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             if (Grid1.SelectedRowIndexArray.Length > 0)
 | |
|             {
 | |
|                 foreach (int rowIndex in Grid1.SelectedRowIndexArray)
 | |
|                 {
 | |
|                     string rowID = Grid1.DataKeys[rowIndex][0].ToString();
 | |
|                     var info = BLL.DriverRunService.GetDriverRunById(rowID);
 | |
|                     if (info != null)
 | |
|                     {
 | |
|                         BLL.DriverRunApproveService.DeleteDriverRunApprovesByDriverRunId(rowID);
 | |
|                         BLL.DriverRunService.DeleteDriverRunById(rowID);
 | |
|                     }
 | |
|                 }
 | |
|                 BindGrid();
 | |
|                 ShowNotify("删除数据成功!", MessageBoxIcon.Success);
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region Grid行点击事件
 | |
|         /// <summary>
 | |
|         /// Grid行点击事件
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
 | |
|         {
 | |
|             string id = Grid1.DataKeys[e.RowIndex][0].ToString();
 | |
|             if (e.CommandName == "AttachUrl")
 | |
|             {
 | |
|                 PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/TestRun/DriverRun/DriverRun&menuId={1}", id, BLL.Const.DriverRunMenuId)));
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 权限设置
 | |
|         /// <summary>
 | |
|         /// 权限设置
 | |
|         /// </summary>
 | |
|         private void GetButtonPower()
 | |
|         {
 | |
|             var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.DriverRunMenuId);
 | |
|             if (buttonList.Count() > 0)
 | |
|             {
 | |
|                 if (buttonList.Contains(BLL.Const.BtnAdd))
 | |
|                 {
 | |
|                     this.btnNew.Hidden = false;
 | |
|                 }
 | |
|                 if (buttonList.Contains(BLL.Const.BtnModify))
 | |
|                 {
 | |
|                     this.btnMenuModify.Hidden = false;
 | |
|                     this.Grid1.EnableRowDoubleClickEvent = true;
 | |
|                 }
 | |
|                 if (buttonList.Contains(BLL.Const.BtnDelete))
 | |
|                 {
 | |
|                     this.btnMenuDel.Hidden = false;
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 把状态转换代号为文字形式
 | |
|         /// </summary>
 | |
|         /// <param name="state"></param>
 | |
|         /// <returns></returns>
 | |
|         protected string ConvertState(object state)
 | |
|         {
 | |
|             if (state != null)
 | |
|             {
 | |
|                 if (state.ToString() == BLL.Const.DriverRun_Compile)
 | |
|                 {
 | |
|                     return "编制";
 | |
|                 }
 | |
|                 else if (state.ToString() == BLL.Const.DriverRun_Audit1)
 | |
|                 {
 | |
|                     return "开车负责人审批";
 | |
|                 }
 | |
|                 else if (state.ToString() == BLL.Const.DriverRun_Audit2)
 | |
|                 {
 | |
|                     return "保运主任审批";
 | |
|                 }
 | |
|                 else if (state.ToString() == BLL.Const.DriverRun_Audit3)
 | |
|                 {
 | |
|                     return "保运主任确认完成";
 | |
|                 }
 | |
|                 else if (state.ToString() == BLL.Const.DriverRun_Audit4)
 | |
|                 {
 | |
|                     return "开车负责人确认完成";
 | |
|                 }
 | |
|                 else if (state.ToString() == BLL.Const.DriverRun_Complete)
 | |
|                 {
 | |
|                     return "流程闭环";
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     return "";
 | |
|                 }
 | |
|             }
 | |
|             return "";
 | |
|         }
 | |
|         //<summary>
 | |
|         //获取办理人姓名
 | |
|         //</summary>
 | |
|         //<param name="state"></param>
 | |
|         //<returns></returns>
 | |
|         protected string ConvertMan(object DriverRunId)
 | |
|         {
 | |
|             if (DriverRunId != null)
 | |
|             {
 | |
|                 Model.DriverRun_DriverRunApprove a = BLL.DriverRunApproveService.GetDriverRunApproveByDriverRunId(DriverRunId.ToString());
 | |
|                 if (a != null)
 | |
|                 {
 | |
|                     if (a.ApproveMan != null)
 | |
|                     {
 | |
|                         return BLL.UserService.GetUserByUserId(a.ApproveMan).UserName;
 | |
|                     }
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     return "";
 | |
|                 }
 | |
|             }
 | |
|             return "";
 | |
|         }
 | |
|     }
 | |
| } |