标签:
AQL.aspx 后台:
using System;
using System.Globalization;
using System.Linq;
using BFW.BLL.QM;
using BFW.Model.QM;
using MYCOMPANY.BFW.BLL;
namespace QM.SysBaseSet
{
public partial class QmSysBaseSetAql : AdminPage
{
#region Page_Load
protected void Page_Load(object sender, EventArgs e)
{
//this.BFWGridAQL.Grid.RowDataBound += new GridViewRowEventHandler(Grid_RowDataBound);
RecordNavigation1.Click += RecordNavigation1_Click;
if (!IsPostBack)
{
PageInitializtion();
}
}
#endregion
#region 页面初始化
private void PageInitializtion()
{
PanelQuery.Visible = true;
PanelEdit.Visible = false;
ButtonQuery.Text = WebUtility.GetResource("Common_Select");//查询
ButtonDelete.Text = WebUtility.GetResource("Common_Delete");//删除
ButtonUpdate.Text = WebUtility.GetResource("Common_Update");//修改
ButtonNew.Text = WebUtility.GetResource("Common_Insert");//删除
ButtonReset.Text = WebUtility.GetResource("Common_Reset");//重置
ButtonRoleSave.Text = WebUtility.GetResource("Common_Save");//保存
//this.ButtonExport.Text = WebUtility.GetResource("Common_Export");//导出
ButtonBack.Text = WebUtility.GetResource("Common_Back");//返回
//this.ButtonAddType.Text = WebUtility.GetResource("QM_AddDefectType");//添加分类
hideInputTypeName.Value = WebUtility.GetResource("QM_Defect_Name");//请输入缺陷名称
ModalFrameDetail.Caption = WebUtility.GetResource("Role_Detail");//系统角色明细
LoadInspectionTypeList();
BindData();
}
#endregion
#region 装载缺陷分类列表
private void LoadInspectionTypeList()
{
var inspectionTypeBll = new InspectionTypeBll();
using (var dataTable = inspectionTypeBll.GetInspectionTypeList())
{
//装载角色列表,用于编辑
DropdownListEnableQuery.DataSource = dataTable;
DropdownListEnableQuery.ValueField = "ID";
DropdownListEnableQuery.TextField = "Name";
DropdownListEnableQuery.ShowAllItem = true;
DropdownListEnableQuery.DataBind();
//装载角色列表,用于查询
DropdownListEnableEdit.DataSource = dataTable;
DropdownListEnableEdit.ValueField = "ID";
DropdownListEnableEdit.TextField = "Name";
DropdownListEnableEdit.DataBind();
}
}
#endregion
#region 数据绑定
private void BindData()
{
//封装实体类
var aqlModel = new AQLModel
{
Culture = CurrentCulture,
CompanyID = CompanyID,
InspectionTypeID = DropdownListEnableQuery.Value
};
//实例化业务层
var aqlbll = new Aqlbll {ModelObject = aqlModel};
BFWGridAQL.BLLObject = aqlbll;
BFWGridAQL.DataFields = new[] { "RowSN", "InspectionName", "Rate", "Yield" };//给DataView控件 绑定字段
//给 DataView 数据列表 头 汉化
BFWGridAQL.HeaderText = new[] {
WebUtility.GetResource("Common_SN"), //序号
WebUtility.GetResource("QM_Inspection_Type_Name"), //检验分类
WebUtility.GetResource("QM_Inspection_Rate"),//检验比率
WebUtility.GetResource("QM_Inspection_Yield")//最大不良率
};
BFWGridAQL.ColumnWidth = new[] { "10%", "30%", "30%","30%" };//设定每一列的宽度
BFWGridAQL.DataKeys = new[] { "ID" };//设定 GirdView 控件的主键
BFWGridAQL.DataBind();//绑定数据
}
//void Grid_RowDataBound(object sender, GridViewRowEventArgs e)
//{
// if (e.Row.RowType == DataControlRowType.DataRow)
// {
// e.Row.Cells[2].Text = this.ModalFrameDetail.ShowDCaption("<font color=‘BLUE‘><u>" + Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Type_Name")) + "</font></u>",
// WebUtility.WebRootDirectory() + "/QM/DefectType/DefectType.aspx?OpenType=Query&Type_Name=" + DataBinder.Eval(e.Row.DataItem, "Type_Name"),
// WebUtility.GetResource("PMP_Parter_Contactor") + " [" + Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Type_Name")) + "]");
// }
//}
#endregion
#region 查询
protected void ButtonQuery_Click(object sender, EventArgs e)
{
BFWGridAQL.CurrentPage = "1";
BindData();
}
#endregion
#region 编辑返回
protected void ButtonBack_Click(object sender, EventArgs e)
{
LoadInspectionTypeList();
PanelQuery.Visible = true;
PanelEdit.Visible = false;
BindData();
}
#endregion
#region 重置
private void Reset()
{
TextBoxRateEdit.Text = string.Empty;
DropdownListEnableEdit.SelectedIndex = 0;
hideID.Value = string.Empty;
LoadInspectionTypeList();
TextBoxRateEdit.Focus();
}
#endregion
#region 新增
protected void ButtonNew_Click(object sender, EventArgs e)
{
PanelQuery.Visible = false;
PanelEdit.Visible = true;
RecordNavigation1.Dispose();
LoadInspectionTypeList();
LabelOperState.Text = WebUtility.GetResource("Common_Insert");//新增
hideOperState.Value = "Insert";
Reset();
}
#endregion
#region 修改前初始化
private void UpdateInitialize(string id)
{
var aqlModel = new AQLModel { ID = id };
var aqlbll = new Aqlbll {ModelObject = aqlModel};
aqlModel = aqlbll.GetAqlbyId();
TextBoxRateEdit.Text = aqlModel.Rate.ToString(CultureInfo.InvariantCulture);
LoadInspectionTypeList();
DropdownListEnableEdit.Value = aqlModel.InspectionTypeID;
}
#endregion
#region 修改
protected void ButtonUpdate_Click(object sender, EventArgs e)
{
RecordNavigation1.DataSource = BFWGridAQL.SelectedValues;
hideID.Value = RecordNavigation1.CurrentRecordID;
UpdateInitialize(RecordNavigation1.CurrentRecordID);
PanelQuery.Visible = false;
PanelEdit.Visible = true;
LabelOperState.Text = WebUtility.GetResource("Common_Update");//修改
hideOperState.Value = "Update";
}
#endregion
#region RecordNavigation1_Click
void RecordNavigation1_Click(object sender, EventArgs e)
{
hideID.Value = RecordNavigation1.CurrentRecordID;
UpdateInitialize(RecordNavigation1.CurrentRecordID);
}
#endregion
#region 删除
protected void ButtonDelete_Click(object sender, EventArgs e)
{
int i = BFWGridAQL.SelectedValues.Select(id => new AQLModel {ID = id}).Select(aqlModel => new Aqlbll {ModelObject = aqlModel}).Count(aqlbll => aqlbll.Execute(OperationType.Delete) > 0);
if (i > 0)
{
BindData();
string message = WebUtility.GetResource("Common_OperSuccess") + "<br/>"
+ WebUtility.GetResource("Common_DeletedRecordNum") + i;//操作成功...已成功删除的记录笔数:
AlertQuery.Alert(message);
}
else
{
BindData();
string message = WebUtility.GetResource("Common_OpeError") + "<br/>"
+ WebUtility.GetResource("Common_DeletedRecordNum") + i;//操作失敗...已成功操作的记录笔数:
AlertQuery.Alert(message);
}
}
#endregion
#region 缺陷名称保存(修改)
protected void ButtonRoleSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(TextBoxRateEdit.Text.Trim()))
{
MessageBox(WebUtility.GetResource("QM_InputRate"));//请输入检验比率
return;
}
if (string.IsNullOrEmpty(TextBoxYieldEdit.Text.Trim()))
{
MessageBox(WebUtility.GetResource("QM_InputYield"));//请输入最大不良率
return;
}
var aqlModel = new AQLModel
{
Rate = decimal.Parse(WebUtility.CutString(TextBoxRateEdit.Text.Trim(), 8, false)),
InspectionTypeID = DropdownListEnableEdit.Value,
Yield =decimal.Parse(TextBoxYieldEdit.Text.Trim()),
CompanyID = CompanyID
};
var aqlbll = new Aqlbll {ModelObject = aqlModel};
//插入操作
if (hideOperState.Value.Equals("Insert"))
{
hideID.Value = Guid.NewGuid().ToString();
aqlModel.ID = hideID.Value;
aqlModel.Creator = UserID;
aqlModel.CreateDate = DateTime.Now;
//bool b = AQLBLL.DataDoubleCheck(AQLModel.ID, AQLModel.AQL);
//if (b == true)
//{
// MessageBox(WebUtility.GetResource("ePO_Common_DataDouble"));//数据已存在,不允许重复
// return;
//}
if (aqlbll.Execute(OperationType.Insert) > 0)
{
BindData();
MessageBox(WebUtility.GetResource("Common_OperSuccess"));//操作成功
PanelQuery.Visible = true;
PanelEdit.Visible = false;
BFWGridAQL.Visible = true;
}
}
else
{
//1,先将 要修改的数据 封装到实体中
aqlModel.ID = hideID.Value;
aqlModel.Modifier = UserID;
aqlModel.ModifyDate = DateTime.Now;
//bool b = AQLBLL.DataDoubleCheck(AQLModel.ID, AQLModel.AQL);
//if (b == true)
//{
// MessageBox(WebUtility.GetResource("ePO_Common_DataDouble"));//数据已存在,不允许重复
// return;
//}
//2,调用 业务层的 更新方法
if (aqlbll.Execute(OperationType.Update) > 0)
{
BindData();
MessageBox(WebUtility.GetResource("Common_OperSuccess"));//操作成功
}
}
}
protected void ButtonReset_Click(object sender, EventArgs e)
{
TextBoxRateEdit.Text = string.Empty;
TextBoxYieldEdit.Text = string.Empty;
DropdownListEnableQuery.SelectedIndex = 0;
BindData();
}
#endregion
}
}
AQL.aspx 前台:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AQL.aspx.cs" Inherits="QM.SysBaseSet.QmSysBaseSetAql" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<ajaxToolkit:ToolkitScriptManager runat="Server" EnablePartialRendering="true" ID="ScriptManager1" />
<!--查询Panel-->
<asp:Panel runat="server" ID="PanelQuery">
<table style="width: 100%; height: 22px; border: 0px;" cellpadding=‘0‘ cellspacing=‘0‘>
<tr>
<td class="tableHeaderLeftBG">
</td>
<td class="tableHeaderBG">
<%=WebUtility.GetResource("Common_QueryCondition")%><%--查询条件--%></td>
<td class="tableHeaderRightBG">
</td>
</tr>
</table>
<table style="width: 100%; border: 0px;" cellpadding=‘0‘ cellspacing=‘1‘ class="table">
<tr style="text-align: left; height: 25px;" class="tableText">
<td style="width: 10%;">
<%=WebUtility.GetResource("QM_Inspection_Type_Name")%><%--检验分类--%></td>
<td style="width: 40%;">
<BFW:DropdownList ID="DropdownListEnableQuery" runat="server" EnableEdit="false"
PopupHeight="80px" />
</td>
</tr>
</table>
<table cellpadding=‘0‘ cellspacing=‘0‘>
<tr style="height: 25px; vertical-align: bottom;">
<td>
<asp:Button ID="ButtonQuery" runat="server" OnClick="ButtonQuery_Click" />
</td>
<td>
<asp:Button ID="ButtonReset" runat="server" OnClick="ButtonReset_Click" />
</td>
<td>
<asp:Button ID="ButtonNew" runat="server" CommandName="insert" OnClick="ButtonNew_Click" />
</td>
<td>
<asp:Button ID="ButtonUpdate" runat="server" CommandName="update" OnClick="ButtonUpdate_Click"
OnClientClick="return Select();" />
</td>
<td>
<asp:Button ID="ButtonDelete" runat="server" CommandName="delete" OnClick="ButtonDelete_Click"
OnClientClick="return Delete(this);" />
</td>
</tr>
</table>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<BFW:GridView ID="BFWGridAQL" runat="server" ShowCheckBoxColumn="True" EnableSelectRow="false" />
<BFW:Alert ID="AlertQuery" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ButtonQuery" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="ButtonDelete" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</asp:Panel>
<!--角色新增或修改Panel-->
<asp:Panel runat="server" ID="PanelEdit">
<table style="width: 100%; height: 22px; border: 0px;" cellpadding=‘0‘ cellspacing=‘0‘>
<tr>
<td class="tableHeaderLeftBG">
</td>
<td class="tableHeaderBG">
<asp:Label ID="LabelOperState" runat="server" SkinID="SkinTitle"></asp:Label>
</td>
<td class="tableHeaderRightBG">
</td>
</tr>
</table>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table style="width: 100%; border: 0px;" cellpadding=‘0‘ cellspacing=‘1‘ class="table">
<tr style="text-align: left; height: 25px;" class="tableText">
<td style="width: 12%;">
<%=WebUtility.GetResource("QM_Inspection_Type_Name")%><%--检验分类--%></td>
<td style="width: 38%;">
<BFW:DropdownList ID="DropdownListEnableEdit" runat="server" EnableEdit="false"
PopupHeight="80px" />
</td>
<td style="width: 12%;">
<%=WebUtility.GetResource("QM_Inspection_Rate")%><%--检验比率--%> <font class="Star">*</font>
</td>
<td style="width: 38%;">
<asp:TextBox ID="TextBoxRateEdit" runat="server"></asp:TextBox>
</td>
</tr>
<tr style="text-align: left; height: 25px;" class="tableText">
<td style="width: 12%;">
<%=WebUtility.GetResource("QM_Inspection_Yield")%><%--最大不良率--%> <font class="Star">*</font>
</td>
<td style="width: 38%;">
<asp:TextBox ID="TextBoxYieldEdit" runat="server"></asp:TextBox>
</td>
</table>
<asp:HiddenField ID="hideID" runat="server" />
<BFW:RecordNavigation ID="RecordNavigation1" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
<table cellpadding=‘0‘ cellspacing=‘0‘>
<tr style="height: 25px; vertical-align: bottom;">
<td>
<asp:Button ID="ButtonRoleSave" runat="server" OnClick="ButtonRoleSave_Click" UseSubmitBehavior="false"
OnClientClick="Submit(this);" />
</td>
<td>
<asp:Button ID="ButtonBack" runat="server" OnClick="ButtonBack_Click" />
</td>
</tr>
</table>
</asp:Panel>
<BFW:UpdateProgress ID="UpdateProgress1" runat="server" />
<BFW:Confirm ID="Confirm1" runat="server" />
<BFW:ModalFrame ID="ModalFrameDetail" Width="620px" Height="520px" runat="server" />
<asp:HiddenField ID="hideUpdateIndex" runat="server" />
<asp:HiddenField ID="hideOperState" runat="server" />
<asp:HiddenField ID="hideInputTypeName" runat="server" />
</form>
</body>
</html>
标签:
原文地址:http://www.cnblogs.com/dlf-myDream/p/4611216.html