2023-08-23
This commit is contained in:
@@ -0,0 +1,192 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using BLL;
|
||||
using Model;
|
||||
|
||||
namespace FineUIPro.Web.PHTGL.BillOfQuantities
|
||||
{
|
||||
public partial class BidProjectQuantityEdit : PageBase
|
||||
{
|
||||
#region
|
||||
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
public string BidProjectQuantityId
|
||||
{
|
||||
get => (string)ViewState["BidProjectQuantityId"];
|
||||
set => ViewState["BidProjectQuantityId"] = value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
||||
////权限按钮方法
|
||||
GetButtonPower();
|
||||
BidProjectQuantityId = Request.Params["BidProjectQuantityId"];
|
||||
if (!string.IsNullOrEmpty(BidProjectQuantityId))
|
||||
{
|
||||
var model = PHTGL_BidProjectQuantityService.GetPHTGL_BidProjectQuantityById(BidProjectQuantityId);
|
||||
if (model != null)
|
||||
{
|
||||
txtLotNumber.Text = model.LotNumber;
|
||||
txtBidProjectCode.Text = model.BidProjectCode;
|
||||
// this.txtIsMainProject.Text = model.IsMainProject;
|
||||
//this.txtMainProjectQuantityId.Text = model.MainProjectQuantityId;
|
||||
}
|
||||
|
||||
// 绑定表格
|
||||
BindGrid();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void BindGrid()
|
||||
{
|
||||
var table = new PHTGL_MainProjectQuantity();
|
||||
table.QuantityId = BidProjectQuantityId;
|
||||
var tb = PHTGL_MainProjectQuantityService.GetPHTGL_MainProjectQuantityByModle(table);
|
||||
Grid1.RecordCount = PHTGL_MainProjectQuantityService.count;
|
||||
//tb = GetFilteredTable(Grid1.FilteredData, tb);
|
||||
Grid1.DataSource = tb;
|
||||
Grid1.DataBind();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
Save();
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
||||
}
|
||||
|
||||
#region 获取按钮权限
|
||||
|
||||
/// <summary>
|
||||
/// 获取按钮权限
|
||||
/// </summary>
|
||||
/// <param name="button"></param>
|
||||
/// <returns></returns>
|
||||
private void GetButtonPower()
|
||||
{
|
||||
var buttonList = CommonService.GetAllButtonList(CurrUser.LoginProjectId, CurrUser.PersonId,
|
||||
Const.PHTGL_BidProjectQuantityMenuId);
|
||||
if (buttonList.Count() > 0)
|
||||
if (buttonList.Contains(Const.BtnSave))
|
||||
btnSave.Hidden = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
private void Save()
|
||||
{
|
||||
var bidProjectQuantity = new PHTGL_BidProjectQuantity();
|
||||
if (string.IsNullOrEmpty(BidProjectQuantityId))
|
||||
{
|
||||
bidProjectQuantity.BidProjectCode = txtBidProjectCode.Text.Trim();
|
||||
bidProjectQuantity.LotNumber = txtLotNumber.Text.Trim();
|
||||
bidProjectQuantity.BidProjectQuantityId = SQLHelper.GetNewID();
|
||||
bidProjectQuantity.ProjectId = CurrUser.LoginProjectId;
|
||||
bidProjectQuantity.CreatorId = CurrUser.PersonId;
|
||||
bidProjectQuantity.CreateDate = DateTime.Now;
|
||||
BidProjectQuantityId = bidProjectQuantity.BidProjectQuantityId;
|
||||
PHTGL_BidProjectQuantityService.AddPHTGL_BidProjectQuantity(bidProjectQuantity);
|
||||
}
|
||||
else
|
||||
{
|
||||
bidProjectQuantity =
|
||||
PHTGL_BidProjectQuantityService.GetPHTGL_BidProjectQuantityById(BidProjectQuantityId);
|
||||
bidProjectQuantity.BidProjectCode = txtBidProjectCode.Text.Trim();
|
||||
bidProjectQuantity.LotNumber = txtLotNumber.Text.Trim();
|
||||
bidProjectQuantity.ProjectId = CurrUser.LoginProjectId;
|
||||
bidProjectQuantity.CreatorId = CurrUser.PersonId;
|
||||
bidProjectQuantity.CreateDate = DateTime.Now;
|
||||
PHTGL_BidProjectQuantityService.UpdatePHTGL_BidProjectQuantity(bidProjectQuantity);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnEdit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||||
{
|
||||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
var ID = Grid1.SelectedRowID;
|
||||
var model = PHTGL_MainProjectQuantityService.GetPHTGL_MainProjectQuantityById(ID);
|
||||
if (model != null)
|
||||
PageContext.RegisterStartupScript(
|
||||
Window1.GetShowReference(string.Format(
|
||||
"MainProjectQuantityEdit.aspx?BidProjectQuantityId={0}&MainProjectQuantityId={1}",
|
||||
BidProjectQuantityId, ID, "编辑 - ")));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Grid行双击事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
||||
{
|
||||
btnEdit_Click(null, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Grid1.SelectedRowIndexArray.Length > 0)
|
||||
{
|
||||
foreach (var rowIndex in Grid1.SelectedRowIndexArray)
|
||||
{
|
||||
var rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
||||
var model = PHTGL_MainProjectQuantityService.GetPHTGL_MainProjectQuantityById(rowID);
|
||||
if (model != null) PHTGL_MainProjectQuantityService.DeleteById(rowID);
|
||||
PHTGL_QuantityService.DeletePHTGL_QuantityByParentId(rowID); //删除主项对于工作量清单
|
||||
}
|
||||
|
||||
BindGrid();
|
||||
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
|
||||
}
|
||||
}
|
||||
|
||||
#region 关闭弹出窗
|
||||
|
||||
/// <summary>
|
||||
/// 关闭弹出窗
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
||||
{
|
||||
BindGrid();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected void btnNew_Click(object sender, EventArgs e)
|
||||
{
|
||||
Save();
|
||||
PageContext.RegisterStartupScript(
|
||||
Window1.GetShowReference(string.Format("MainProjectQuantityEdit.aspx?BidProjectQuantityId={0}",
|
||||
BidProjectQuantityId, "编辑 - ")));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user