Protected Sub gvDisplay_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles gvDisplay.RowCommand
If e.CommandName = "cmdDelete" Then
Dim Sl_No As Integer = 0
Sl_No = Int32.Parse(e.CommandArgument.ToString())
Dim ObjQueue As clsQueue = New clsQueue()
Dim retval As Integer
Try
retval = ObjQueue.DeleteActivetask(Convert.ToString(Sl_No))
Catch ex As Exception
Dim objErrHandler = New clsErrHandler()
objErrHandler.WriteError(ex)
End Try
BindGrid()
lblMessage.Text = "Service Active Slot has been deleted successfully."
ElseIf e.CommandName = "cmdEdit" Then
Dim Sl_No As Integer = 0
Sl_No = Int32.Parse(e.CommandArgument.ToString())
Dim ObjQueue As clsQueue = New clsQueue()
Dim dt As DataTable
Try
dt = ObjQueue.EditActivetask(Convert.ToString(Sl_No))
If dt.Rows.Count > 0 Then
ddlTask.SelectedValue = Convert.ToString(dt.Rows(0)("Task_Id"))
ddlTask.Enabled = False
' txtFrom.Text = Convert.ToString(dt.Rows(0)("FromTime"))
' txtTo.Text = Convert.ToString(dt.Rows(0)("ToTime"))
If Convert.ToInt32(Convert.ToString(dt.Rows(0)("FromTime")).Substring(0, 2)) >= 12 Then
ddlFromAMPM.SelectedValue = "PM"
If Convert.ToInt32(Convert.ToString(dt.Rows(0)("FromTime")).Substring(0, 2)) = 12 Then
ddlFromHr.SelectedValue = Convert.ToString(Convert.ToInt32(Convert.ToString(dt.Rows(0)("FromTime")).Substring(0, 2))).PadLeft(2, "0")
Else
ddlFromHr.SelectedValue = Convert.ToString(Convert.ToInt32(Convert.ToString(dt.Rows(0)("FromTime")).Substring(0, 2)) - 12).PadLeft(2, "0")
End If
Else
ddlFromAMPM.SelectedValue = "AM"
ddlFromHr.SelectedValue = Convert.ToString(dt.Rows(0)("FromTime")).Substring(0, 2)
End If
ddlFromMin.SelectedValue = Convert.ToString(dt.Rows(0)("FromTime")).Substring(2, 2)
If Convert.ToInt32(Convert.ToString(dt.Rows(0)("ToTime")).Substring(0, 2)) >= 12 Then
ddlToAMPM.SelectedValue = "PM"
ddlToHr.SelectedValue = Convert.ToString(Convert.ToInt32(Convert.ToString(dt.Rows(0)("ToTime")).Substring(0, 2)) - 12).PadLeft(2, "0")
Else
ddlToAMPM.SelectedValue = "AM"
ddlToHr.SelectedValue = Convert.ToString(dt.Rows(0)("ToTime")).Substring(0, 2)
End If
ddlToMin.SelectedValue = Convert.ToString(dt.Rows(0)("ToTime")).Substring(2, 2)
ViewState("Sl_No") = Convert.ToString(dt.Rows(0)("Sl_No"))
btnSave.Text = "Update"
End If
Catch ex As Exception
Dim objErrHandler = New clsErrHandler()
objErrHandler.WriteError(ex)
End Try
End If
End Sub
<asp:GridView ID="gvDisplay" runat="server" AlternatingRowStyle-BackColor="#C2D69B" AutoGenerateColumns="False"
DataKeyNames="Sl_No" EmptyDataText="No Records Found" Font-Names="Arial" Font-Size="11pt" HeaderStyle-BackColor="green"
HeaderStyle-ForeColor="white" Height="42px" PagerStyle-HorizontalAlign="Right" Width="98%" RowStyle-Font-Size="Large" BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" CellSpacing="1" GridLines="None">
<FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
<PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
<RowStyle CssClass="RowStyle" BackColor="#DEDFDE" ForeColor="Black" />
<AlternatingRowStyle CssClass="AlternateRowStyle" />
<Columns>
<asp:BoundField DataField="Task" HeaderText="Service Name" />
<asp:TemplateField HeaderText="FromTime" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"
ItemStyle-Width="10%">
<ItemTemplate>
<asp:Label ID="lblFromTime" runat="server" Text=' <%# GetFormattedTime(Eval("FromTime"))%>'></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" Width="10%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="ToTime" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"
ItemStyle-Width="10%">
<ItemTemplate>
<asp:Label ID="lblToTime" runat="server" Text=' <%# GetFormattedTime(Eval("ToTime"))%>'></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" Width="10%" />
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnDelete" runat="server" CommandArgument='<%#Eval("Sl_No")%>' CommandName="cmdDelete" OnClientClick="return ConfirmOnDelete();" Text="Delete"
Width="100px" Height="30px" Style="font-size: 16px" />
<asp:Button ID="btnEdit" runat="server" CommandArgument='<%#Eval("Sl_No")%>' CommandName="cmdEdit" Text="Edit" Width="100px" Height="30px" Style="font-size: 16px" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataRowStyle BackColor="#C2D69B" HorizontalAlign="Center" Width="450px" />
<SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#594B9C" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#33276A" />
</asp:GridView>
If e.CommandName = "cmdDelete" Then
Dim Sl_No As Integer = 0
Sl_No = Int32.Parse(e.CommandArgument.ToString())
Dim ObjQueue As clsQueue = New clsQueue()
Dim retval As Integer
Try
retval = ObjQueue.DeleteActivetask(Convert.ToString(Sl_No))
Catch ex As Exception
Dim objErrHandler = New clsErrHandler()
objErrHandler.WriteError(ex)
End Try
BindGrid()
lblMessage.Text = "Service Active Slot has been deleted successfully."
ElseIf e.CommandName = "cmdEdit" Then
Dim Sl_No As Integer = 0
Sl_No = Int32.Parse(e.CommandArgument.ToString())
Dim ObjQueue As clsQueue = New clsQueue()
Dim dt As DataTable
Try
dt = ObjQueue.EditActivetask(Convert.ToString(Sl_No))
If dt.Rows.Count > 0 Then
ddlTask.SelectedValue = Convert.ToString(dt.Rows(0)("Task_Id"))
ddlTask.Enabled = False
' txtFrom.Text = Convert.ToString(dt.Rows(0)("FromTime"))
' txtTo.Text = Convert.ToString(dt.Rows(0)("ToTime"))
If Convert.ToInt32(Convert.ToString(dt.Rows(0)("FromTime")).Substring(0, 2)) >= 12 Then
ddlFromAMPM.SelectedValue = "PM"
If Convert.ToInt32(Convert.ToString(dt.Rows(0)("FromTime")).Substring(0, 2)) = 12 Then
ddlFromHr.SelectedValue = Convert.ToString(Convert.ToInt32(Convert.ToString(dt.Rows(0)("FromTime")).Substring(0, 2))).PadLeft(2, "0")
Else
ddlFromHr.SelectedValue = Convert.ToString(Convert.ToInt32(Convert.ToString(dt.Rows(0)("FromTime")).Substring(0, 2)) - 12).PadLeft(2, "0")
End If
Else
ddlFromAMPM.SelectedValue = "AM"
ddlFromHr.SelectedValue = Convert.ToString(dt.Rows(0)("FromTime")).Substring(0, 2)
End If
ddlFromMin.SelectedValue = Convert.ToString(dt.Rows(0)("FromTime")).Substring(2, 2)
If Convert.ToInt32(Convert.ToString(dt.Rows(0)("ToTime")).Substring(0, 2)) >= 12 Then
ddlToAMPM.SelectedValue = "PM"
ddlToHr.SelectedValue = Convert.ToString(Convert.ToInt32(Convert.ToString(dt.Rows(0)("ToTime")).Substring(0, 2)) - 12).PadLeft(2, "0")
Else
ddlToAMPM.SelectedValue = "AM"
ddlToHr.SelectedValue = Convert.ToString(dt.Rows(0)("ToTime")).Substring(0, 2)
End If
ddlToMin.SelectedValue = Convert.ToString(dt.Rows(0)("ToTime")).Substring(2, 2)
ViewState("Sl_No") = Convert.ToString(dt.Rows(0)("Sl_No"))
btnSave.Text = "Update"
End If
Catch ex As Exception
Dim objErrHandler = New clsErrHandler()
objErrHandler.WriteError(ex)
End Try
End If
End Sub
<asp:GridView ID="gvDisplay" runat="server" AlternatingRowStyle-BackColor="#C2D69B" AutoGenerateColumns="False"
DataKeyNames="Sl_No" EmptyDataText="No Records Found" Font-Names="Arial" Font-Size="11pt" HeaderStyle-BackColor="green"
HeaderStyle-ForeColor="white" Height="42px" PagerStyle-HorizontalAlign="Right" Width="98%" RowStyle-Font-Size="Large" BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" CellSpacing="1" GridLines="None">
<FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
<PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
<RowStyle CssClass="RowStyle" BackColor="#DEDFDE" ForeColor="Black" />
<AlternatingRowStyle CssClass="AlternateRowStyle" />
<Columns>
<asp:BoundField DataField="Task" HeaderText="Service Name" />
<asp:TemplateField HeaderText="FromTime" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"
ItemStyle-Width="10%">
<ItemTemplate>
<asp:Label ID="lblFromTime" runat="server" Text=' <%# GetFormattedTime(Eval("FromTime"))%>'></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" Width="10%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="ToTime" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"
ItemStyle-Width="10%">
<ItemTemplate>
<asp:Label ID="lblToTime" runat="server" Text=' <%# GetFormattedTime(Eval("ToTime"))%>'></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" Width="10%" />
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnDelete" runat="server" CommandArgument='<%#Eval("Sl_No")%>' CommandName="cmdDelete" OnClientClick="return ConfirmOnDelete();" Text="Delete"
Width="100px" Height="30px" Style="font-size: 16px" />
<asp:Button ID="btnEdit" runat="server" CommandArgument='<%#Eval("Sl_No")%>' CommandName="cmdEdit" Text="Edit" Width="100px" Height="30px" Style="font-size: 16px" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataRowStyle BackColor="#C2D69B" HorizontalAlign="Center" Width="450px" />
<SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#594B9C" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#33276A" />
</asp:GridView>
No comments:
Post a Comment