150 lines
5.7 KiB
C#
150 lines
5.7 KiB
C#
using BLL;
|
|
using Model;
|
|
using System;
|
|
|
|
namespace FineUIPro.Web.PHTGL.BillOfQuantities
|
|
{
|
|
public partial class MainProjectQuantityEdit : PageBase
|
|
{
|
|
public string BidProjectQuantityId
|
|
{
|
|
get => (string)ViewState["BidProjectQuantityId"];
|
|
set => ViewState["BidProjectQuantityId"] = value;
|
|
}
|
|
|
|
public string MainProjectQuantityId
|
|
{
|
|
get => (string)ViewState["MainProjectQuantityId"];
|
|
set => ViewState["MainProjectQuantityId"] = value;
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
|
|
|
BidProjectQuantityId = Request.Params["BidProjectQuantityId"];
|
|
MainProjectQuantityId = Request.Params["MainProjectQuantityId"];
|
|
if (!string.IsNullOrEmpty(MainProjectQuantityId))
|
|
{
|
|
var model = PHTGL_MainProjectQuantityService
|
|
.GetPHTGL_MainProjectQuantityById(MainProjectQuantityId);
|
|
if (model != null)
|
|
{
|
|
txtMainProjectQuantityCode.Text = model.MainProjectQuantityCode;
|
|
txtMainProjectQuantityName.Text = model.MainProjectQuantityName;
|
|
}
|
|
|
|
// 绑定表格
|
|
BindGrid();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void Save()
|
|
{
|
|
var mainProjectQuantity = new PHTGL_MainProjectQuantity();
|
|
if (string.IsNullOrEmpty(MainProjectQuantityId))
|
|
{
|
|
mainProjectQuantity.MainProjectQuantityCode = txtMainProjectQuantityCode.Text.Trim();
|
|
mainProjectQuantity.MainProjectQuantityName = txtMainProjectQuantityName.Text.Trim();
|
|
mainProjectQuantity.MainProjectQuantityId = SQLHelper.GetNewID();
|
|
mainProjectQuantity.QuantityId = BidProjectQuantityId;
|
|
MainProjectQuantityId = mainProjectQuantity.MainProjectQuantityId;
|
|
PHTGL_MainProjectQuantityService.AddPHTGL_MainProjectQuantity(mainProjectQuantity);
|
|
}
|
|
else
|
|
{
|
|
mainProjectQuantity =
|
|
PHTGL_MainProjectQuantityService.GetPHTGL_MainProjectQuantityById(MainProjectQuantityId);
|
|
mainProjectQuantity.MainProjectQuantityCode = txtMainProjectQuantityCode.Text.Trim();
|
|
mainProjectQuantity.MainProjectQuantityName = txtMainProjectQuantityName.Text.Trim();
|
|
PHTGL_MainProjectQuantityService.UpdatePHTGL_MainProjectQuantity(mainProjectQuantity);
|
|
}
|
|
}
|
|
|
|
private void BindGrid()
|
|
{
|
|
var table = new PHTGL_Quantity();
|
|
table.IsTemplate = false;
|
|
table.ParentId = MainProjectQuantityId;
|
|
var tb = PHTGL_QuantityService.GetPHTGL_QuantityByModle(table);
|
|
Grid1.RecordCount = PHTGL_QuantityService.count;
|
|
//tb = GetFilteredTable(Grid1.FilteredData, tb);
|
|
Grid1.DataSource = tb;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
protected void btnSelect_Click(object sender, EventArgs e)
|
|
{
|
|
Save();
|
|
PageContext.RegisterStartupScript(
|
|
Window1.GetShowReference(string.Format("TemQuantitySelect.aspx?MainProjectQuantityId={0}", MainProjectQuantityId,
|
|
"编辑 - ")));
|
|
}
|
|
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
btnEdit_Click(null, null);
|
|
}
|
|
|
|
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_QuantityService.GetPHTGL_QuantityById(ID);
|
|
if (model != null)
|
|
PageContext.RegisterStartupScript(
|
|
Window1.GetShowReference(string.Format("PHTGL_QuantityEdit.aspx?Id={0}", ID, "编辑 - ")));
|
|
}
|
|
|
|
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_QuantityService.GetPHTGL_QuantityById(rowID);
|
|
if (model != null) PHTGL_QuantityService.DeletePHTGL_QuantityById(rowID);
|
|
}
|
|
|
|
BindGrid();
|
|
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
|
|
}
|
|
}
|
|
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
Save();
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
|
}
|
|
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
protected void btnOut_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(MainProjectQuantityId))
|
|
{
|
|
return;
|
|
}
|
|
PHTGL_BidProjectQuantityService.ExportByMainProjectQuantityId(MainProjectQuantityId);
|
|
}
|
|
|
|
protected void btnImport_Click(object sender, EventArgs e)
|
|
{
|
|
Save();
|
|
PageContext.RegisterStartupScript(
|
|
Window2.GetShowReference(string.Format("TemQuantityIn.aspx?MainProjectQuantityId={0}", MainProjectQuantityId, "导入 - ")));
|
|
}
|
|
}
|
|
} |