SGGL_JT/SUBQHSE/FineUIPro.Web/Door/LeaveRecordEdit.aspx.cs

116 lines
4.0 KiB
C#

using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.Door
{
public partial class LeaveRecordEdit :PageBase
{
/// <summary>
/// 项目id
/// </summary>
public string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ProjectId = Request.Params["projectId"];
txtStartTime.SelectedDate=DateTime.Now;
txtEndTime.SelectedDate = DateTime.Now;
if (!string.IsNullOrEmpty(this.ProjectId))
{
UnitService.InitUnitDropDownList(this.drpUnit, this.ProjectId, true);
GetAbsenceDuty();
}
}
}
private void GetAbsenceDuty()
{
if (string.IsNullOrEmpty(ProjectId)) return ;
string unitId = null;
if (this.drpUnit.SelectedValue != Const._Null && !string.IsNullOrEmpty(this.drpUnit.SelectedValue))
{
unitId = Funs.GetStringByArray(this.drpUnit.SelectedValueArray);
}
var getData = Funs.DB.spAbsenceDutyReport(this.ProjectId, unitId, null, Funs.GetNewDateTimeOrNow(this.txtStartTime.Text)) ;
if (this.drpWorkTeam.SelectedValue != Const._Null && !string.IsNullOrEmpty(this.drpWorkTeam.SelectedValue))
{
getData=getData.Where(x => x.TeamGroupId == this.drpWorkTeam.SelectedValue);
}
if (!string.IsNullOrEmpty(txtPersonName.Text.Trim()))
{
getData = getData.Where(x => x.PersonName .Contains(this.txtPersonName.Text) );
}
if (!string.IsNullOrEmpty(txtIdentityCard.Text.Trim()))
{
getData = getData.Where(x => x.IdentityCard.Contains (this.txtIdentityCard.Text));
}
DataTable tb = this.LINQToDataTable(getData.ToList());
Grid1.RecordCount = tb.Rows.Count;
Grid1.DataSource = tb;
Grid1.DataBind();
}
protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e)
{
TeamGroupService.InitTeamGroupProjectUnitDropDownList(this.drpWorkTeam, this.ProjectId, drpUnit.SelectedValue, true);
GetAbsenceDuty();
}
protected void TextBox_TextChanged(object sender, EventArgs e)
{
GetAbsenceDuty();
}
protected void btnSave_Click(object sender, EventArgs e)
{
var personIdList = drpPersonId.Values;
if (personIdList.Length == 0)
{
Alert.ShowInTop("请选择人员!");
return;
}
foreach (var item in personIdList)
{
var person = PersonService.GetPersonById(item);
if (person!=null)
{
Model.SitePerson_PersonLeave table = new Model.SitePerson_PersonLeave();
table.Id = SQLHelper.GetNewID();
table.ProjectId = this.ProjectId;
table.PersonId = item;
table.StartTime = string.Format("{0:yyyy-MM-dd}", txtStartTime.SelectedDate);
table.EndTime = string.Format("{0:yyyy-MM-dd}", txtEndTime.SelectedDate);
table.Title = txtTitle.Text;
table.IdCrads = person.IdentityCard;
SitepersonPersonleaveService.AddSitePerson_PersonLeave(table);
}
}
ShowNotify("提交成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
}
}