158 lines
		
	
	
		
			6.2 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			158 lines
		
	
	
		
			6.2 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								using System;
							 | 
						|||
| 
								 | 
							
								using System.Collections.Generic;
							 | 
						|||
| 
								 | 
							
								using System.Data;
							 | 
						|||
| 
								 | 
							
								using System.Data.SqlClient;
							 | 
						|||
| 
								 | 
							
								using System.Linq;
							 | 
						|||
| 
								 | 
							
								using System.Web;
							 | 
						|||
| 
								 | 
							
								using System.Web.UI;
							 | 
						|||
| 
								 | 
							
								using System.Web.UI.WebControls;
							 | 
						|||
| 
								 | 
							
								using BLL;
							 | 
						|||
| 
								 | 
							
								namespace FineUIPro.Web.CQMS.ManageReport
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    public partial class QualityGoalStaticTotal : PageBase
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        protected void Page_Load(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (!IsPostBack) {
							 | 
						|||
| 
								 | 
							
								                BindGrid();
							 | 
						|||
| 
								 | 
							
								                GetButtonPower();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        public void BindGrid()
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            string strSql = @"SELECT  [ReportId]
							 | 
						|||
| 
								 | 
							
								                              ,a.[ProjectId]
							 | 
						|||
| 
								 | 
							
															  ,b.ProjectName
							 | 
						|||
| 
								 | 
							
								                              ,a.[Date]
							 | 
						|||
| 
								 | 
							
								                              ,[Pro_Total]
							 | 
						|||
| 
								 | 
							
								                              ,[Pro_Pass]
							 | 
						|||
| 
								 | 
							
									                          ,[Pro_Total] - [Pro_Pass]  [Pro_NoPass]
							 | 
						|||
| 
								 | 
							
								                              ,[Pro_NoPassRectify]
							 | 
						|||
| 
								 | 
							
									                          ,[Pro_Pass]/[Pro_Total] [Pro_Pass_Rate]
							 | 
						|||
| 
								 | 
							
								                              ,[Sup_Total]
							 | 
						|||
| 
								 | 
							
								                              ,[Sup_Rectify]
							 | 
						|||
| 
								 | 
							
									                          ,[Sup_Rectify]/[Sup_Total] [Sup_Rectify_Rate]
							 | 
						|||
| 
								 | 
							
								                              ,[Sub_Total]
							 | 
						|||
| 
								 | 
							
								                              ,[Sub_Pass]
							 | 
						|||
| 
								 | 
							
									                          ,[Sub_Pass]/[Sub_Total] [Sub_Pass_Rate]
							 | 
						|||
| 
								 | 
							
								                              ,[WorkArea_Total]
							 | 
						|||
| 
								 | 
							
								                              ,[WorkArea_Pass]
							 | 
						|||
| 
								 | 
							
									                          ,[WorkArea_Pass]/[WorkArea_Total] [WorkArea_Pass_Rate]
							 | 
						|||
| 
								 | 
							
								                              ,[KeyPro_Total]
							 | 
						|||
| 
								 | 
							
								                              ,[KeyPro_Pass]
							 | 
						|||
| 
								 | 
							
									                          ,[KeyPro_Pass]/[KeyPro_Total] [KeyPro_Pass_Rate]
							 | 
						|||
| 
								 | 
							
								                              ,[Weld_Total]
							 | 
						|||
| 
								 | 
							
								                              ,[Weld_Pass]
							 | 
						|||
| 
								 | 
							
									                          ,[Weld_Pass]/[Weld_Total]  [Weld_Pass_Rate]
							 | 
						|||
| 
								 | 
							
								                              ,[DeviceWeld_Total]
							 | 
						|||
| 
								 | 
							
								                              ,[DeviceWeld_Pass]
							 | 
						|||
| 
								 | 
							
									                          ,[DeviceWeld_Pass]/[DeviceWeld_Total] [DeviceWeld_Pass_Rate]
							 | 
						|||
| 
								 | 
							
								                              ,[SafetyInstruction_Total]
							 | 
						|||
| 
								 | 
							
								                              ,[SafetyInstruction_Pass]
							 | 
						|||
| 
								 | 
							
									                          ,[SafetyInstruction_Pass]/[SafetyInstruction_Total] [SafetyInstruction_Pass_Rate]
							 | 
						|||
| 
								 | 
							
								                              ,[ManName]
							 | 
						|||
| 
								 | 
							
								                              ,[ManOcpu]
							 | 
						|||
| 
								 | 
							
								                              ,a.[Remark]
							 | 
						|||
| 
								 | 
							
								                              ,case when [IsSample] = 1 then '是' when [IsSample] = 0 then '否' else  '' end  IsSample
							 | 
						|||
| 
								 | 
							
								                          FROM [dbo].[Report_QualityGoal] a left join Base_Project b on  a.projectId=b.ProjectId
							 | 
						|||
| 
								 | 
							
								                              where 1=1 ";
							 | 
						|||
| 
								 | 
							
								            List<SqlParameter> listStr = new List<SqlParameter>();
							 | 
						|||
| 
								 | 
							
								            
							 | 
						|||
| 
								 | 
							
								            if (!string.IsNullOrEmpty(this.txtStartDate.Text.Trim()))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                strSql += "  and a.Date >=@date1 ";
							 | 
						|||
| 
								 | 
							
								                listStr.Add(new SqlParameter("@date1", this.txtStartDate.Text.Trim()));
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (!string.IsNullOrEmpty(this.txtEndDate.Text.Trim()))            {
							 | 
						|||
| 
								 | 
							
								                strSql += "  and a.Date <=@date2 ";
							 | 
						|||
| 
								 | 
							
								                listStr.Add(new SqlParameter("@date2", this.txtEndDate.Text.Trim()));
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            strSql += "   order by a.Date desc";
							 | 
						|||
| 
								 | 
							
								            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();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        protected void btnSearch_Click(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            BindGrid();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 格式化字符串
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            /// <param name="reportId"></param>
							 | 
						|||
| 
								 | 
							
								            /// <returns></returns>
							 | 
						|||
| 
								 | 
							
								            protected static string ConvertDate(object reportId)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            string date = string.Empty;
							 | 
						|||
| 
								 | 
							
								            if (reportId != null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                var r = BLL.WeekAndMonthReportService.GetWeekAndMonthReportById(reportId.ToString());
							 | 
						|||
| 
								 | 
							
								                if (r != null)
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    date = string.Format("{0:yyyy-MM-dd}", r.StartDate) + " 至 " + string.Format("{0:yyyy-MM-dd}", r.EndDate);
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            return date;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        protected void btnNew_Click(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("QualityGoalEdit.aspx", "添加 - ")));
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        protected void btnMenuModify_Click(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("QualityGoalEdit.aspx?ReportId=" + Grid1.SelectedRowID, "添加 - ")));
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        protected void btnMenuDel_Click(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (Grid1.SelectedRowIndexArray.Length == 0)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                return;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            string ReportId = Grid1.SelectedRowID.Split(',')[0];
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            BLL.QualityGoalService.Delete_QualityGoalByReportId(ReportId); 
							 | 
						|||
| 
								 | 
							
								            BindGrid();
							 | 
						|||
| 
								 | 
							
								            Alert.ShowInTop("删除数据成功!", MessageBoxIcon.Success);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        protected void Window1_Close(object sender, WindowCloseEventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            BindGrid();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        #region 获取按钮权限
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 获取按钮权限
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="button"></param>
							 | 
						|||
| 
								 | 
							
								        /// <returns></returns>
							 | 
						|||
| 
								 | 
							
								        private void GetButtonPower()
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (Request.Params["value"] == BLL.Const._Null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                return;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.CQMS_QualityGoalStaticMenuId);
							 | 
						|||
| 
								 | 
							
								            if (buttonList.Count() > 0)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                if (buttonList.Contains(BLL.Const.BtnModify))
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    this.btnMenuModify.Hidden = false;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                if (buttonList.Contains(BLL.Const.BtnDelete))
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    this.btnMenuDel.Hidden = false;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |