294 lines
		
	
	
		
			9.9 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			294 lines
		
	
	
		
			9.9 KiB
		
	
	
	
		
			C#
		
	
	
	
using BLL;
 | 
						|
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Data;
 | 
						|
using System.Data.SqlClient;
 | 
						|
using System.Linq;
 | 
						|
 | 
						|
namespace FineUIPro.Web.EditorManage
 | 
						|
{
 | 
						|
    public partial class CostReport : PageBase
 | 
						|
    {
 | 
						|
        #region 加载
 | 
						|
        /// <summary>
 | 
						|
        /// 加载页面
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void Page_Load(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (!IsPostBack)
 | 
						|
            {
 | 
						|
                GetButtonPower();//权限设置
 | 
						|
 | 
						|
                //this.drpJobNo.DataTextField = "ProjectControl_JobNo";
 | 
						|
                //this.drpJobNo.DataValueField = "EProjectId";
 | 
						|
                //this.drpJobNo.DataSource = BLL.EProjectService.GetEProjectList();
 | 
						|
                //this.drpJobNo.DataBind();
 | 
						|
                //Funs.FineUIPleaseSelect(this.drpJobNo);
 | 
						|
 | 
						|
                //btnNew.OnClientClick = Window1.GetShowReference("CostReportEdit.aspx") + "return false;";
 | 
						|
                //btnDelete.OnClientClick = Grid1.GetNoSelectionAlertReference("Please select at least one item!");
 | 
						|
                //btnDelete.ConfirmText = String.Format("Are you sure you want to delete the selected  <b><script>{0}</script></b> rows?", Grid1.GetSelectedCountReference());
 | 
						|
 | 
						|
                ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
 | 
						|
                // 绑定表格
 | 
						|
                BindGrid();
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 绑定数据
 | 
						|
        /// </summary>
 | 
						|
        private void BindGrid()
 | 
						|
        {
 | 
						|
            string strSql = @"SELECT CostReport.CostReportId, 
 | 
						|
                                     CostReport.EProjectId, 
 | 
						|
                                     CostReport.Monthly, 
 | 
						|
                                     CostReport.OrginalBudget, 
 | 
						|
                                     CostReport.ChangedBudget, 
 | 
						|
                                     CostReport.ActualCost, 
 | 
						|
                                     CostReport.CommittedPRPO, 
 | 
						|
                                     CostReport.CommittedSSRs, 
 | 
						|
                                     CostReport.CostToComplete,
 | 
						|
                                     eProject.ProjectControl_JobNo,
 | 
						|
                                     eProject.ProjectControl_JobType "
 | 
						|
                       + @" FROM Editor_CostReport AS CostReport "
 | 
						|
                       + @" LEFT JOIN dbo.Editor_EProject AS eProject ON eProject.EProjectId = CostReport.EProjectId "
 | 
						|
                       + @" WHERE 1=1 ";
 | 
						|
            List<SqlParameter> listStr = new List<SqlParameter>();
 | 
						|
            if (!string.IsNullOrEmpty(this.txtJobNO.Text.Trim()))
 | 
						|
            {
 | 
						|
                strSql += " AND eProject.ProjectControl_JobNo LIKE @jobNo ";
 | 
						|
                listStr.Add(new SqlParameter("@jobNo", this.txtJobNO.Text.Trim() + "%"));
 | 
						|
            }
 | 
						|
            if (!string.IsNullOrEmpty(this.txtMonthlyS.Text.Trim()))
 | 
						|
            {
 | 
						|
                strSql += " AND CostReport.Monthly=@Monthly ";
 | 
						|
                listStr.Add(new SqlParameter("@Monthly", string.Format("{0:yyyy-MM}", this.txtMonthlyS.Text.Trim())));
 | 
						|
            }
 | 
						|
            strSql += " ORDER BY Monthly DESC ";
 | 
						|
            SqlParameter[] parameter = listStr.ToArray();
 | 
						|
            DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
 | 
						|
            // 2.获取当前分页数据
 | 
						|
            //var table = this.GetPagedDataTable(Grid1, tb1);
 | 
						|
            Grid1.RecordCount = tb.Rows.Count;
 | 
						|
            var table = this.GetPagedDataTable(Grid1, tb);
 | 
						|
            Grid1.DataSource = table;
 | 
						|
            Grid1.DataBind();
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region  删除数据
 | 
						|
        /// <summary>
 | 
						|
        /// 批量删除数据
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void btnDelete_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            this.DeleteData();
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 右键删除事件
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void btnMenuDelete_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            this.DeleteData();
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 删除方法
 | 
						|
        /// </summary>
 | 
						|
        private void DeleteData()
 | 
						|
        {
 | 
						|
            if (Grid1.SelectedRowIndexArray.Length > 0)
 | 
						|
            {
 | 
						|
                foreach (int rowIndex in Grid1.SelectedRowIndexArray)
 | 
						|
                {
 | 
						|
                    string rowID = Grid1.DataKeys[rowIndex][0].ToString();
 | 
						|
                    var costReport = BLL.CostReportService.GetCostReportById(rowID);
 | 
						|
                    if (costReport != null)
 | 
						|
                    {
 | 
						|
                        if (judgementDelete(rowID, false))
 | 
						|
                        {
 | 
						|
                            BLL.CostReportService.DeleteCostReportById(rowID);
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                BindGrid();
 | 
						|
                BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "Delete Cost report information");
 | 
						|
                ShowNotify("Deleted successfully!");
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 分页、排序
 | 
						|
        /// <summary>
 | 
						|
        /// 分页
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
 | 
						|
        {
 | 
						|
            Grid1.PageIndex = e.NewPageIndex;
 | 
						|
            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 关闭弹出窗口
 | 
						|
        /// <summary>
 | 
						|
        /// 关闭窗口
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void Window1_Close(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            BindGrid();
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 编辑
 | 
						|
        /// <summary>
 | 
						|
        /// 编辑
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void btnEdit_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (Grid1.SelectedRowIndexArray.Length == 0)
 | 
						|
            {
 | 
						|
                Alert.ShowInParent("Please select at least one record!");
 | 
						|
                return;
 | 
						|
            }
 | 
						|
            string Id = Grid1.SelectedRowID;
 | 
						|
            PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("CostReportEdit.aspx?costReportId={0}",Id, "编辑 - ")));
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 右键编辑事件
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void btnMenuEdit_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            btnEdit_Click(null, null);
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Grid行双击事件
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
 | 
						|
        {
 | 
						|
            btnEdit_Click(null, null);
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 判断是否可删除
 | 
						|
        /// <summary>
 | 
						|
        /// 判断是否可以删除
 | 
						|
        /// </summary>
 | 
						|
        /// <returns></returns>
 | 
						|
        private bool judgementDelete(string id, bool isShow)
 | 
						|
        {
 | 
						|
            string content = string.Empty;
 | 
						|
 | 
						|
            if (string.IsNullOrEmpty(content))
 | 
						|
            {
 | 
						|
                return true;
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                if (isShow)
 | 
						|
                {
 | 
						|
                    Alert.ShowInTop(content);
 | 
						|
                }
 | 
						|
                return false;
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 权限设置
 | 
						|
        /// <summary>
 | 
						|
        /// 菜单按钮权限
 | 
						|
        /// </summary>
 | 
						|
        private void GetButtonPower()
 | 
						|
        {
 | 
						|
            var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.UserId, BLL.Const.CostReportMenuId);
 | 
						|
            if (buttonList.Count() > 0)
 | 
						|
            {
 | 
						|
                //if (buttonList.Contains(BLL.Const.BtnAdd))
 | 
						|
                //{
 | 
						|
                //    this.btnNew.Hidden = false;
 | 
						|
                //}
 | 
						|
                //if (buttonList.Contains(BLL.Const.BtnModify))
 | 
						|
                //{
 | 
						|
                //    this.btnEdit.Hidden = false;
 | 
						|
                //    this.btnMenuEdit.Hidden = false;
 | 
						|
                //}
 | 
						|
                //if (buttonList.Contains(BLL.Const.BtnDelete))
 | 
						|
                //{
 | 
						|
                //    this.btnDelete.Hidden = false;
 | 
						|
                //    this.btnMenuDelete.Hidden = false;
 | 
						|
                //}
 | 
						|
                if (buttonList.Contains(BLL.Const.BtnIn))
 | 
						|
                {
 | 
						|
                    this.btnImport.Hidden = false;
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 查询
 | 
						|
        /// <summary>
 | 
						|
        /// 下拉框选择事件
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void btnSearch_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            BindGrid();
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 导入
 | 
						|
        /// <summary>
 | 
						|
        /// 导入
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void btnImport_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("CostReportIn.aspx", "导入 - ")));
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
    }
 | 
						|
} |