SGGL_SHJ/SGGL/FineUIPro.Web/Person/DepartPersonChecking.aspx.cs

102 lines
4.4 KiB
C#
Raw Normal View History

2022-09-05 16:36:31 +08:00
using BLL;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
namespace FineUIPro.Web.Person
{
public partial class DepartPersonChecking : PageBase
{
/// <summary>
/// 绩效表主键
/// </summary>
public string QuarterCheckId
{
get
{
return (string)ViewState["QuarterCheckId"];
}
set
{
ViewState["QuarterCheckId"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.QuarterCheckId = Request.Params["QuarterCheckId"];
Model.Person_QuarterCheck getCheck = BLL.Person_QuarterCheckService.GetPerson_QuarterCheckById(this.QuarterCheckId);
if (getCheck != null)
{
this.txtCheckedMan.Text = Person_PersonsService.GetPersonsNameById(getCheck.UserId);
this.txtRoleName.Text = BLL.RoleService.getRoleNamesRoleIds(getCheck.RoleId);
this.txtProject.Text = BLL.ProjectService.GetProjectNameByProjectId(getCheck.ProjectId);
if (string.IsNullOrEmpty(this.txtProject.Text))
{
this.txtProject.Hidden = true;
}
}
BindGrid();
}
}
private void BindGrid()
{
string strSql = @"select QuarterCheckItemId, QuarterCheckId, C.UserId, TargetClass2, CheckContent,'100' AS standardGrade, Grade,TargetClass1,SortId from [dbo].[Person_QuarterCheckItem] C
left join Person_Persons U on C.UserId=U.PersonId where QuarterCheckId=@QuarterCheckId";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@QuarterCheckId", this.QuarterCheckId));
strSql += " AND C.UserId=@UserId";
listStr.Add(new SqlParameter("@UserId", this.CurrUser.PersonId));
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();
}
protected void btnSave_Click(object sender, EventArgs e)
{
if (Grid1.GetMergedData().Count > 0)
{
foreach (JObject mergedRow in Grid1.GetMergedData())
{
int i = mergedRow.Value<int>("index");
string id = Grid1.Rows[i].RowID;
JObject values = mergedRow.Value<JObject>("values");
Model.Person_QuarterCheckItem Item = BLL.Person_QuarterCheckItemService.GetCheckItemById(id);
if (Item != null)
{
Item.Grade = values.Value<decimal>("Grade").ToString() == "" ? 0 : values.Value<decimal>("Grade");
}
BLL.Person_QuarterCheckItemService.UpdateCheckItem(Item);
}
Model.Person_QuarterCheckApprove getApprove = BLL.Person_QuarterCheckApproveService.GetApproveByQuarterCheckIdUserId(this.QuarterCheckId, this.CurrUser.PersonId);
if (getApprove != null)
{
getApprove.ApproveDate = DateTime.Now;
}
BLL.Person_QuarterCheckApproveService.UpdateCheckApprove(getApprove);
List<Model.Person_QuarterCheckApprove> Approve = BLL.Person_QuarterCheckApproveService.GetApproveByQuarterCheckId(this.QuarterCheckId);
if (Approve.Count == 0)
{
Model.Person_QuarterCheck Construct = BLL.Person_QuarterCheckService.GetPerson_QuarterCheckById(this.QuarterCheckId);
if (Construct != null)
{
Construct.State = "1";
BLL.Person_QuarterCheckService.UpdatePerson_QuarterCheck(Construct);
}
}
ShowNotify("提交成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
}
}
}