359 lines
13 KiB
C#
359 lines
13 KiB
C#
using System;
|
|
using System.Linq;
|
|
using Newtonsoft.Json.Linq;
|
|
using System.Data.SqlClient;
|
|
using System.Data;
|
|
using BLL;
|
|
|
|
namespace FineUIPro.Web.common.ProjectSet
|
|
{
|
|
public partial class EditTeamGroup : PageBase
|
|
{
|
|
/// <summary>
|
|
///项目单位主键
|
|
/// </summary>
|
|
public string ProjectUnitId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ProjectUnitId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ProjectUnitId"] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
///单位主键
|
|
/// </summary>
|
|
public string UnitId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["UnitId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["UnitId"] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
///项目主键
|
|
/// </summary>
|
|
public string ProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ProjectId"] = value;
|
|
}
|
|
}
|
|
|
|
private bool AppendToEnd = false;
|
|
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.ProjectUnitId = Request.Params["projectUnitId"];
|
|
this.ProjectId = Request.Params["projectId"];
|
|
|
|
Model.Project_Unit pUnit = BLL.Project_UnitService.GetProject_UnitByProjectUnitId(ProjectUnitId);
|
|
if (pUnit != null)
|
|
{
|
|
UnitId = pUnit.UnitId;
|
|
var unit = BLL.Base_UnitService.GetUnit(UnitId);
|
|
BLL.Base_UnitService.UnitTypeDropDownList(this.drpUnitType, true,Resources.Lan.PleaseSelect);
|
|
if (pUnit.InTime != null)
|
|
{
|
|
txtInTime.Text = string.Format("{0:yyyy-MM-dd}", pUnit.InTime);
|
|
}
|
|
if (pUnit.OutTime != null)
|
|
{
|
|
this.txtOutTime.Text = string.Format("{0:yyyy-MM-dd}", pUnit.OutTime);
|
|
}
|
|
this.txtPhone.Text = pUnit.Phone;
|
|
if (pUnit.ProjectRange != null)
|
|
{
|
|
this.txtProjectRange.Text = pUnit.ProjectRange.Trim();
|
|
}
|
|
if (pUnit.UnitType != null)
|
|
{
|
|
string u = pUnit.UnitType.Split(',')[0];
|
|
drpUnitType.SelectedValue = u;
|
|
}
|
|
if (pUnit.WelderQueIsUse == true)
|
|
{
|
|
ckbIsUse.Checked = true;
|
|
}
|
|
else
|
|
{
|
|
ckbIsUse.Checked = false;
|
|
}
|
|
}
|
|
|
|
//// 删除选中单元格的客户端脚本
|
|
//string deleteScript = GetDeleteScript();
|
|
//// 新增数据初始值
|
|
//JObject defaultObj = new JObject();
|
|
//defaultObj.Add("Post", "");
|
|
//defaultObj.Add("CardNo", "");
|
|
//defaultObj.Add("PersonName", "");
|
|
//defaultObj.Add("CellPhone", "");
|
|
//defaultObj.Add("Telephone", "");
|
|
//defaultObj.Add("Email", "");
|
|
//defaultObj.Add("Delete", String.Format("<a href=\"javascript:;\" onclick=\"{0}\"><img src=\"{1}\"/></a>", deleteScript, IconHelper.GetResolvedIconUrl(Icon.Delete)));
|
|
|
|
//// 在第一行新增一条数据
|
|
//btnNew.OnClientClick = Grid1.GetAddNewRecordReference(defaultObj, AppendToEnd);
|
|
|
|
//// 删除选中行按钮
|
|
//btnDelete.OnClientClick = Grid1.GetNoSelectionAlertReference("请至少选择一项!") + deleteScript;
|
|
|
|
|
|
// 绑定表格
|
|
//BindGrid();
|
|
|
|
// 删除选中单元格的客户端脚本
|
|
string deleteScript2 = GetDeleteScript2();
|
|
// 新增数据初始值
|
|
JObject defaultObj2 = new JObject();
|
|
defaultObj2.Add("TeamGroupCode", "");
|
|
defaultObj2.Add("TeamGroupName", "");
|
|
defaultObj2.Add("Remark", "");
|
|
defaultObj2.Add("Delete", String.Format("<a href=\"javascript:;\" onclick=\"{0}\"><img src=\"{1}\"/></a>", deleteScript2, IconHelper.GetResolvedIconUrl(Icon.Delete)));
|
|
|
|
// 在第一行新增一条数据
|
|
btnNew2.OnClientClick = Grid2.GetAddNewRecordReference(defaultObj2, AppendToEnd);
|
|
|
|
// 删除选中行按钮
|
|
btnDelete2.OnClientClick = Grid2.GetNoSelectionAlertReference(Resources.Lan.SelectLeastOneRecord) + deleteScript2;
|
|
|
|
|
|
// 绑定表格
|
|
BindGrid2();
|
|
//drpPost.DataTextField = "PostName";
|
|
//drpPost.DataValueField = "PostName";
|
|
//drpPost.DataSource = BLL.Base_PostService.GetPostList();
|
|
//drpPost.DataBind();
|
|
}
|
|
}
|
|
|
|
///// <summary>
|
|
///// 绑定数据
|
|
///// </summary>
|
|
//private void BindGrid()
|
|
//{
|
|
// string strSql = @"select * from dbo.Base_Organization where ProjectId=@ProjectId and UnitId=@UnitId order by Post";
|
|
|
|
// SqlParameter[] parameter = new SqlParameter[]
|
|
// {
|
|
// new SqlParameter("@ProjectId",this.ProjectId),
|
|
// new SqlParameter("@UnitId",this.UnitId),
|
|
// };
|
|
|
|
// DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
// Grid1.DataSource = tb;
|
|
// Grid1.DataBind();
|
|
//}
|
|
|
|
private void BindGrid2()
|
|
{
|
|
string strSql = @"select * from dbo.Welder_TeamGroup where ProjectId=@ProjectId and UnitId=@UnitId order by TeamGroupCode";
|
|
|
|
SqlParameter[] parameter = new SqlParameter[]
|
|
{
|
|
new SqlParameter("@ProjectId",this.ProjectId),
|
|
new SqlParameter("@UnitId",this.UnitId),
|
|
};
|
|
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
Grid2.DataSource = tb;
|
|
Grid2.DataBind();
|
|
}
|
|
#endregion
|
|
|
|
#region 保存
|
|
/// <summary>
|
|
/// 保存按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.ProjectUnitMenuId, Const.BtnSave))
|
|
{
|
|
if (!string.IsNullOrEmpty(this.txtPhone.Text.Trim()))
|
|
{
|
|
if (this.txtPhone.Text.Trim().Length > 15)
|
|
{
|
|
ShowNotify(Resources.Lan.MorePhones, MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
// 项目单位信息
|
|
Model.Project_Unit pUnit = BLL.Project_UnitService.GetProject_UnitByProjectUnitId(this.ProjectUnitId);
|
|
if (!string.IsNullOrEmpty(this.txtInTime.Text))
|
|
{
|
|
pUnit.InTime = Convert.ToDateTime(this.txtInTime.Text);
|
|
}
|
|
else
|
|
{
|
|
pUnit.InTime = null;
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtOutTime.Text))
|
|
{
|
|
pUnit.OutTime = Convert.ToDateTime(this.txtOutTime.Text);
|
|
}
|
|
else
|
|
{
|
|
pUnit.OutTime = null;
|
|
}
|
|
pUnit.Phone = this.txtPhone.Text.Trim();
|
|
if (!string.IsNullOrEmpty(this.txtProjectRange.Text))
|
|
{
|
|
pUnit.ProjectRange = this.txtProjectRange.Text.Trim();
|
|
}
|
|
else
|
|
{
|
|
pUnit.ProjectRange = null;
|
|
}
|
|
pUnit.UnitType = drpUnitType.SelectedValue;
|
|
|
|
if (ckbIsUse.Checked)
|
|
{
|
|
pUnit.WelderQueIsUse = true;
|
|
}
|
|
else
|
|
{
|
|
pUnit.WelderQueIsUse = null;
|
|
}
|
|
|
|
BLL.Project_UnitService.UpdateProject_Unit(pUnit);
|
|
|
|
|
|
if (Grid2.GetDeletedList().Count() > 0)
|
|
{
|
|
foreach (int i in Grid2.GetDeletedList())
|
|
{
|
|
string rowID = Grid2.DataKeys[i][0].ToString();
|
|
BLL.Welder_TeamGroupService.DeleteTeamGroupById(rowID);
|
|
}
|
|
}
|
|
|
|
if (Grid2.GetModifiedData().Count > 0)
|
|
{
|
|
JArray teamGroupData = Grid2.GetMergedData();
|
|
foreach (JObject teamGroupRow in teamGroupData)
|
|
{
|
|
string status = teamGroupRow.Value<string>("status");
|
|
JObject values = teamGroupRow.Value<JObject>("values");
|
|
Model.Welder_TeamGroup team = new Model.Welder_TeamGroup();
|
|
|
|
team.ProjectId = this.ProjectId;
|
|
team.UnitId = this.UnitId;
|
|
team.TeamGroupCode = values.Value<string>("TeamGroupCode");
|
|
team.TeamGroupName = values.Value<string>("TeamGroupName");
|
|
team.Remark = values.Value<string>("Remark");
|
|
|
|
if (status == "newadded")
|
|
{
|
|
team.TeamGroupId = SQLHelper.GetNewID(typeof(Model.Welder_TeamGroup));
|
|
BLL.Welder_TeamGroupService.AddTeamGroup(team);
|
|
}
|
|
else
|
|
{
|
|
team.TeamGroupId = teamGroupRow.Value<string>("id");
|
|
BLL.Welder_TeamGroupService.UpdateTeamGroup(team);
|
|
}
|
|
|
|
}
|
|
}
|
|
//BindGrid();
|
|
BindGrid2();
|
|
|
|
ShowNotify(Resources.Lan.SaveSuccessfully,MessageBoxIcon.Success);
|
|
}
|
|
else
|
|
{
|
|
ShowNotify(Resources.Lan.NoPrivilegePrompt,MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Grid2排序、删除提示
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid2_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
{
|
|
Grid2.SortDirection = e.SortDirection;
|
|
Grid2.SortField = e.SortField;
|
|
BindGrid2();
|
|
}
|
|
|
|
private string GetDeleteScript2()
|
|
{
|
|
return Confirm.GetShowReference(Resources.Lan.DeleteReminder, String.Empty, MessageBoxIcon.Question, Grid2.GetDeleteSelectedRowsReference(), String.Empty);
|
|
}
|
|
|
|
protected void Grid2_PreDataBound(object sender, EventArgs e)
|
|
{
|
|
// 设置LinkButtonField的点击客户端事件
|
|
LinkButtonField deleteField = Grid2.FindColumn("Delete") as LinkButtonField;
|
|
deleteField.OnClientClick = GetDeleteScript2();
|
|
}
|
|
#endregion
|
|
|
|
///// <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();
|
|
//}
|
|
|
|
//// 删除选中行的脚本
|
|
//private string GetDeleteScript()
|
|
//{
|
|
// return Confirm.GetShowReference("删除选中行?", String.Empty, MessageBoxIcon.Question, Grid1.GetDeleteSelectedRowsReference(), String.Empty);
|
|
//}
|
|
|
|
//protected void Grid1_PreDataBound(object sender, EventArgs e)
|
|
//{
|
|
// // 设置LinkButtonField的点击客户端事件
|
|
// LinkButtonField deleteField = Grid1.FindColumn("Delete") as LinkButtonField;
|
|
// deleteField.OnClientClick = GetDeleteScript();
|
|
//}
|
|
|
|
//protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
|
|
//{
|
|
// RenderField post = Grid1.FindColumn("Post") as RenderField;
|
|
// DropDownList drpPost = new DropDownList();
|
|
// drpPost.DataTextField = "PostName";
|
|
// drpPost.DataValueField = "PostId";
|
|
// drpPost.DataSource = BLL.Base_PostService.GetPostList();
|
|
// drpPost.DataBind();
|
|
// post.Controls.Add(drpPost);
|
|
//}
|
|
}
|
|
} |