How to change the order of pushbutton in RadGrid?

6 posts, 0 answers
  1. 啟仲
    啟仲 avatar
    8 posts
    Member since:
    Mar 2014

    Posted 05 May 2014 Link to this post

    Dear Sir:

    As the subject.
    Example as how to change the Query and Delete?

    Kind Regards
  2. Eyup
    Admin
    Eyup avatar
    3014 posts

    Posted 08 May 2014 Link to this post

    Hi 啟仲,

    I'm afraid it is difficult to figure out your exact requirement. Generally, you can control the display sequence of the columns in the mark-up:
    <Columns>
        <telerik:GridEditCommandColumn UniqueName="EditCommandColumn"></telerik:GridEditCommandColumn>
        <telerik:GridButtonColumn UniqueName="ButtonColumnName" CommandName="Delete" Text="Delete"></telerik:GridButtonColumn>
        <telerik:GridTemplateColumn UniqueName="TemplateColumnName">
            <ItemTemplate>
                <telerik:RadButton ID="RadButton1" runat="server" Text="RadButton" CommandName="Edit"></telerik:RadButton>
            </ItemTemplate>
        </telerik:GridTemplateColumn>
    </Columns>

    Hope this helps. In case you have different requirements or further instructions, please elaborate on your specific scenario and send us sample screenshots or video demonstrating the desired behavior.

    Regards,
    Eyup
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. 啟仲
    啟仲 avatar
    8 posts
    Member since:
    Mar 2014

    Posted 14 May 2014 in reply to Eyup Link to this post

    Hello ,Eyup:
          Thanks your kind passion,attach is aspx file and aspx.cs file.
    I want to question how to change the order of  pushbutton(ex. '刪除' and '查詢')?
    Because after I changed it ,it incorrectly works  that '刪除' to delete record directly  and '查詢' shows delete pop window.
    Please clean my ear to hear your advice,Thanks!

    Best Regards
     
  5. 啟仲
    啟仲 avatar
    8 posts
    Member since:
    Mar 2014

    Posted 14 May 2014 in reply to 啟仲 Link to this post

    MSARPT.aspx

    <%@ Page Title="" Language="C#" MasterPageFile="~/Body.Master" AutoEventWireup="True"
        CodeBehind="MSARPT.aspx.cs" Inherits="QMS.MSA.BasicInputMaintain.MSARPT" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
        <style type="text/css">
           
        .style1
        {
            width: 526px;
        }
        .style3
        {
            width: 134px;
        }
        .style4
        {
            width: 526px;
            height: 25px;
        }
        .style5
        {
            height: 25px;
        }
           
        </style>
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
         <script type="text/javascript">
             function requestStart(sender, args) {
                 if (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0) {
                     args.set_enableAjax(false);
                 }
             }
        </script>
        <div>
            <asp:Panel ID="RadPane1" runat="server">
                <fieldset style="width: 790px">
                    <legend>查詢條件</legend>
                    <table width="100%">
                        <tr>
                            <td class="style3" rowspan="6">
                                <asp:RadioButtonList ID="RadioButtonList1" runat="server" Height="148px"
                                    Width="122px">
                                    <asp:ListItem Value="0">儀器編號</asp:ListItem>
                                    <asp:ListItem Value="1">型號</asp:ListItem>
                                    <asp:ListItem Value="2">輸入時間</asp:ListItem>
                                    <asp:ListItem Value="3">檢定檢日期</asp:ListItem>
                                    <asp:ListItem Value="4">檢定有效日期</asp:ListItem>
                                    <asp:ListItem Value="5">使用單位</asp:ListItem>
                                </asp:RadioButtonList>
                            </td>
                            <td class="style4">
                                <asp:TextBox ID="tbInstrumentNo" runat="server"></asp:TextBox>
                            </td>
                            <td class="style5">
                                <telerik:RadButton ID="btnQuery" runat="server" Text="查詢"
                                    onclick="btnQuery_Click">
                                </telerik:RadButton>
                                <telerik:RadButton ID="btnClear" runat="server" Text="清除"
                                    onclick="btnClear_Click">
                                </telerik:RadButton>
                            </td>
                        </tr>
                        <tr>
                            <td class="style1">
                                <asp:TextBox ID="tbInstrumentModel" runat="server"></asp:TextBox>
                            </td>
                            <td>
                                &nbsp;</td>
                        </tr>
                        <tr>
                            <td class="style1">
                                &nbsp;<telerik:RadDateTimePicker ID="dtpSysFromDate" Runat="server" Skin="Vista">
                                        <TimeView Runat="server" CellSpacing="-1" Culture="zh-TW" TimeFormat="HH:mm:ss"></TimeView>
                                        <TimePopupButton ImageUrl="" HoverImageUrl=""></TimePopupButton>
                                        <Calendar Runat="server" UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" ViewSelectorText="x"
                                        Skin="Vista"></Calendar>
                                        <DateInput Runat="server" DisplayDateFormat="yyyy/MM/dd HH:mm:ss" DateFormat="yyyy/MM/dd HH:mm:ss"></DateInput>
                                        <DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>
                                </telerik:RadDateTimePicker>
                                 <asp:Label ID="Label1" runat="server" Text="~"></asp:Label>
                                 <telerik:RadDateTimePicker ID="dtpSysToDate" Runat="server" Skin="Vista">
                                        <TimeView  Runat="server" CellSpacing="-1" Culture="zh-TW" TimeFormat="HH:mm:ss"></TimeView>
                                        <TimePopupButton ImageUrl="" HoverImageUrl=""></TimePopupButton>
                                        <Calendar  Runat="server" UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" ViewSelectorText="x"
                                        Skin="Vista"></Calendar>
                                        <DateInput Runat="server" DisplayDateFormat="yyyy/MM/dd HH:mm:ss" DateFormat="yyyy/MM/dd HH:mm:ss"></DateInput>
                                        <DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>
                                </telerik:RadDateTimePicker>
                            </td>
                            <td>
                                &nbsp;</td>
                        </tr>
                        <tr>
                            <td class="style1">
                                <telerik:RadDatePicker ID="dpCheckDateF" Runat="server" Skin="Vista">
                                    <Calendar Runat="server" Skin="Vista" UseColumnHeadersAsSelectors="False"
                                        UseRowHeadersAsSelectors="False" ViewSelectorText="x">
                                    </Calendar>
                                    <DateInput Runat="server" DateFormat="yyyy/MM/dd" DisplayDateFormat="yyyy/MM/dd">
                                    </DateInput>
                                    <DatePopupButton HoverImageUrl="" ImageUrl="" />
                                </telerik:RadDatePicker>
                                <asp:Label ID="Label4" runat="server" Text="~"></asp:Label>
                                <telerik:RadDatePicker ID="dpCheckDateT" Runat="server" Skin="Vista">
                                    <Calendar Runat="server" UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" ViewSelectorText="x"
                                        Skin="Vista"></Calendar>
                                    <DateInput Runat="server" DisplayDateFormat="yyyy/MM/dd" DateFormat="yyyy/MM/dd">
                                    </DateInput>
                                    <DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>
                                </telerik:RadDatePicker>
                            </td>
                            <td>
                                &nbsp;</td>
                        </tr>
                        <tr>
                            <td class="style1">
                                <telerik:RadDatePicker ID="dpNextCalDateF" Runat="server" Skin="Vista">
                                     <Calendar Runat="server" UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" ViewSelectorText="x"
                                        Skin="Vista"></Calendar>
                                     <DateInput Runat="server" DisplayDateFormat="yyyy/MM/dd" DateFormat="yyyy/MM/dd"></DateInput>
                                     <DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>
                                </telerik:RadDatePicker>
                                <asp:Label ID="Label5" runat="server" Text="~"></asp:Label>
                                <telerik:RadDatePicker ID="dpNextCalDateT" Runat="server" Skin="Vista">
                                     <Calendar Runat="server" UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" ViewSelectorText="x"
                                        Skin="Vista"></Calendar>
                                     <DateInput Runat="server" DisplayDateFormat="yyyy/MM/dd" DateFormat="yyyy/MM/dd"></DateInput>
                                     <DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>
                                </telerik:RadDatePicker>
                            </td>
                            <td>
                                &nbsp;</td>
                        </tr>
                        <tr>
                            <td class="style1">
                              
                                <telerik:RadComboBox ID="cbDepartment" Runat="server" 
                                AppendDataBoundItems="True" DataSourceID="odsDepartment"
                                DataTextField="Department" DataValueField="Department"
                                Height="250px" MarkFirstMatch="True" AllowCustomText="True"
                                EmptyMessage="請選擇" >
                                    <Items>
                                        <telerik:RadComboBoxItem runat="server" />
                                    </Items>
                                </telerik:RadComboBox>
                                <asp:ObjectDataSource ID="odsDepartment" runat="server"
                                OldValuesParameterFormatString="original_{0}" SelectMethod="GetDepartment"
                                TypeName="QMSDAL.Dao.MSA.BasicInputMaintain.daoQMS_MSARPT_TABLE"></asp:ObjectDataSource>
                            </td>
                            <td>
                                &nbsp;</td>
                        </tr>
                    </table>
                </fieldset>
                
            </asp:Panel>
          
          
          <asp:Label ID="lblMsg" runat="server" ForeColor="Red"></asp:Label>
            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel2" runat="server">
            </telerik:RadAjaxLoadingPanel>
            <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1"
            ClientEvents-OnRequestStart="requestStart">
            <telerik:RadGrid ID="gvMSAReport" runat="server" AutoGenerateColumns="False"
                CellSpacing="0" Width="2500px" Height="490px"
                GridLines="None" Culture="zh-TW"
                ShowStatusBar="True" AllowPaging="True" AllowSorting="True"
                DataSourceID="objdsMSAReport"
                ondeletecommand="gvMSAReport_DeleteCommand"
                onitemdatabound="gvMSAReport_ItemDataBound"
                onitemcommand="gvMSAReport_ItemCommand"
                oninsertcommand="gvMSAReport_InsertCommand"
                onprerender="gvMSAReport_PreRender"
                onupdatecommand="gvMSAReport_UpdateCommand">
                <ExportSettings Excel-Format="ExcelML" IgnorePaging="True" ExportOnlyData="True">
                    <Excel Format="ExcelML"></Excel>
                </ExportSettings>
                <ClientSettings>
                    <Scrolling AllowScroll="True" UseStaticHeaders="True" />
                </ClientSettings>
                <MasterTableView CommandItemDisplay="Top" AutoGenerateColumns="False"
                    InsertItemPageIndexAction="ShowItemOnCurrentPage"
                    DataSourceID="objdsMSAReport">
                    <CommandItemSettings ExportToPdfText="Export to PDF" AddNewRecordText="新增" ShowRefreshButton="False" ShowExportToExcelButton="True">
                    </CommandItemSettings>
                    <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </RowIndicatorColumn>
                    <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </ExpandCollapseColumn>
                    <Columns>
                        <telerik:GridEditCommandColumn EditText="修改" FilterControlAltText="Filter EditCommandColumn column"
                            ButtonType="PushButton">
                            <FooterStyle Width="60px" />
                            <HeaderStyle Width="60px" />
                            <ItemStyle Width="60px"></ItemStyle>
                        </telerik:GridEditCommandColumn>
                        <telerik:GridButtonColumn ButtonType="PushButton" CommandName="Delete" FilterControlAltText="Filter DeleteColumn column"
                            Text="刪除" UniqueName="DeleteColumn">
                            <FooterStyle Width="60px" />
                            <HeaderStyle Width="60px" />
                            <ItemStyle Width="60px" />
                        </telerik:GridButtonColumn>
                        <telerik:GridButtonColumn ButtonType="PushButton" CommandName="Edit" FilterControlAltText="Filter QueryColumn column"
                            Text="查詢" UniqueName="QueryColumn">
                            <FooterStyle Width="60px" />
                            <HeaderStyle Width="60px" />
                            <ItemStyle Width="60px" />
                        </telerik:GridButtonColumn>
                        <telerik:GridBoundColumn DataField="Instrument_No"
                            SortExpression="Instrument_No" FilterControlAltText="Filter Instrument_No column"
                            UniqueName="Instrument_No" HeaderText="Instrument_No">
                            <FooterStyle Width="60px"></FooterStyle>
                            <HeaderStyle Width="120px"></HeaderStyle>
                            <ItemStyle Width="60px"></ItemStyle>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Instrument" SortExpression="Instrument" FilterControlAltText="Filter Instrument column"
                            UniqueName="Instrument" HeaderText="Instrument">
                            <FooterStyle Width="60px"></FooterStyle>
                            <HeaderStyle Width="80px"></HeaderStyle>
                            <ItemStyle Width="60px"></ItemStyle>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Department" SortExpression="Department" FilterControlAltText="Filter Department column"
                            UniqueName="Department" HeaderText="Department">
                            <FooterStyle Width="60px"></FooterStyle>
                            <HeaderStyle Width="85px"></HeaderStyle>
                            <ItemStyle Width="60px"></ItemStyle>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Cal_Cyle"
                            FilterControlAltText="Filter Cal_Cyle column" HeaderText="Cal_Cyle"
                            SortExpression="Cal_Cyle" UniqueName="Cal_Cyle">
                            <FooterStyle Width="60px"></FooterStyle>
                            <HeaderStyle Width="60px"></HeaderStyle>
                            <ItemStyle Width="60px"></ItemStyle>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Location"
                            FilterControlAltText="Filter Location column" HeaderText="Location"
                            SortExpression="Location" UniqueName="Location">
                            <FooterStyle Width="60px"></FooterStyle>
                            <HeaderStyle Width="80px"></HeaderStyle>
                            <ItemStyle Width="60px"></ItemStyle>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Getory_Name"
                            FilterControlAltText="Filter Getory_Name column" HeaderText="Getory_Name"
                            SortExpression="Getory_Name" UniqueName="Getory_Name">
                            <FooterStyle Width="60px"></FooterStyle>
                            <HeaderStyle Width="200px"></HeaderStyle>
                            <ItemStyle Width="60px"></ItemStyle>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Agent_Maker_Name"
                            FilterControlAltText="Filter Agent_Maker_Name column"
                            HeaderText="Agent_Maker_Name" SortExpression="Agent_Maker_Name"
                            UniqueName="Agent_Maker_Name">
                            <FooterStyle Width="60px"></FooterStyle>
                            <HeaderStyle Width="150px"></HeaderStyle>
                            <ItemStyle Width="60px"></ItemStyle>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Instrument_Model"
                            FilterControlAltText="Filter Instrument_Model column"
                            HeaderText="Instrument_Model" SortExpression="Instrument_Model"
                            UniqueName="Instrument_Model">
                            <FooterStyle Width="60px"></FooterStyle>
                            <HeaderStyle Width="150px"></HeaderStyle>
                            <ItemStyle Width="60px"></ItemStyle>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Instrument_Serial_No"
                            FilterControlAltText="Filter Instrument_Serial_No column"
                            HeaderText="Instrument_Serial_No" SortExpression="Instrument_Serial_No"
                            UniqueName="Instrument_Serial_No">
                            <FooterStyle Width="60px"></FooterStyle>
                            <HeaderStyle Width="150px"></HeaderStyle>
                            <ItemStyle Width="60px"></ItemStyle>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Instrument_Step"
                            FilterControlAltText="Filter Instrument_Step column"
                            HeaderText="Instrument_Step" SortExpression="Instrument_Step"
                            UniqueName="Instrument_Step">
                            <FooterStyle Width="60px"></FooterStyle>
                            <HeaderStyle Width="120px"></HeaderStyle>
                            <ItemStyle Width="60px"></ItemStyle>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Check_Date" DataFormatString="{0:yyyy/MM/dd HH:mm:ss}"
                            FilterControlAltText="Filter Check_Date column" HeaderText="Check_Date"
                            SortExpression="Check_Date" UniqueName="Check_Date">
                            <FooterStyle Width="60px"></FooterStyle>
                            <HeaderStyle Width="160px"></HeaderStyle>
                            <ItemStyle Width="60px"></ItemStyle>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Next_CAL_Date" DataFormatString="{0:yyyy/MM/dd HH:mm:ss}"
                            FilterControlAltText="Filter Next_CAL_Date column" HeaderText="Next_CAL_Date"
                            SortExpression="Next_CAL_Date" UniqueName="Next_CAL_Date">
                            <FooterStyle Width="60px"></FooterStyle>
                            <HeaderStyle Width="160px"></HeaderStyle>
                            <ItemStyle Width="60px"></ItemStyle>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Bias"
                            FilterControlAltText="Filter Bias column" HeaderText="Bias"
                            SortExpression="Bias" UniqueName="Bias">
                            <FooterStyle Width="60px"></FooterStyle>
                            <HeaderStyle Width="50px"></HeaderStyle>
                            <ItemStyle Width="60px"></ItemStyle>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Linearity"
                            FilterControlAltText="Filter Linearity column" HeaderText="Linearity"
                            SortExpression="Linearity" UniqueName="Linearity">
                            <FooterStyle Width="60px"></FooterStyle>
                            <HeaderStyle Width="80px"></HeaderStyle>
                            <ItemStyle Width="60px"></ItemStyle>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Grr"
                            FilterControlAltText="Filter Grr column" HeaderText="GRR"
                            SortExpression="Grr" UniqueName="Grr">
                            <FooterStyle Width="60px"></FooterStyle>
                            <HeaderStyle Width="80px"></HeaderStyle>
                            <ItemStyle Width="60px"></ItemStyle>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="MaskText"
                            FilterControlAltText="Filter MaskText column" HeaderText="MaskText"
                            SortExpression="MaskText" UniqueName="MaskText">
                            <FooterStyle Width="60px"></FooterStyle>
                            <HeaderStyle Width="200px"></HeaderStyle>
                            <ItemStyle Width="60px"></ItemStyle>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="SYS_DATE" DataFormatString="{0:yyyy/MM/dd}"
                            FilterControlAltText="Filter SYS_DATE column" HeaderText="SYS_DATE"
                            SortExpression="SYS_DATE" UniqueName="SYS_DATE">
                            <FooterStyle Width="60px"></FooterStyle>
                            <HeaderStyle Width="80px"></HeaderStyle>
                            <ItemStyle Width="60px"></ItemStyle>
                        </telerik:GridBoundColumn>
                    </Columns>
                <EditFormSettings EditFormType="WebUserControl" UserControlName="ucMSARPT.ascx">
                <EditColumn UniqueName="EditCommandColumn1" FilterControlAltText="Filter EditCommandColumn1 column"></EditColumn>
                </EditFormSettings>
                </MasterTableView>
                <FilterMenu EnableImageSprites="False">
                </FilterMenu>
                <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
                </HeaderContextMenu>
            </telerik:RadGrid>
             </telerik:RadAjaxPanel>
            
            <asp:ObjectDataSource ID="objdsMSAReport" runat="server"
                OldValuesParameterFormatString="original_{0}" SelectMethod="getQmsMsaReport"
                TypeName="QMSDAL.Dao.MSA.BasicInputMaintain.daoQMS_MSARPT_TABLE"
                DeleteMethod="Delete">
                <DeleteParameters>
                    <asp:Parameter Name="entity" Type="Object" />
                    <asp:Parameter Name="p_trans" Type="Object" />
                </DeleteParameters>
                <SelectParameters>
                    <asp:ControlParameter ControlID="RadioButtonList1" Name="p_QueryTarget"
                        PropertyName="SelectedValue" Type="String" />
                    <asp:ControlParameter ControlID="tbInstrumentNo" Name="p_InstrumentNo"
                        PropertyName="Text" Type="String" />
                    <asp:ControlParameter ControlID="tbInstrumentModel" Name="p_InstrumentModel"
                        PropertyName="Text" Type="String" />
                    <asp:ControlParameter ControlID="cbDepartment" Name="p_Department"
                        PropertyName="Text" Type="String" />
                    <asp:ControlParameter ControlID="dtpSysFromDate" Name="p_SysFromDate"
                        PropertyName="SelectedDate" Type="DateTime" />
                    <asp:ControlParameter ControlID="dtpSysToDate" Name="p_SysToDate"
                        PropertyName="SelectedDate" Type="DateTime" />
                    <asp:ControlParameter ControlID="dpCheckDateF" Name="p_CheckDateF"
                        PropertyName="SelectedDate" Type="DateTime" />
                    <asp:ControlParameter ControlID="dpCheckDateT" Name="p_CheckDateT"
                        PropertyName="SelectedDate" Type="DateTime" />
                    <asp:ControlParameter ControlID="dpNextCalDateF" Name="p_NextCalDateF"
                        PropertyName="SelectedDate" Type="DateTime" />
                    <asp:ControlParameter ControlID="dpNextCalDateT" Name="p_NextCalDateT"
                        PropertyName="SelectedDate" Type="DateTime" />
                </SelectParameters>
            </asp:ObjectDataSource>
        </div>
       
    </asp:Content>
  6. 啟仲
    啟仲 avatar
    8 posts
    Member since:
    Mar 2014

    Posted 14 May 2014 in reply to 啟仲 Link to this post

    MSARPT.aspx.cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using QMSBO.Common;
    using QMSDAL.Dto.MSA;
    using QMSDAL.Dao.MSA.BasicInputMaintain;
    using QMSDAL.DBUtility;
    using QMSBO.Core;
    using Telerik.Web.UI;
    using System.Data;
    using QMSDAL.Dto.Human;
    using QMSDAL.Dao.MSA.BasicDataMaintain;
    namespace QMS.MSA.BasicInputMaintain
    {
        public partial class MSARPT : BasePage
        {
            #region  properties
            LiteralControl lcResult;
            LiteralControl lcAlterMsg;
            Boolean haveDelete, haveQuery, haveInsertAndUpdate, haveInsert, haveUdate;
            private string deleteMessage;
            private string insertUpdateMessage;
            private string insertMessage;
            private string updateMessage;
            private const string sQMS_MSARPT_TABLE = "wectqms.dbo.QMS_MSARPT_TABLE";
            DataTable dt = new DataTable();
            DateTime lv_Max_NextCalDate;
            DataRow dr;
            QMS_MSARPT_TABLE od_QMS_MSARPT_TABLE = new QMS_MSARPT_TABLE();
            QMS_MSARPT1_TABLE od_QMS_MSARPT1_TABLE = new QMS_MSARPT1_TABLE();
            QMS_MSARPT2_TABLE od_QMS_MSARPT2_TABLE = new QMS_MSARPT2_TABLE();
            QMS_MSAHISTO_TABLE od_QMS_MSAHISTO_TABLE = new QMS_MSAHISTO_TABLE();
            vwemployeeinfo od_vwemployeeinfo = new vwemployeeinfo();
            daoQMS_MSARPT_TABLE daoQMS_MSARPT = new daoQMS_MSARPT_TABLE();
            daoQMS_MSARPT1_TABLE daoQMS_MSARPT1 = new daoQMS_MSARPT1_TABLE();
            daoQMS_MSARPT2_TABLE daoQMS_MSARPT2 = new daoQMS_MSARPT2_TABLE();
            QMSDAL.Dao.MSA.BasicInputMaintain.daoQMS_MSAHISTO_TABLE daoQMS_MSAHISTO_TABLE = new QMSDAL.Dao.MSA.BasicInputMaintain.daoQMS_MSAHISTO_TABLE();
            #endregion
            #region Page Events
            protected void Page_Load(object sender, EventArgs e)
            {
                //lblMsg.Text = null;
               
                string programUrl = GetPageUrl(Request.Path);
                var s = GetPrivilegeOfCAL_MSA(SessionManager.User.EmployeeID, programUrl);
                if (s.ADD_FUN == "T") { haveInsert = true; } else { haveInsert = false; }
                if (s.DEL_FUN == "T") { haveDelete = true; } else { haveDelete = false; }
                if (s.QUY_FUN == "T") { haveQuery = true; } else { haveQuery = false; }
                if (s.MDY_FUN == "T") { haveUdate = true; } else { haveUdate = false; }
                if (haveDelete)
                {
                    deleteMessage = "return confirm('" + ConfigManager.MSAConfig.Messages[12].Content + "');";
                   
                }
                else
                {
                    gvMSAReport.MasterTableView.GetColumn("DeleteColumn").Visible = false;
                    deleteMessage = "javascript:alert('" + ConfigManager.MSAConfig.Messages[6].Content + "');return false;";
                }
                if (!haveInsert) { insertMessage = "javascript:alert('" + ConfigManager.MSAConfig.Messages[24].Content + "');return false;"; }
                if (!haveUdate) { updateMessage = "javascript:alert('" + ConfigManager.MSAConfig.Messages[23].Content + "');return false;"; }
                if (!haveQuery)
                {
                    gvMSAReport.Visible = false;
                    ShowAlertForCheckUser(ConfigManager.MSAConfig.Messages[7].Content);
                }
            }
            #endregion
           
            protected void gvMSAReport_DeleteCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
            {
                Trans trans = new Trans();
                lblMsg.Text = null;
                od_QMS_MSARPT_TABLE.InstrumentNo = e.Item.OwnerTableView.Items[e.Item.ItemIndex]["Instrument_No"].Text;
                od_QMS_MSARPT1_TABLE.InstrumentNo = e.Item.OwnerTableView.Items[e.Item.ItemIndex]["Instrument_No"].Text;
                od_QMS_MSARPT2_TABLE.InstrumentNo = e.Item.OwnerTableView.Items[e.Item.ItemIndex]["Instrument_No"].Text;
                try
                {
                    daoQMS_MSARPT.Delete(od_QMS_MSARPT_TABLE, trans);
                    daoQMS_MSARPT1.Delete(od_QMS_MSARPT1_TABLE, trans);
                    daoQMS_MSARPT2.Delete(od_QMS_MSARPT2_TABLE, trans);
                    trans.Commit();
                    trans.Dispose();
                    lcResult = new LiteralControl("<font color=\"red\">儀器編號:" + od_QMS_MSARPT_TABLE.InstrumentNo + ConfigManager.MSAConfig.Messages[2].Content + "</font>");
                }
                catch (Exception ex)
                {
                    trans.RollBack();
                    trans.Dispose();
                    lcResult = new LiteralControl("<font color=\"red\">儀器編號:" + od_QMS_MSARPT_TABLE.InstrumentNo + ConfigManager.MSAConfig.Messages[3].Content + " 失敗原因:" + ex.Message + "</font>");
                }
                lblMsg.Text = lcResult.Text;
                //gvMSAReport.Controls.Add(lcResult);
            }
            protected void gvMSAReport_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
            {
                if (e.Item is GridDataItem)// to access a row
                {
                    GridDataItem item = (GridDataItem)e.Item;
                    (item.Cells[3].Controls[0] as Button).OnClientClick = deleteMessage;
                    (item.Cells[3].Controls[0] as Button).CausesValidation = true;
                    (item.Cells[3].Controls[0] as Button).ValidationGroup = "DeleteGroup";
                    if (!haveInsertAndUpdate)
                    {
                        (item.FindControl("EditButton") as Button).OnClientClick = updateMessage;
                    }
                }
                if (e.Item is GridCommandItem && (!haveInsertAndUpdate))
                {
                    GridCommandItem item = (GridCommandItem)e.Item;
                    if (item.FindControl("InitInsertButton") != null)
                    {
                        (item.FindControl("InitInsertButton") as LinkButton).OnClientClick = insertMessage;
                        (item.FindControl("AddNewRecordButton") as Button).OnClientClick = insertMessage;
                    }
                }
               
            }
            protected void gvMSAReport_ItemCommand(object sender, GridCommandEventArgs e)
            {
                if (e.CommandName.Equals("InitInsert"))
                {
                    Session["Status"] = "Insert";
                    Session["Users"] = new List<vwemployeeinfo>();
                    Session["UsersTab2"] = new List<vwemployeeinfo>();
                    Session["UsersTab3"] = new List<vwemployeeinfo>();
                    Session["PageLoad"] = null;
                    //RadPane1.Visible = false;
                    //gvMSAReport.AllowPaging = false;
                    //Session["RadGrid1"] = new List<vwemployeeinfo>();
                    //Session["RadGrid2"] = new List<vwemployeeinfo>();
                    //Session["RadGrid3"] = new List<vwemployeeinfo>();
                    gvMSAReport.MasterTableView.ClearEditItems();
                }
                else if (e.CommandName.Equals("Edit"))
                {
                    Session["Status"] = "Update";
                    if ((e.CommandSource as Button).Text.Equals("查詢")) { Session["Status"] = "Query";}
                    Session["OldInstrumentNo"] = null;
                    Session["OldInstrumentNo"] = (e.Item as GridDataItem)["Instrument_No"].Text;
                    Session["PageLoad"] = null;
                    //RadPane1.Visible = false;
                    //gvMSAReport.AllowPaging = false;
                    dt = new DataTable();
                    dt = daoQMS_MSARPT1.SelectTab1((e.Item as GridDataItem)["Instrument_No"].Text);
                    List<vwemployeeinfo> lv = new List<vwemployeeinfo>();
                    for (int row_count = 0; row_count < dt.Rows.Count; row_count++)
                    {
                        od_vwemployeeinfo = new vwemployeeinfo();
                        od_vwemployeeinfo.employeeid = dt.Rows[row_count]["employeeid"].ToString();
                        od_vwemployeeinfo.deptcode = dt.Rows[row_count]["deptcode"].ToString();
                        od_vwemployeeinfo.localname = dt.Rows[row_count]["localname"].ToString();
                        lv.Add(od_vwemployeeinfo);
                    }
                    Session["Users"] = lv;
                    dt = new DataTable();
                    dt = daoQMS_MSARPT1.SelectTab2((e.Item as GridDataItem)["Instrument_No"].Text);
                    lv = new List<vwemployeeinfo>();
                    for (int row_count = 0; row_count < dt.Rows.Count; row_count++)
                    {
                        od_vwemployeeinfo = new vwemployeeinfo();
                        od_vwemployeeinfo.employeeid = dt.Rows[row_count]["employeeid"].ToString();
                        od_vwemployeeinfo.deptcode = dt.Rows[row_count]["deptcode"].ToString();
                        od_vwemployeeinfo.localname = dt.Rows[row_count]["localname"].ToString();
                        lv.Add(od_vwemployeeinfo);
                    }
                    Session["UsersTab2"] = lv;
                    dt = new DataTable();
                    dt = daoQMS_MSARPT1.SelectTab3((e.Item as GridDataItem)["Instrument_No"].Text);
                    lv = new List<vwemployeeinfo>();
                    for (int row_count = 0; row_count < dt.Rows.Count; row_count++)
                    {
                        od_vwemployeeinfo = new vwemployeeinfo();
                        od_vwemployeeinfo.employeeid = dt.Rows[row_count]["employeeid"].ToString();
                        od_vwemployeeinfo.deptcode = dt.Rows[row_count]["deptcode"].ToString();
                        od_vwemployeeinfo.localname = dt.Rows[row_count]["localname"].ToString();
                        lv.Add(od_vwemployeeinfo);
                    }
                    Session["UsersTab3"] = lv;
                    
                }
                else if (e.CommandName.Equals("Update") || e.CommandName.Equals("PerformInsert") || e.CommandName.Equals("Cancel"))
                {
                    //RadPane1.Visible = true;
                    //gvMSAReport.AllowPaging = true;
                }
               
               // try
               // {
               //     if (e.CommandName.Equals("Edit"))
               //     {
               //         gvMSAReport.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = false;
               //     }
               //     else
               //     {
               //         gvMSAReport.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = true;
               //     }
               // }
               // catch (Exception ex)
               // {
               // }
               // if (e.CommandName.Equals("Edit") || e.CommandName.Equals("Delete"))
               // {
               //gvMSAReport.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = false;
               // }
               // else if (e.CommandName.Equals("Update") || e.CommandName.Equals("PerformInsert") || e.CommandName.Equals("Cancel") )
               // {
               //     gvMSAReport.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = true;
               // }
            }
            protected void gvMSAReport_PreRender(object sender, EventArgs e)
            {
                if (gvMSAReport.MasterTableView.IsItemInserted)
                {
                    foreach (GridItem item in gvMSAReport.Items)
                        item.Visible = false;             
                }
                if (gvMSAReport.EditItems.Count > 0)
                {
                    foreach (GridDataItem item in gvMSAReport.MasterTableView.Items)
                    {
                        if (item != gvMSAReport.EditItems[0])
                        {
                            item.Visible = false;
                        }
                    }
                }
            }
            protected void gvMSAReport_InsertCommand(object sender, GridCommandEventArgs e)
            {
                Trans trans = new Trans();
                UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
                lcAlterMsg = new LiteralControl();
                lblMsg.Text = null;
                //if (!new daoExternalUnit().IsExist_Table(sQMS_MSARPT_TABLE, "instrument_no", (userControl.FindControl("tbInstrumentNo") as TextBox).Text, null, null, null, false))
                //{
                    try
                    {
                        #region QMS_MSARPT_TABLE
                        od_QMS_MSARPT_TABLE.Instrument = (userControl.FindControl("tbInstrument") as TextBox).Text.ToUpper();
                        od_QMS_MSARPT_TABLE.InstrumentNo = (userControl.FindControl("tbInstrumentNo") as TextBox).Text;
                        od_QMS_MSARPT_TABLE.Department = (userControl.FindControl("tbDepartment") as TextBox).Text.Trim();
                        od_QMS_MSARPT_TABLE.CalCyle = (userControl.FindControl("tbCalCyle") as TextBox).Text;
                        od_QMS_MSARPT_TABLE.Location = (userControl.FindControl("tbLocation") as TextBox).Text.Trim();
                        od_QMS_MSARPT_TABLE.GetoryName = (userControl.FindControl("tbGetoryName") as TextBox).Text.Trim();
                        od_QMS_MSARPT_TABLE.AgentMakerName = (userControl.FindControl("tbAgentMakerName") as TextBox).Text.Trim();
                        od_QMS_MSARPT_TABLE.InstrumentModel = (userControl.FindControl("tbInstrumentModel") as TextBox).Text.Trim();
                        od_QMS_MSARPT_TABLE.InstrumentSerialNo = (userControl.FindControl("tbInstrumentSeria") as TextBox).Text.Trim();
                        od_QMS_MSARPT_TABLE.InstrumentStep = (userControl.FindControl("tbInstrumentStep") as TextBox).Text.Trim();
                        od_QMS_MSARPT_TABLE.CheckDate = Convert.ToDateTime((userControl.FindControl("rdpCheckDat") as RadDatePicker).SelectedDate);
                        od_QMS_MSARPT_TABLE.NextCALDate = Convert.ToDateTime((userControl.FindControl("rdpNextCalDat") as RadDatePicker).SelectedDate);
                        try
                        {
                            od_QMS_MSARPT_TABLE.Bias = (float)(userControl.FindControl("ntbBias") as RadNumericTextBox).Value;
                        }
                        catch
                        { }
                        try
                        {
                            od_QMS_MSARPT_TABLE.Linearity = (float)(userControl.FindControl("ntbLinearit") as RadNumericTextBox).Value;
                        }
                        catch
                        { }
                        od_QMS_MSARPT_TABLE.MaskText = (userControl.FindControl("tbMaskText") as TextBox).Text;
                        od_QMS_MSARPT_TABLE.SysDate = Convert.ToDateTime(System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
                        daoQMS_MSARPT.Insert(od_QMS_MSARPT_TABLE, trans);
                        #endregion
                        #region into QMS_MSARPT1_TABLE
                        foreach (GridDataItem gdi in (userControl.FindControl("RadGrid1") as RadGrid).Items)
                        {
                            if (!(gdi["employeeid"].Text.Equals("") &&
                                  gdi["deptcode"].Text.Equals("") &&
                                  gdi["localname"].Text.Equals("")))
                            {
                                od_QMS_MSARPT1_TABLE.InstrumentNo = (userControl.FindControl("tbInstrumentNo") as TextBox).Text;
                                od_QMS_MSARPT1_TABLE.ItemNo = 0;
                                od_QMS_MSARPT1_TABLE.EmployeeNo = gdi["employeeid"].Text.Trim();
                                od_QMS_MSARPT1_TABLE.DeptNo = gdi["deptcode"].Text.Trim();
                                od_QMS_MSARPT1_TABLE.CName = gdi["localname"].Text.Trim();
                                daoQMS_MSARPT1.Insert(od_QMS_MSARPT1_TABLE, trans);
                            }
                        }
                        foreach (GridDataItem gdi in (userControl.FindControl("RadGrid2") as RadGrid).Items)
                        {
                            if (!(gdi["employeeid"].Text.Equals("") &&
                                  gdi["deptcode"].Text.Equals("") &&
                                  gdi["localname"].Text.Equals("")))
                            {
                                od_QMS_MSARPT1_TABLE.InstrumentNo = (userControl.FindControl("tbInstrumentNo") as TextBox).Text;
                                od_QMS_MSARPT1_TABLE.ItemNo = 1;
                                od_QMS_MSARPT1_TABLE.EmployeeNo = gdi["employeeid"].Text.Trim();
                                od_QMS_MSARPT1_TABLE.DeptNo = gdi["deptcode"].Text.Trim();
                                od_QMS_MSARPT1_TABLE.CName = gdi["localname"].Text.Trim();
                                daoQMS_MSARPT1.Insert(od_QMS_MSARPT1_TABLE, trans);
                            }
                        }
                        foreach (GridDataItem gdi in (userControl.FindControl("RadGrid3") as RadGrid).Items)
                        {
                            if (!(gdi["employeeid"].Text.Equals("") &&
                                  gdi["deptcode"].Text.Equals("") &&
                                  gdi["localname"].Text.Equals("")))
                            {
                                od_QMS_MSARPT1_TABLE.InstrumentNo = (userControl.FindControl("tbInstrumentNo") as TextBox).Text;
                                od_QMS_MSARPT1_TABLE.ItemNo = 2;
                                od_QMS_MSARPT1_TABLE.EmployeeNo = gdi["employeeid"].Text.Trim();
                                od_QMS_MSARPT1_TABLE.DeptNo = gdi["deptcode"].Text.Trim();
                                od_QMS_MSARPT1_TABLE.CName = gdi["localname"].Text.Trim();
                                daoQMS_MSARPT1.Insert(od_QMS_MSARPT1_TABLE, trans);
                            }
                        }
                        #endregion
                        #region into QMS_MSARPT2_TABLE
                        if ((((userControl.FindControl("tbGrs1") as RadNumericTextBox).Text)) != "")
                        {
                            od_QMS_MSARPT2_TABLE.InstrumentNo = (userControl.FindControl("tbInstrumentNo") as TextBox).Text;
                            od_QMS_MSARPT2_TABLE.Grr = (float)Convert.ToDouble(((userControl.FindControl("tbGrs1") as RadNumericTextBox).Text));
                            od_QMS_MSARPT2_TABLE.GRRAnalysis = (userControl.FindControl("tbMesGrs1") as TextBox).Text;
                            daoQMS_MSARPT2.Insert(od_QMS_MSARPT2_TABLE, "0", trans);
                        }
                        if ((((userControl.FindControl("tbGrs2") as RadNumericTextBox).Text)) != "")
                        {
                            od_QMS_MSARPT2_TABLE.InstrumentNo = (userControl.FindControl("tbInstrumentNo") as TextBox).Text;
                            od_QMS_MSARPT2_TABLE.Grr = (float)Convert.ToDouble(((userControl.FindControl("tbGrs2") as RadNumericTextBox).Text));
                            od_QMS_MSARPT2_TABLE.GRRAnalysis = (userControl.FindControl("tbMesGrs2") as TextBox).Text;
                            daoQMS_MSARPT2.Insert(od_QMS_MSARPT2_TABLE, "1", trans);
                        }
                        if ((((userControl.FindControl("tbGrs3") as RadNumericTextBox).Text)) != "")
                        {
                            od_QMS_MSARPT2_TABLE.InstrumentNo = (userControl.FindControl("tbInstrumentNo") as TextBox).Text;
                            od_QMS_MSARPT2_TABLE.Grr = (float)Convert.ToDouble(((userControl.FindControl("tbGrs3") as RadNumericTextBox).Text));
                            od_QMS_MSARPT2_TABLE.GRRAnalysis = (userControl.FindControl("tbMesGrs3") as TextBox).Text;
                            daoQMS_MSARPT2.Insert(od_QMS_MSARPT2_TABLE, "2", trans);
                        }
                        #endregion
                        #region update QMS_MSAHISTO_TABLE
                        try
                        {
                            daoQMS_MSAHISTO_TABLE.Update(Convert.ToDateTime((userControl.FindControl("rdpCheckDat") as RadDatePicker).SelectedDate), Convert.ToDateTime((userControl.FindControl("rdpNextCalDat") as RadDatePicker).SelectedDate), (userControl.FindControl("tbInstrument") as TextBox).Text, trans);
                        }
                        catch
                        {
                        }
                        #endregion
                        lcResult = new LiteralControl("<font color=\"red\">檢定編號:" + od_QMS_MSARPT_TABLE.InstrumentNo + ConfigManager.MSAConfig.Messages[0].Content + "</font>");
                        trans.Commit();
                        trans.Dispose();
                        //判斷檢定日期是否MSA已提早超過30天
                        try
                        {
                            lv_Max_NextCalDate = Convert.ToDateTime(new daoQMS_MSARPT_TABLE().getMaxNextCalDate((userControl.FindControl("tbInstrument") as TextBox).Text, (userControl.FindControl("tbInstrumentNo") as TextBox).Text));
                        }
                        catch
                        {
                            lv_Max_NextCalDate = Convert.ToDateTime((userControl.FindControl("rdpCheckDat") as RadDatePicker).SelectedDate);
                        }
                        if (Convert.ToDateTime((userControl.FindControl("rdpCheckDat") as RadDatePicker).SelectedDate) < (lv_Max_NextCalDate.AddDays(-30)))
                        {
                            lcAlterMsg = new LiteralControl("<font color=\"red\">警告:MSA" + ConfigManager.MSAConfig.Messages[25].Content + "已提早超過30天</font>");
                        }
                    }
                    catch (Exception ex)
                    {
                        trans.RollBack();
                        trans.Dispose();
                        lcResult = new LiteralControl("<font color=\"red\">檢定編號:" + od_QMS_MSARPT_TABLE.InstrumentNo + ConfigManager.MSAConfig.Messages[1].Content + " 失敗原因:" + ex.Message + "</font>");
                        e.Canceled = true;
                    }
                //}
                //else
                //{
                //    lcResult = new LiteralControl("<font color=\"red\">此儀器" + od_QMS_MSARPT_TABLE.InstrumentNo + ConfigManager.MSAConfig.Messages[14].Content + "</font>");
                //    e.Canceled = true;
                //}
                lblMsg.Text = lcResult.Text + " " + lcAlterMsg.Text;
                gvMSAReport.Controls.Add(lcResult);
                gvMSAReport.Controls.Add(lcAlterMsg);
            }
            protected void gvMSAReport_UpdateCommand(object sender, GridCommandEventArgs e)
            {
                Trans trans = new Trans();
                UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
                lcAlterMsg = new LiteralControl();
                lblMsg.Text = null;
                try
                {
                    #region Update QMS_MSARPT_TABLE
                    od_QMS_MSARPT_TABLE.Instrument = (userControl.FindControl("tbInstrument") as TextBox).Text;
                    od_QMS_MSARPT_TABLE.InstrumentNo = (userControl.FindControl("tbInstrumentNo") as TextBox).Text;
                    od_QMS_MSARPT_TABLE.Department = (userControl.FindControl("tbDepartment") as TextBox).Text;
                    od_QMS_MSARPT_TABLE.CalCyle = (userControl.FindControl("tbCalCyle") as TextBox).Text;
                    od_QMS_MSARPT_TABLE.Location = (userControl.FindControl("tbLocation") as TextBox).Text;
                    od_QMS_MSARPT_TABLE.GetoryName = (userControl.FindControl("tbGetoryName") as TextBox).Text;
                    od_QMS_MSARPT_TABLE.AgentMakerName = (userControl.FindControl("tbAgentMakerName") as TextBox).Text;
                    od_QMS_MSARPT_TABLE.InstrumentModel = (userControl.FindControl("tbInstrumentModel") as TextBox).Text;
                    od_QMS_MSARPT_TABLE.InstrumentSerialNo = (userControl.FindControl("tbInstrumentSeria") as TextBox).Text;
                    od_QMS_MSARPT_TABLE.InstrumentStep = (userControl.FindControl("tbInstrumentStep") as TextBox).Text;
                    od_QMS_MSARPT_TABLE.CheckDate = Convert.ToDateTime((userControl.FindControl("rdpCheckDat") as RadDatePicker).SelectedDate);
                    od_QMS_MSARPT_TABLE.NextCALDate = Convert.ToDateTime((userControl.FindControl("rdpNextCalDat") as RadDatePicker).SelectedDate);
                    try
                    {
                        od_QMS_MSARPT_TABLE.Bias = (float)(userControl.FindControl("ntbBias") as RadNumericTextBox).Value;
                    }
                    catch
                    { }
                    try
                    {
                        od_QMS_MSARPT_TABLE.Linearity = (float)(userControl.FindControl("ntbLinearit") as RadNumericTextBox).Value;
                    }
                    catch
                    { }
                    od_QMS_MSARPT_TABLE.MaskText = (userControl.FindControl("tbMaskText") as TextBox).Text;
                    daoQMS_MSARPT.Update(od_QMS_MSARPT_TABLE, Session["OldInstrumentNo"].ToString(), trans);
                    #endregion
                    #region Update into QMS_MSARPT1_TABLE
                    od_QMS_MSARPT1_TABLE.InstrumentNo = (userControl.FindControl("tbInstrumentNo") as TextBox).Text;
                    daoQMS_MSARPT1.Delete(od_QMS_MSARPT1_TABLE, "0", trans);
                    foreach (GridDataItem gdi in (userControl.FindControl("RadGrid1") as RadGrid).Items)
                    {
                        if (!(gdi["employeeid"].Text.Equals("") &&
                              gdi["deptcode"].Text.Equals("") &&
                              gdi["localname"].Text.Equals("")))
                        {
                            od_QMS_MSARPT1_TABLE.InstrumentNo = (userControl.FindControl("tbInstrumentNo") as TextBox).Text;
                            od_QMS_MSARPT1_TABLE.ItemNo = 0;
                            od_QMS_MSARPT1_TABLE.EmployeeNo = gdi["employeeid"].Text.Trim();
                            od_QMS_MSARPT1_TABLE.DeptNo = gdi["deptcode"].Text.Trim();
                            od_QMS_MSARPT1_TABLE.CName = gdi["localname"].Text.Trim();
                            daoQMS_MSARPT1.Insert(od_QMS_MSARPT1_TABLE, "0", trans);
                        }
                    }
                    od_QMS_MSARPT1_TABLE.InstrumentNo = (userControl.FindControl("tbInstrumentNo") as TextBox).Text;
                    daoQMS_MSARPT1.Delete(od_QMS_MSARPT1_TABLE, "1", trans);
                    foreach (GridDataItem gdi in (userControl.FindControl("RadGrid2") as RadGrid).Items)
                    {
                        if (!(gdi["employeeid"].Text.Equals("") &&
                              gdi["deptcode"].Text.Equals("") &&
                              gdi["localname"].Text.Equals("")))
                        {
                            od_QMS_MSARPT1_TABLE.InstrumentNo = (userControl.FindControl("tbInstrumentNo") as TextBox).Text;
                            od_QMS_MSARPT1_TABLE.ItemNo = 1;
                            od_QMS_MSARPT1_TABLE.EmployeeNo = gdi["employeeid"].Text.Trim();
                            od_QMS_MSARPT1_TABLE.DeptNo = gdi["deptcode"].Text.Trim();
                            od_QMS_MSARPT1_TABLE.CName = gdi["localname"].Text.Trim();
                            daoQMS_MSARPT1.Insert(od_QMS_MSARPT1_TABLE, "1", trans);
                        }
                    }
                    od_QMS_MSARPT1_TABLE.InstrumentNo = (userControl.FindControl("tbInstrumentNo") as TextBox).Text;
                    daoQMS_MSARPT1.Delete(od_QMS_MSARPT1_TABLE, "2", trans);
                    foreach (GridDataItem gdi in (userControl.FindControl("RadGrid3") as RadGrid).Items)
                    {
                        if (!(gdi["employeeid"].Text.Equals("") &&
                              gdi["deptcode"].Text.Equals("") &&
                              gdi["localname"].Text.Equals("")))
                        {
                            od_QMS_MSARPT1_TABLE.InstrumentNo = (userControl.FindControl("tbInstrumentNo") as TextBox).Text;
                            od_QMS_MSARPT1_TABLE.ItemNo = 2;
                            od_QMS_MSARPT1_TABLE.EmployeeNo = gdi["employeeid"].Text.Trim();
                            od_QMS_MSARPT1_TABLE.DeptNo = gdi["deptcode"].Text.Trim();
                            od_QMS_MSARPT1_TABLE.CName = gdi["localname"].Text.Trim();
                            daoQMS_MSARPT1.Insert(od_QMS_MSARPT1_TABLE, "2", trans);
                        }
                    }
                    #endregion
                    #region Update QMS_MSARPT2_TABLE
                    od_QMS_MSARPT2_TABLE.InstrumentNo = (userControl.FindControl("tbInstrumentNo") as TextBox).Text;
                    daoQMS_MSARPT2.Delete(od_QMS_MSARPT2_TABLE, trans);
                    if ((((userControl.FindControl("tbGrs1") as RadNumericTextBox).Text)) != "")
                    {
                        od_QMS_MSARPT2_TABLE.InstrumentNo = (userControl.FindControl("tbInstrumentNo") as TextBox).Text;
                        od_QMS_MSARPT2_TABLE.Grr = (float)Convert.ToDouble(((userControl.FindControl("tbGrs1") as RadNumericTextBox).Text));
                        od_QMS_MSARPT2_TABLE.GRRAnalysis = (userControl.FindControl("tbMesGrs1") as TextBox).Text;
                        daoQMS_MSARPT2.Insert(od_QMS_MSARPT2_TABLE, "0", trans);
                    }
                    if ((((userControl.FindControl("tbGrs2") as RadNumericTextBox).Text)) != "")
                    {
                        od_QMS_MSARPT2_TABLE.InstrumentNo = (userControl.FindControl("tbInstrumentNo") as TextBox).Text;
                        od_QMS_MSARPT2_TABLE.Grr = (float)Convert.ToDouble(((userControl.FindControl("tbGrs2") as RadNumericTextBox).Text));
                        od_QMS_MSARPT2_TABLE.GRRAnalysis = (userControl.FindControl("tbMesGrs2") as TextBox).Text;
                        daoQMS_MSARPT2.Insert(od_QMS_MSARPT2_TABLE, "1", trans);
                    }
                    if ((((userControl.FindControl("tbGrs3") as RadNumericTextBox).Text)) != "")
                    {
                        od_QMS_MSARPT2_TABLE.InstrumentNo = (userControl.FindControl("tbInstrumentNo") as TextBox).Text;
                        od_QMS_MSARPT2_TABLE.Grr = (float)Convert.ToDouble(((userControl.FindControl("tbGrs3") as RadNumericTextBox).Text));
                        od_QMS_MSARPT2_TABLE.GRRAnalysis = (userControl.FindControl("tbMesGrs3") as TextBox).Text;
                        daoQMS_MSARPT2.Insert(od_QMS_MSARPT2_TABLE, "2", trans);
                    }
                    #endregion
                    #region update QMS_MSAHISTO_TABLE
                    try
                    {
                        daoQMS_MSAHISTO_TABLE.Update(Convert.ToDateTime((userControl.FindControl("rdpCheckDat") as RadDatePicker).SelectedDate), Convert.ToDateTime((userControl.FindControl("rdpNextCalDat") as RadDatePicker).SelectedDate), (userControl.FindControl("tbInstrument") as TextBox).Text,trans);
                    }
                    catch
                    {
                    }
                    #endregion
                    trans.Commit();
                    trans.Dispose();
                    lcResult = new LiteralControl("<font color=\"red\">檢定編號:" + od_QMS_MSARPT_TABLE.InstrumentNo + ConfigManager.MSAConfig.Messages[4].Content + "</font>");
                   
                    //判斷檢定日期是否MSA已提早超過30天
                    try
                    {
                        lv_Max_NextCalDate = Convert.ToDateTime(new daoQMS_MSARPT_TABLE().getMaxNextCalDate((userControl.FindControl("tbInstrument") as TextBox).Text, (userControl.FindControl("tbInstrumentNo") as TextBox).Text));
                    }
                    catch
                    {
                        lv_Max_NextCalDate = Convert.ToDateTime((userControl.FindControl("rdpCheckDat") as RadDatePicker).SelectedDate);
                    }
                    if (Convert.ToDateTime((userControl.FindControl("rdpCheckDat") as RadDatePicker).SelectedDate) < (lv_Max_NextCalDate.AddDays(-30)))
                    {
                        lcAlterMsg = new LiteralControl("<font color=\"red\">警告:MSA已提早超過30天</font>");
                    }
                }
                catch (Exception ex)
                {
                    trans.RollBack();
                    trans.Dispose();
                    lcResult = new LiteralControl("<font color=\"red\">檢定編號:" + od_QMS_MSARPT_TABLE.InstrumentNo + ConfigManager.MSAConfig.Messages[5].Content + " 失敗原因:" + ex.Message + "</font>");
                    e.Canceled = true;
                }
                lblMsg.Text = lcResult.Text + " " +lcAlterMsg.Text;
                //DisplayMessageWithLable(lblMsg, lcResult.Text + " " + lcAlterMsg.Text);
                gvMSAReport.Controls.Add(lcResult);
                gvMSAReport.Controls.Add(lcAlterMsg);
            }
            protected void btnClear_Click(object sender, EventArgs e)
            {
                tbInstrumentNo.Text = null;
                tbInstrumentModel.Text = null;
                dtpSysFromDate.Clear();
                dtpSysToDate.Clear();
                dpCheckDateF.Clear();
                dpCheckDateT.Clear();
                dpNextCalDateF.Clear();
                dpNextCalDateT.Clear();
              
            }
            protected void btnQuery_Click(object sender, EventArgs e)
            {
                gvMSAReport.MasterTableView.ClearChildEditItems();
            }
        }
    }
  7. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 14 May 2014 in reply to 啟仲 Link to this post

    Hi 啟仲,

    I'm not clear about your issue, from your code i see that you have used a GridEditCommandColumn as well as a GridButtonColumn for Edit in RadGrid. Please use either one as shown below and let me know if any concern. Elaborate on your requirement if this doesn't help.

    ASPX:
    <%-- Edit Button--%>
    <telerik:GridEditCommandColumn EditText="修改" FilterControlAltText="Filter EditCommandColumn column" ButtonType="PushButton">
        <HeaderStyle Width="60px" />
    </telerik:GridEditCommandColumn>
    <%--Delete Button--%>
    <telerik:GridButtonColumn ButtonType="PushButton" CommandName="Delete" FilterControlAltText="Filter DeleteColumn column" Text="刪除" UniqueName="DeleteColumn" ConfirmText="Are you sure to Delete?" ConfirmDialogType="RadWindow">
        <HeaderStyle Width="60px" />
    </telerik:GridButtonColumn>

    Thanks,
    Princy
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017