294 lines
12 KiB
C#
294 lines
12 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using BLL;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace FineUIPro.Web.JDGL.Check
|
|
{
|
|
public partial class WeekPlan : PageBase
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
GetButtonPower();
|
|
btnNew.OnClientClick = Window1.GetShowReference("WeekPlanEdit.aspx") + "return false;";
|
|
this.drpWeekNo.DataTextField = "Text";
|
|
this.drpWeekNo.DataValueField = "Value";
|
|
var weekPlans = (from x in Funs.DB.JDGL_WeekPlan where x.ProjectId == this.CurrUser.LoginProjectId orderby x.StartDate descending select x.WeekNo).Distinct().OrderByDescending(x => x).ToList();
|
|
if (weekPlans.Count() > 0)
|
|
{
|
|
ListItem[] list = new ListItem[weekPlans.Count()];
|
|
for (int i = 0; i < weekPlans.Count(); i++)
|
|
{
|
|
list[i] = new ListItem(weekPlans[i], weekPlans[i]);
|
|
}
|
|
this.drpWeekNo.DataSource = list;
|
|
this.drpWeekNo.DataBind();
|
|
this.drpWeekNo.SelectedValue = list[0].Value;
|
|
}
|
|
else
|
|
{
|
|
this.drpWeekNo.DataSource = null;
|
|
this.drpWeekNo.DataBind();
|
|
}
|
|
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.WeekPlanMenuId);
|
|
if (buttonList.Count() > 0)
|
|
{
|
|
if (buttonList.Contains(BLL.Const.BtnSave))
|
|
{
|
|
this.btnNew.Hidden = false;
|
|
this.btnModify.Hidden = false;
|
|
this.btnMenuDel.Hidden = false;
|
|
this.btnMenuDel2.Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
protected void btnModify_Click(object sender, EventArgs e)
|
|
{
|
|
Window1.Title = "录入";
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeekPlanEdit.aspx?WeekNo={0}", this.drpWeekNo.SelectedValue, "编辑 - ")));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载Grid
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string weekNo2 = string.Empty;
|
|
var weekPlan = Funs.DB.JDGL_WeekPlan.FirstOrDefault(x => x.WeekNo == this.drpWeekNo.SelectedValue);
|
|
if (weekPlan != null)
|
|
{
|
|
if (weekPlan.StartDate != null)
|
|
{
|
|
this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", weekPlan.StartDate);
|
|
}
|
|
if (weekPlan.EndDate != null)
|
|
{
|
|
this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", weekPlan.EndDate);
|
|
}
|
|
var lastWeekPlan = (from x in Funs.DB.JDGL_WeekPlan where x.ProjectId == this.CurrUser.LoginProjectId && x.StartDate < weekPlan.StartDate orderby x.StartDate descending select x).FirstOrDefault();
|
|
if (lastWeekPlan != null)
|
|
{
|
|
weekNo2 = lastWeekPlan.WeekNo;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.txtStartDate.Text = string.Empty;
|
|
this.txtEndDate.Text = string.Empty;
|
|
}
|
|
string strSql = @"select mp.*,u.UnitName,us.UserName as DutyPersonName,uw.UnitWorkName,cn.ProfessionalName,case mp.IsOK when 1 then '已完成' when 0 then '未完成' else '' end as IsOKStr from [dbo].[JDGL_WeekPlan] mp
|
|
left join Base_Unit u on u.UnitId=mp.UnitId
|
|
left join Sys_User us on us.UserId=mp.DutyPerson
|
|
left join WBS_UnitWork uw on uw.UnitWorkId=mp.UnitWork
|
|
left join Base_CNProfessional cn on cn.CNProfessionalId=mp.Major
|
|
where mp.ProjectId=@ProjectId and mp.WeekNo=@WeekNo order by mp.SortIndex";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
|
string weekNo = string.Empty;
|
|
if (!string.IsNullOrEmpty(this.drpWeekNo.SelectedValue))
|
|
{
|
|
weekNo = this.drpWeekNo.SelectedValue;
|
|
}
|
|
listStr.Add(new SqlParameter("@WeekNo", weekNo));
|
|
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();
|
|
|
|
string strSql2 = @"select mp.*,u.UnitName,us.UserName as DutyPersonName,uw.UnitWorkName,cn.ProfessionalName,case mp.IsOK when 1 then '已完成' when 0 then '未完成' else '' end as IsOKStr from [dbo].[JDGL_WeekPlan] mp
|
|
left join Base_Unit u on u.UnitId=mp.UnitId
|
|
left join Sys_User us on us.UserId=mp.DutyPerson
|
|
left join WBS_UnitWork uw on uw.UnitWorkId=mp.UnitWork
|
|
left join Base_CNProfessional cn on cn.CNProfessionalId=mp.Major
|
|
where mp.ProjectId=@ProjectId2 and mp.WeekNo=@WeekNo2 order by mp.SortIndex";
|
|
List<SqlParameter> listStr2 = new List<SqlParameter>();
|
|
listStr2.Add(new SqlParameter("@ProjectId2", this.CurrUser.LoginProjectId));
|
|
|
|
listStr2.Add(new SqlParameter("@WeekNo2", weekNo2));
|
|
SqlParameter[] parameter2 = listStr2.ToArray();
|
|
DataTable tb2 = SQLHelper.GetDataTableRunText(strSql2, parameter2);
|
|
Grid2.RecordCount = tb2.Rows.Count;
|
|
//tb = GetFilteredTable(Grid1.FilteredData, tb);
|
|
var table2 = this.GetPagedDataTable(Grid2, tb2);
|
|
Grid2.DataSource = table2;
|
|
Grid2.DataBind();
|
|
}
|
|
|
|
#region 月份选择事件
|
|
/// <summary>
|
|
/// 月份选择事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void txtWeeks_TextChanged(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 保存按钮
|
|
/// <summary>
|
|
/// 保存按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.Grid1.Rows.Count > 0)
|
|
{
|
|
JArray mergedData = Grid1.GetMergedData();
|
|
foreach (JObject mergedRow in mergedData)
|
|
{
|
|
JObject values = mergedRow.Value<JObject>("values");
|
|
int i = mergedRow.Value<int>("index");
|
|
Model.JDGL_WeekPlan WeekPlan = BLL.WeekPlanService.GetWeekPlanById(this.Grid1.Rows[i].RowID);
|
|
if (WeekPlan != null)
|
|
{
|
|
WeekPlan.CompileMan = this.CurrUser.UserId;
|
|
WeekPlan.CompileDate = DateTime.Now;
|
|
BLL.WeekPlanService.UpdateWeekPlan(WeekPlan);
|
|
}
|
|
}
|
|
Alert.ShowInTop("保存成功!", MessageBoxIcon.Success);
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
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();
|
|
BLL.WeekPlanService.DeleteWeekPlanByWeekPlanId(rowID);
|
|
}
|
|
//var weekPlans = (from x in Funs.DB.JDGL_WeekPlan where x.ProjectId == this.CurrUser.LoginProjectId orderby x.StartDate descending select x.WeekNo).Distinct().OrderByDescending(x => x).ToList();
|
|
//if (weekPlans.Count() > 0)
|
|
//{
|
|
// ListItem[] list = new ListItem[weekPlans.Count()];
|
|
// for (int i = 0; i < weekPlans.Count(); i++)
|
|
// {
|
|
// list[i] = new ListItem(weekPlans[i], weekPlans[i]);
|
|
// }
|
|
// this.drpWeekNo.DataSource = list;
|
|
// this.drpWeekNo.DataBind();
|
|
// this.drpWeekNo.SelectedValue = list[0].Value;
|
|
//}
|
|
//else
|
|
//{
|
|
// this.drpWeekNo.DataSource = null;
|
|
// this.drpWeekNo.DataBind();
|
|
//}
|
|
BindGrid();
|
|
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
|
|
}
|
|
}
|
|
|
|
protected void btnMenuDel2_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid2.SelectedRowIndexArray.Length > 0)
|
|
{
|
|
foreach (int rowIndex in Grid2.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid2.DataKeys[rowIndex][0].ToString();
|
|
BLL.WeekPlanService.DeleteWeekPlanByWeekPlanId(rowID);
|
|
}
|
|
BindGrid();
|
|
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
|
|
}
|
|
}
|
|
|
|
#region 导入
|
|
/// <summary>
|
|
/// 导入按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnImport_Click(object sender, EventArgs e)
|
|
{
|
|
Window1.Title = "导入";
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeekPlanIn.aspx?ProjectId={0}", this.CurrUser.LoginProjectId, "导入 - ")));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 关闭导入弹出窗口
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
var weekPlans = (from x in Funs.DB.JDGL_WeekPlan where x.ProjectId == this.CurrUser.LoginProjectId orderby x.StartDate descending select x.WeekNo).Distinct().OrderByDescending(x => x).ToList();
|
|
if (weekPlans.Count() > 0)
|
|
{
|
|
ListItem[] list = new ListItem[weekPlans.Count()];
|
|
for (int i = 0; i < weekPlans.Count(); i++)
|
|
{
|
|
list[i] = new ListItem(weekPlans[i], weekPlans[i]);
|
|
}
|
|
this.drpWeekNo.DataSource = list;
|
|
this.drpWeekNo.DataBind();
|
|
this.drpWeekNo.SelectedValue = list[0].Value;
|
|
}
|
|
else
|
|
{
|
|
this.drpWeekNo.DataSource = null;
|
|
this.drpWeekNo.DataBind();
|
|
}
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 统计
|
|
/// <summary>
|
|
/// 统计分析
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void BtnAnalyse_Click(object sender, EventArgs e)
|
|
{
|
|
Window1.Title = "统计";
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeekPlanStatisc.aspx", "统计 - ")));
|
|
}
|
|
#endregion
|
|
|
|
protected void drpWeekNo_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
}
|
|
} |