提交代码
This commit is contained in:
@@ -9,52 +9,109 @@ namespace FineUIPro.Web.TestRun.DriverGoods
|
||||
{
|
||||
public partial class GoodsBuy : PageBase
|
||||
{
|
||||
#region 加载
|
||||
#region 加载页面
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
GetButtonPower();
|
||||
BindGrid();
|
||||
btnNew.OnClientClick = Window1.GetShowReference("GoodsBuyEdit.aspx") + "return false;";
|
||||
InitTree();//加载类别树
|
||||
}
|
||||
}
|
||||
|
||||
#region 绑定方案类别
|
||||
/// <summary>
|
||||
/// 绑定方案树节点
|
||||
/// </summary>
|
||||
private void InitTree()
|
||||
{
|
||||
this.tvDataTypeInit.Nodes.Clear();
|
||||
TreeNode node = new TreeNode();
|
||||
node.Text = "开车物资材料管理";
|
||||
node.NodeID = "0";
|
||||
node.Expanded = true;
|
||||
this.tvDataTypeInit.Nodes.Add(node);
|
||||
var types = BLL.GoodsBuyService.GetBugType();
|
||||
foreach (var q in types)
|
||||
{
|
||||
TreeNode newNode = new TreeNode();
|
||||
newNode.ToolTip = q.Text;
|
||||
newNode.Text = q.Text;
|
||||
newNode.NodeID = q.Value;
|
||||
newNode.EnableExpandEvent = true;
|
||||
newNode.EnableClickEvent = true;
|
||||
node.Nodes.Add(newNode);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 展开树
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
//protected void trWBS_NodeExpand(object sender, TreeNodeEventArgs e)
|
||||
//{
|
||||
// e.Node.Nodes.Clear();
|
||||
// var types = from x in Funs.DB.DriverPrepare_DriverDataType
|
||||
// where x.ProjectId == this.CurrUser.LoginProjectId && x.ParentId == e.Node.NodeID
|
||||
// select x;
|
||||
// if (types.Count() > 0)
|
||||
// {
|
||||
// foreach (var type in types)
|
||||
// {
|
||||
// TreeNode newNode = new TreeNode();
|
||||
// newNode.ToolTip = type.DriverDataTypeName;
|
||||
// newNode.Text = type.DriverDataTypeName;
|
||||
// newNode.NodeID = type.DriverDataTypeId;
|
||||
// newNode.EnableExpandEvent = true;
|
||||
// newNode.EnableClickEvent = true;
|
||||
// e.Node.Nodes.Add(newNode);
|
||||
// var childTypes = from x in Funs.DB.DriverPrepare_DriverDataType where x.ParentId == type.DriverDataTypeId select x;
|
||||
// if (childTypes.Count() > 0)
|
||||
// {
|
||||
// TreeNode temp = new TreeNode();
|
||||
// temp.Text = "";
|
||||
// temp.NodeID = "";
|
||||
// newNode.Nodes.Add(temp);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region 树点击事件
|
||||
/// <summary>
|
||||
/// 资料库类别树点击事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void tvDataTypeInit_NodeCommand(object sender, TreeCommandEventArgs e)
|
||||
{
|
||||
BindGrid();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 数据绑定
|
||||
//加载列表
|
||||
/// <summary>
|
||||
/// 数据绑定
|
||||
/// </summary>
|
||||
public void BindGrid()
|
||||
{
|
||||
string strSql = @"SELECT buy.GoodsBuyId,
|
||||
buy.ProjectId,
|
||||
buy.Code,
|
||||
buy.BuyName,
|
||||
buy.BuyCode,
|
||||
buy.CompileMan,
|
||||
buy.ApprovalDate,
|
||||
buy.SubmitDate,
|
||||
buy.GetGoodsDate,
|
||||
buy.Remark,
|
||||
U.UserName AS CompileManName"
|
||||
+ @" FROM DriverGoods_GoodsBuy AS buy "
|
||||
+ @" LEFT JOIN Sys_User AS U ON U.UserId = buy.CompileMan WHERE buy.ProjectId=@projectId";
|
||||
string strSql = @"SELECT chec.GoodsBuyId,chec.ProjectId,chec.Code,chec.BuyName,chec.BuyCode,"
|
||||
+ @" chec.CompileMan,chec.ApprovalDate,chec.UnitCode,"
|
||||
+ @" u.userName as CompileManName"
|
||||
+ @" FROM DriverGoods_GoodsBuy chec "
|
||||
+ @" left join sys_User u on u.userId = chec.CompileMan"
|
||||
+ @" where chec.ProjectId=@ProjectId and chec.BuyCode=@BuyCode";
|
||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
listStr.Add(new SqlParameter("@projectId", this.CurrUser.LoginProjectId));
|
||||
if (!string.IsNullOrEmpty(this.txtBuyName.Text.Trim()))
|
||||
{
|
||||
strSql += " AND buy.BuyName LIKE @BuyName";
|
||||
listStr.Add(new SqlParameter("@BuyName", "%" + this.txtBuyName.Text.Trim() + "%"));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.txtBuyCode.Text.Trim()))
|
||||
{
|
||||
strSql += " AND buy.BuyCode LIKE @BuyCode";
|
||||
listStr.Add(new SqlParameter("@BuyCode", "%" + this.txtBuyCode.Text.Trim() + "%"));
|
||||
}
|
||||
listStr.Add(new SqlParameter("@BuyCode", this.tvDataTypeInit.SelectedNodeID));
|
||||
SqlParameter[] parameter = listStr.ToArray();
|
||||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||||
Grid1.RecordCount = tb.Rows.Count;
|
||||
//tb = GetFilteredTable(Grid1.FilteredData, tb);
|
||||
var table = this.GetPagedDataTable(Grid1, tb);
|
||||
tb = GetFilteredTable(Grid1.FilteredData, tb);
|
||||
var table = GetPagedDataTable(Grid1, tb);
|
||||
Grid1.DataSource = table;
|
||||
Grid1.DataBind();
|
||||
}
|
||||
@@ -95,8 +152,12 @@ namespace FineUIPro.Web.TestRun.DriverGoods
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 搜索
|
||||
//搜索按钮事件
|
||||
#region 查询
|
||||
/// <summary>
|
||||
/// 查询
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnSearch_Click(object sender, EventArgs e)
|
||||
{
|
||||
BindGrid();
|
||||
@@ -111,10 +172,38 @@ namespace FineUIPro.Web.TestRun.DriverGoods
|
||||
/// <param name="e"></param>
|
||||
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
||||
{
|
||||
InitTree();
|
||||
BindGrid();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 增加按钮
|
||||
/// <summary>
|
||||
/// 增加
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnNew_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (this.tvDataTypeInit.SelectedNode != null)
|
||||
{
|
||||
//if (this.trWBS.SelectedNode.Nodes.Count == 0) //末级节点
|
||||
if (this.tvDataTypeInit.SelectedNodeID != "0")
|
||||
{
|
||||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("GoodsBuyEdit.aspx?BuyCode={0}", this.tvDataTypeInit.SelectedNode.NodeID, "新增 - ")));
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert.ShowInTop("请选择请购单类别!", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert.ShowInTop("请选择树节点!", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 编辑
|
||||
protected void btnMenuModify_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -141,11 +230,16 @@ namespace FineUIPro.Web.TestRun.DriverGoods
|
||||
Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("GoodsBuyEdit.aspx?id={0}", Grid1.SelectedRowID, "编辑 - ")));
|
||||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("GoodsBuyEdit.aspx?GoodsBuyId={0}", Grid1.SelectedRowID, "编辑 - ")));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 删除
|
||||
/// <summary>
|
||||
/// 右键删除
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnMenuDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Grid1.SelectedRowIndexArray.Length > 0)
|
||||
@@ -153,11 +247,8 @@ namespace FineUIPro.Web.TestRun.DriverGoods
|
||||
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
||||
{
|
||||
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
||||
var info = BLL.GoodsBuyService.GetGoodsBuyById(rowID);
|
||||
if (info != null)
|
||||
{
|
||||
BLL.GoodsBuyService.DeleteGoodsBuy(rowID);
|
||||
}
|
||||
BLL.GoodsBuyItemService.DeleteGoodsBuyItemByGoodsBuyId(rowID);
|
||||
BLL.GoodsBuyService.DeleteGoodsBuy(rowID);
|
||||
}
|
||||
BindGrid();
|
||||
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
|
||||
|
||||
Reference in New Issue
Block a user