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 { /// /// 绩效表主键 /// 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 listStr = new List(); 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("index"); string id = Grid1.Rows[i].RowID; JObject values = mergedRow.Value("values"); Model.Person_QuarterCheckItem Item = BLL.Person_QuarterCheckItemService.GetCheckItemById(id); if (Item != null) { Item.Grade = values.Value("Grade").ToString() == "" ? 0 : values.Value("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 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()); } } } }