protected void btnSave_Click(object sender, EventArgs e) { #region 逻辑检查 string strWhere = string.Format("RoutingNO = '{0}'", txbRoutingNO.Text); BLL.tb_JC_Routing bllRouting = new BLL.tb_JC_Routing(); int count = bllRouting.GetList(strWhere).Tables[0].Rows.Count; if (count > 0) { Alert.ShowInTop("工艺路线编号已存在", "错误", MessageBoxIcon.Error); return; } if (nbxProcedureAmount.Text == "0") { Alert.ShowInTop("工序数量不能为0", "错误", MessageBoxIcon.Error); return; } #endregion #region 保存数据 Model.tb_JC_Routing modelRouting = new Model.tb_JC_Routing(); modelRouting.ID = Guid.NewGuid().ToString(); modelRouting.RoutingNO = txbRoutingNO.Text; modelRouting.RoutingName = txbRoutingName.Text; modelRouting.ProcedureAmount = int.Parse(nbxProcedureAmount.Text); modelRouting.Status = "Y"; bool result = bllRouting.Add(modelRouting); if (!result) { Alert.ShowInTop("添加失败", "错误", MessageBoxIcon.Error, ActiveWindow.GetHidePostBackReference("Main_Add_Fail")); } else { Alert.ShowInTop("添加成功", "信息", MessageBoxIcon.Information, ActiveWindow.GetHidePostBackReference("Main_Add_Success")); } #endregion }
protected void btnSave_Click(object sender, EventArgs e) { #region 逻辑检查 if (nbxProcedureAmount.Text == "0") { Alert.ShowInTop("工序数量不能为0", "错误", MessageBoxIcon.Error); return; } #endregion #region 保存数据 BLL.tb_JC_Routing bllRouting = new BLL.tb_JC_Routing(); Model.tb_JC_Routing modelRouting = new Model.tb_JC_Routing(); modelRouting.ID = Request.QueryString["ID"]; modelRouting.RoutingNO = txbRoutingNO.Text; modelRouting.RoutingName = txbRoutingName.Text; modelRouting.ProcedureAmount = int.Parse(nbxProcedureAmount.Text); modelRouting.Status = "Y"; bool result = bllRouting.Update(modelRouting); if (!result) { Alert.ShowInTop("更新失败", "错误", MessageBoxIcon.Error, ActiveWindow.GetHidePostBackReference("Main_Modify_Fail")); } else { Alert.ShowInTop("更新成功", "信息", MessageBoxIcon.Information, ActiveWindow.GetHidePostBackReference("Main_Modify_Success")); } #endregion }
private void LoadData() { string strWhere = string.Format("ID = '{0}'", Request.QueryString["ID"]); BLL.tb_JC_Routing bllRouting = new BLL.tb_JC_Routing(); DataRow dr = bllRouting.GetList(strWhere).Tables[0].Rows[0]; txbRoutingNO.Text = dr["RoutingNO"].ToString(); txbRoutingName.Text = dr["RoutingName"].ToString(); nbxProcedureAmount.Text = dr["ProcedureAmount"].ToString(); }
//Grid绑定数据源 private void BindGrid() { string strWhere = string.Format("1=1"); string order = string.Format("{0} {1}", gridRouting.SortField, gridRouting.SortDirection); int pageSize = gridRouting.PageSize; int pageIndex = gridRouting.PageIndex; long totalRecord; BLL.tb_JC_Routing bllRouting = new BLL.tb_JC_Routing(); DataTable dtSource = bllRouting.GetListByPage(strWhere, order, pageSize, pageIndex, out totalRecord).Tables[0]; gridRouting.DataSource = dtSource; gridRouting.RecordCount = (int)totalRecord; gridRouting.DataBind(); }
//删除选中记录集 protected void btnDelete_Click(object sender, EventArgs e) { FineUI.Button btn = (FineUI.Button)sender; #region 主表删除事件 if (btn.ID == "btnDelete") { if (gridRoutingSub.RecordCount > 0) { Alert.ShowInTop("在删除该项前,请删除所有子项", "错误", MessageBoxIcon.Error); return; } else { BLL.tb_JC_Routing bllRouting = new BLL.tb_JC_Routing(); string id = gridRouting.DataKeys[gridRouting.SelectedRowIndex][0].ToString(); bool result = bllRouting.Delete(id); if (result) { Alert.ShowInTop("删除成功", "信息", MessageBoxIcon.Information); BindGrid(); } else { Alert.ShowInTop("删除失败", "错误", MessageBoxIcon.Error); } return; } } #endregion #region 除子表记录 if (btn.ID == "btnDeleteSub") { BLL.tb_JC_RoutingSub bllRoutingSub = new BLL.tb_JC_RoutingSub(); string id = gridRoutingSub.DataKeys[gridRoutingSub.SelectedRowIndex][0].ToString(); bool result = bllRoutingSub.Delete(id); if (result) { Alert.ShowInTop("删除成功", "信息", MessageBoxIcon.Information); BindGridSub(gridRouting.DataKeys[gridRouting.SelectedRowIndex][0].ToString()); } else { Alert.ShowInTop("删除失败", "错误", MessageBoxIcon.Error); } return; } #endregion }