226 lines
8.6 KiB
C#
226 lines
8.6 KiB
C#
using BLL;
|
|
using Model;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices.ComTypes;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.JDGL.Check
|
|
{
|
|
public partial class WeekPlanSelect : PageBase
|
|
{
|
|
/// <summary>
|
|
/// 定义项
|
|
/// </summary>
|
|
public string WeekNo
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["WeekNo"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["WeekNo"] = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 项目id
|
|
/// </summary>
|
|
public string ProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ProjectId"] = value;
|
|
}
|
|
}
|
|
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
Funs.DropDownPageSize(this.ddlPageSize);
|
|
this.WeekNo = Request.QueryString["WeekNo"];
|
|
this.ProjectId = this.CurrUser.LoginProjectId;
|
|
if (this.CurrUser != null && this.CurrUser.PageSize.HasValue)
|
|
{
|
|
Grid1.PageSize = this.CurrUser.PageSize.Value;
|
|
}
|
|
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
|
|
//BLL.UnitService.InitUnitDropDownList(this.drpUnit, this.ProjectId, false);
|
|
//if (!string.IsNullOrEmpty(this.CurrUser.UnitId))
|
|
//{
|
|
// this.drpUnit.SelectedValue = this.CurrUser.UnitId;
|
|
//}
|
|
// 绑定表格
|
|
this.BindGrid();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
//其他周计划(排除本周)
|
|
string strSql = @"select mp.*,u.UnitName,uw.UnitWorkName,cn.ProfessionalName,case mp.IsOK when 1 then '已完成' when 0 then '未完成' else '' end as IsOKStr
|
|
,DutyPersonName = STUFF((SELECT ',' + p.UserName FROM dbo.Sys_User as p where PATINDEX('%,' + RTRIM(p.UserId) + ',%', ',' + mp.DutyPerson + ',') > 0 FOR XML PATH('')), 1, 1,'')
|
|
from [dbo].[JDGL_WeekPlan] mp
|
|
left join Base_Unit u on u.UnitId=mp.UnitId
|
|
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.WeekNo desc,mp.SortIndex ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@ProjectId", this.ProjectId));
|
|
listStr.Add(new SqlParameter("@WeekNo", WeekNo));
|
|
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 排序 分页
|
|
/// <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
|
|
|
|
/// <summary>
|
|
/// 确定按钮事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSure_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
var lastWeekPlan = Funs.DB.JDGL_WeekPlan.Where(x => x.ProjectId == this.ProjectId && x.WeekNo == WeekNo).OrderByDescending(x => x.SortIndex).FirstOrDefault();
|
|
int sortIndex = lastWeekPlan != null ? (int)lastWeekPlan.SortIndex + 1 : 1;
|
|
//根据周号查询周信息(起始时间)
|
|
var weekItem = BLL.WeekItemService.GetWeekItemByProjectIdAndWeekNo(this.ProjectId, int.Parse(WeekNo));
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
this.SaveData(Grid1.DataKeys[rowIndex][0].ToString(), weekItem, sortIndex);
|
|
sortIndex++;
|
|
}
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 双击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
var lastWeekPlan = Funs.DB.JDGL_WeekPlan.Where(x => x.ProjectId == this.ProjectId && x.WeekNo == WeekNo).OrderByDescending(x => x.SortIndex).FirstOrDefault();
|
|
int sortIndex = lastWeekPlan != null ? (int)lastWeekPlan.SortIndex + 1 : 1;
|
|
//根据周号查询周信息(起始时间)
|
|
var weekItem = BLL.WeekItemService.GetWeekItemByProjectIdAndWeekNo(this.ProjectId, int.Parse(WeekNo));
|
|
this.SaveData(Grid1.SelectedRowID, weekItem, sortIndex);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 保存数据
|
|
/// </summary>
|
|
/// <param name="weekPlanId">被选中的周计划Id</param>
|
|
/// <param name="weekItem">周信息</param>
|
|
/// <param name="sortIndex">计划排序</param>
|
|
private void SaveData(string weekPlanId, JDGL_WeekItem weekItem, int sortIndex)
|
|
{
|
|
var weekPlan = Funs.DB.JDGL_WeekPlan.FirstOrDefault(x => x.WeekPlanId == weekPlanId);
|
|
if (weekPlan != null)
|
|
{
|
|
Model.JDGL_WeekPlan WeekPlan = new Model.JDGL_WeekPlan();
|
|
WeekPlan.WeekPlanId = SQLHelper.GetNewID(typeof(Model.JDGL_WeekPlan));
|
|
WeekPlan.ProjectId = this.CurrUser.LoginProjectId;
|
|
WeekPlan.WeekNo = weekItem.WeekNo.ToString();
|
|
WeekPlan.StartDate = weekItem.StartDate;
|
|
WeekPlan.EndDate = weekItem.EndDate;
|
|
WeekPlan.PlanDate = weekItem.EndDate;//计划完成时间默认周结束时间
|
|
WeekPlan.UnitWork = weekPlan.UnitWork;
|
|
WeekPlan.Major = weekPlan.Major;
|
|
WeekPlan.UnitId = weekPlan.UnitId;
|
|
WeekPlan.WorkContent = weekPlan.WorkContent;
|
|
WeekPlan.DutyPerson = weekPlan.DutyPerson;
|
|
WeekPlan.IsOK = false;//默认未完成
|
|
WeekPlan.Remark = weekPlan.Remark;
|
|
WeekPlan.CompileMan = this.CurrUser.UserId;
|
|
WeekPlan.CompileDate = DateTime.Now;
|
|
WeekPlan.SortIndex = sortIndex;
|
|
BLL.WeekPlanService.AddWeekPlan(WeekPlan);
|
|
}
|
|
}
|
|
}
|
|
} |