Radcombobox change java script not fired,
how i achieve this one
Thanks Advance,
Mohamed.
how i achieve this one
RadComboBox DedSer1 = (RadComboBox)e.Item.FindControl("DedSer1");DedSer1.Attributes.Add("onChange", string.Format("CalculationAmount('{0}','{1}','{2}','{3}','{4}','{5}','{6}');", InvFinalamount.ClientID, DedValue.ClientID, DedInvoiceMinus.ClientID, GetValueSev.ClientID, GstInvoice.ClientID, InvoiceType.ClientID, DedSer1.ClientID));Thanks Advance,
Mohamed.
8 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 31 Dec 2012, 07:11 AM
Hi,
Try the following code snippet to fire the Javascript function.
C#:
Thanks,
Shinu.
Try the following code snippet to fire the Javascript function.
C#:
. . . DedSer1.Attributes.Add("onChange","CalculationAmount('"+InvFinalamount.ClientID+"', '"+DedValue.ClientID+"', '"+DedInvoiceMinus.ClientID+"', '"+GetValueSev.ClientID+"', '"+GstInvoice.ClientID+"', '"+InvoiceType.ClientID+"', '"+DedSer1.ClientID+"')");. . .Thanks,
Shinu.
0
0
Shinu
Top achievements
Rank 2
answered on 02 Jan 2013, 11:54 AM
Hi
Unfortunately I couldn't replicate the issue that you are facing. Here is the code that I tried and which worked as expected at my end.
ASPX:
C#:
JS:
Please provide your full code if it doesn't helps.
Regards,
Shinu.
Unfortunately I couldn't replicate the issue that you are facing. Here is the code that I tried and which worked as expected at my end.
ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="true" DataSourceID="SqlDataSource1" onitemdatabound="RadGrid1_ItemDataBound"> <MasterTableView> <Columns> <telerik:GridTemplateColumn> <ItemTemplate> <telerik:RadComboBox ID="DedSer1" runat="server" AutoPostBack="true"> ........ </telerik:RadComboBox> </ItemTemplate> </telerik:GridTemplateColumn> ............. </Columns> </MasterTableView></telerik:RadGrid>C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e){ if (e.Item is GridDataItem) { GridDataItem DataItem = (GridDataItem)e.Item; RadComboBox DedSer = (RadComboBox)DataItem.FindControl("DedSer1"); DedSer1.Attributes.Add("onChange","CalculationAmount('"+InvFinalamount.ClientID+"', '"+DedValue.ClientID+"', '"+DedInvoiceMinus.ClientID+"', '"+GetValueSev.ClientID+"', '"+GstInvoice.ClientID+"', '"+InvoiceType.ClientID+"', '"+DedSer1.ClientID+"')"); }}JS:
<script type="text/javascript"> function CalculationAmount(InvFinalamount,DedValue,DedInvoiceMinus,GetValueSev,GstInvoice,InvoiceType,DedSer1.ClientID){ //Your code }</script>Please provide your full code if it doesn't helps.
Regards,
Shinu.
0
mohamed
Top achievements
Rank 1
answered on 02 Jan 2013, 02:05 PM
Thanks For Ur reply Shinu
.aspx
I bind the values in run time like that
.cs
i call like that from itemdatabount
.cs
See the attachment screen
Thanks advance,
Mohamed.
.aspx
<telerik:RadComboBox runat="server" id="DedSer1" AutoPostBack="true" AppendDataBoundItems="true" width="50px"> </telerik:RadComboBox>I bind the values in run time like that
.cs
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) { if (e.Item.OwnerTableView.IsItemInserted) { RadComboBox DedSer1 = (RadComboBox)item.FindControl("DedSer1"); DedSer1.Items.Add(new RadComboBoxItem("6", "6")); DedSer1.Items.Add(new RadComboBoxItem("8", "8")); } }i call like that from itemdatabount
.cs
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridEditableItem && e.Item.IsInEditMode) { RadComboBox DedSer1 = (RadComboBox)e.Item.FindControl("DedSer1"); DedSer1.Attributes.Add("onChange", "CalculationAmount('" + InvFinalamount.ClientID + "', '" + DedValue.ClientID + "', '" + DedInvoiceMinus.ClientID + "', '" + GetValueSev.ClientID + "', '" + GstInvoice.ClientID + "', '" + InvoiceType.ClientID + "', '" + DedSer1.ClientID + "')"); } }See the attachment screen
Thanks advance,
Mohamed.
0
Shinu
Top achievements
Rank 2
answered on 03 Jan 2013, 04:04 AM
Hi,
After inspecting your code I guess you want to populate the RadComboBox in both edit and insert mode. Please try the following code snippet which worked as expected for me.
C#:
Hope this helps.
Regards,
Shinu.
After inspecting your code I guess you want to populate the RadComboBox in both edit and insert mode. Please try the following code snippet which worked as expected for me.
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e){ if (e.Item is GridEditableItem && e.Item.IsInEditMode) { GridEditableItem DataItem = (GridEditableItem)e.Item; RadComboBox DedSer = (RadComboBox)DataItem.FindControl("DedSer1"); DedSer1.Attributes.Add("onChange", "CalculationAmount('" + InvFinalamount.ClientID + "', '" + DedValue.ClientID + "', '" + DedInvoiceMinus.ClientID + "', '" + GetValueSev.ClientID + "', '" + GstInvoice.ClientID + "', '" + InvoiceType.ClientID + "', '" + DedSer1.ClientID + "')"); }}protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e){ if (e.Item is GridEditableItem && e.Item.IsInEditMode) { GridEditableItem item = (GridEditableItem)e.Item; RadComboBox DedSer1 = (RadComboBox)item.FindControl("DedSer1"); DedSer1.Items.Add(new RadComboBoxItem("6", "6")); DedSer1.Items.Add(new RadComboBoxItem("8", "8")); }}Hope this helps.
Regards,
Shinu.
0
mohamed
Top achievements
Rank 1
answered on 03 Jan 2013, 04:47 AM
Thanks for r reply
As you told like that i did in my side but not fired the javascript
.aspx
Thanks Advance,
Mohamed.
As you told like that i did in my side but not fired the javascript
.aspx
<telerik:RadComboBox runat="server" id="DedSer1" AutoPostBack="true" AppendDataBoundItems="true" width="50px"> </telerik:RadComboBox>Thanks Advance,
Mohamed.
0
Shinu
Top achievements
Rank 2
answered on 04 Jan 2013, 04:14 AM
Hi Mohamed,
Unfortunately I couldn't replicate the issue that you are facing. Please provide your entire code so that I can replicate the issue at my end.
Regards,
Shinu.
Unfortunately I couldn't replicate the issue that you are facing. Please provide your entire code so that I can replicate the issue at my end.
Regards,
Shinu.
0
mohamed
Top achievements
Rank 1
answered on 04 Jan 2013, 05:02 AM
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="workorder.aspx.cs" Inherits="DOSKMANAGEMENT.PMS.workorder" MasterPageFile="~/Site.Master" %><%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %><asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> <%= Resources.FormName.workorder%></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="FormName" runat="server"> <%= Resources.FormName.workorder%></asp:Content><asp:Content ID="aboutContent" ContentPlaceHolderID="MainContent" runat="server"> <telerik:RadCodeBlock runat="server" ID="radCodeBlock"> <script type="text/javascript"> function Surviour(totest) { var Toalest = $find(totest).get_value(); var md = 0; if (Toalest == "") { var duratn = $find(totest); duratn.set_value(md); } } function Jointer(totest) { var Toalest = $find(totest).get_value(); var md = 0; if (Toalest == "") { var duratn = $find(totest); duratn.set_value(md); } } function changeEndDate(startDateID, endDateID, chk) { var startDateObj = $find(startDateID); var startDate = startDateObj.get_selectedDate(); var endDateObj = $find(endDateID); var endofdate = endDateObj.get_selectedDate(); if (endDateObj._element.value != "") { if (endofdate <= startDate) { if (chk == 0) { endDateObj.clear(); alert("Commencement Date should be greater than Work Order Date"); } else if (chk == 1) { endDateObj.clear(); alert("Completion Date should be greater than Commencement Date"); } } } } function onToolBarClientButtonClicking(sender, args) { var grid = $find("<%=RadGrid1.ClientID %>"); var comandName = args.get_item().get_commandName(); if (comandName == "Filter") { if (grid.get_masterTableView().get_isFilterItemVisible()) { grid.get_masterTableView().hideFilterItem(); } else { grid.get_masterTableView().showFilterItem(); } } } function onRequestStart(sender, args) { if (args.get_eventTarget().indexOf("btnExport") >= 0) args.set_enableAjax(false); } //this for to avoid decimal point function NoDecimal(sender, eventArgs) { //debugger; var c = eventArgs.get_keyCharacter(); if (c == '.') eventArgs.set_cancel(true); } //this for to avoid decimal point function KeyPress(sender, args) { if (args.get_keyCharacter() == sender.get_numberFormat().DecimalSeparator) { args.set_cancel(true); } } </script> </telerik:RadCodeBlock> <telerik:RadFormDecorator ID="FormDecorator1" runat="server" EnableRoundedCorners="false" DecoratedControls="All"></telerik:RadFormDecorator> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" UpdatePanelsRenderMode="Inline" DefaultLoadingPanelID="tbsLoadingPanel"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadAjaxLoadingPanel ID="tbsLoadingPanel" runat="server" Skin="Default" IsSticky="false"> </telerik:RadAjaxLoadingPanel> <table style="margin-top: 10px; width: 100%"> <tr> <td> <telerik:RadGrid ID="RadGrid1" runat="server" Skin="Office2007" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" GridLines="None" autocompletetype="Disabled" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" OnNeedDataSource="RadGrid1_NeedDataSource" VirtualItemCount="500" OnItemCommand="RadGrid1_ItemCommand" OnItemCreated="RadGrid1_ItemCreated" EnableHeaderContextMenu="true" EnableHeaderContextFilterMenu="true" OnPreRender="RadGrid1_PreRender" OnItemDataBound="RadGrid1_ItemDataBound"> <ExportSettings> <Pdf PageHeight="297mm" PageWidth="210mm" /> </ExportSettings> <GroupingSettings CaseSensitive="true" /> <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" EditMode="PopUp" IsFilterItemExpanded="false" EditFormSettings-PopUpSettings-Modal="true" AllowFilteringByColumn="true" AllowMultiColumnSorting="true"> <CommandItemTemplate> <telerik:RadToolBar ID="RadToolBar1" runat="server" OnClientButtonClicking="onToolBarClientButtonClicking" OnButtonClick="RadToolBar1_ButtonClick"> <Items> <telerik:RadToolBarButton Text="Add New" CommandName="InitInsert" ImageUrl="../../images/AddRecord.gif" Visible='<%# !RadGrid1.MasterTableView.IsItemInserted %>'> </telerik:RadToolBarButton> <telerik:RadToolBarButton Text="<%$ Resources:FormName, Filter %>" CommandName="Filter" ImageUrl="../../images/Filter 3.gif"> </telerik:RadToolBarButton> <telerik:RadToolBarButton Text="<%$ Resources:FormName, Refresh %>" CommandName="RebindGrid" ImageUrl="../../images/Refresh.gif"> </telerik:RadToolBarButton> <telerik:RadToolBarButton runat="server" Value="HeaderDisplay"> <ItemTemplate> <table> <tr> <td align="right"> <telerik:RadComboBox runat="server" ID="DeleteOption" OnSelectedIndexChanged="DeleteOption_SelectedIndexChanged" AutoPostBack="true" AppendDataBoundItems="true"> <Items> <telerik:RadComboBoxItem runat="server" Text="All" Value="All" /> <telerik:RadComboBoxItem runat="server" Text="Deleted" Value="Deleted" /> <telerik:RadComboBoxItem runat="server" Text="Not Deleted" Value="Not Deleted" /> </Items> </telerik:RadComboBox> </td> <td> <telerik:RadComboBox runat="server" ID="PendingSearch" OnSelectedIndexChanged="PendingSearch_SelectedIndexChanged" AutoPostBack="true" AppendDataBoundItems="true"> <Items> <telerik:RadComboBoxItem runat="server" Text="All" Value="All1" /> <telerik:RadComboBoxItem runat="server" Text="Pending" Value="Pending" /> <telerik:RadComboBoxItem runat="server" Text="Completed" Value="Completed" /> <telerik:RadComboBoxItem runat="server" Text="Certified" Value="Certified" /> </Items> </telerik:RadComboBox> </td> </tr> </table> </ItemTemplate> </telerik:RadToolBarButton> </Items> </telerik:RadToolBar> </CommandItemTemplate> <PagerStyle BackColor="#D8EBFC" Mode="NextPrevNumericAndAdvanced" /> <HeaderStyle CssClass="dataheadcolor" /> <RowIndicatorColumn> <HeaderStyle Width="20px"></HeaderStyle> </RowIndicatorColumn> <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings> <Columns> <telerik:GridEditCommandColumn ButtonType="ImageButton" HeaderStyle-Width="10px" UniqueName="EditButton" HeaderText="<%$ Resources:FormName, EDIT %>" /> <telerik:GridNumericColumn ReadOnly="true" DataField="workordid" HeaderText="workordid" SortExpression="workordid" UniqueName="workordid" MaxLength="6" HeaderStyle-Width="80px" Visible="false"> </telerik:GridNumericColumn> <telerik:GridBoundColumn DataField="workordno" HeaderText="Work Order No" SortExpression="workordno" UniqueName="workordno" FilterControlWidth="100px" HeaderStyle-Width="100px"> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="orderamount" SortExpression="orderamount" HeaderText="Order Amt. (S$)" DataField="orderamount" FilterControlWidth="100px" HeaderStyle-Width="100px" DataType="System.Decimal" DataFormatString="{0:C}"> <HeaderStyle Width="100px"></HeaderStyle> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="jointeramt" HeaderText="Jointer Amt. (S$)" SortExpression="jointeramt" UniqueName="jointeramt" FilterControlWidth="130px" HeaderStyle-Width="100px" DataType="System.Decimal" DataFormatString="{0:C}"> <HeaderStyle Width="100px"></HeaderStyle> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="survivoram" HeaderText="Surveyor Amt. (S$)" SortExpression="survivoram" UniqueName="survivoram" FilterControlWidth="100px" HeaderStyle-Width="110px" DataType="System.Decimal" DataFormatString="{0:C}"> <HeaderStyle Width="110px"></HeaderStyle> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="worklocatn" HeaderText="Work Location" SortExpression="worklocatn" UniqueName="worklocatn" FilterControlWidth="100px" HeaderStyle-Width="160px" DataType="System.String"> </telerik:GridBoundColumn> <telerik:GridDateTimeColumn DataField="commencement" HeaderText="Commencement" SortExpression="commencement" UniqueName="commencement" FilterControlWidth="40px" HeaderStyle-Width="40px" PickerType="DatePicker" DataFormatString="{0:dd/MM/yyyy}" DataType="System.DateTime"> </telerik:GridDateTimeColumn> <telerik:GridDateTimeColumn DataField="completion" HeaderText="Completion" SortExpression="completion" UniqueName="completion" FilterControlWidth="40px" HeaderStyle-Width="40px" PickerType="DatePicker" DataFormatString="{0:dd/MM/yyyy}" DataType="System.DateTime"> </telerik:GridDateTimeColumn> <telerik:GridBoundColumn DataField="Remarkss" HeaderText="Remarks" SortExpression="Remarkss" UniqueName="Remarkss" FilterControlWidth="100px" HeaderStyle-Width="160px" DataType="System.String"> </telerik:GridBoundColumn> <telerik:GridButtonColumn HeaderText="<%$ Resources:FormName, Delete %>" CommandName="Delete" ButtonType="ImageButton" UniqueName="DeleteColumn" CommandArgument="Child" ConfirmDialogType="RadWindow" ConfirmText="Are You Sure Want To Delete This Record?" ConfirmTitle="Delete Confirm" HeaderStyle-Width="10px" /> </Columns> <EditFormSettings CaptionFormatString="Create" EditFormType="Template" PopUpSettings-Width="825" PopUpSettings-Height="390"> <EditColumn UniqueName="EditCommandColumn1"> </EditColumn> <FormTemplate> <div style="margin-left: 3%; margin-right: 3%;"> <table width="100%"> <tr> <td style="height: 75px; width: 75%;"> <table style="float: right;"> <tr> <td> <asp:Label ID="Label3" runat="server" ForeColor="Red" Text="*" Width="1px"></asp:Label> <asp:Label ID="Label2" Text="Mandatory Field(s)" runat="server"></asp:Label> </td> </tr> </table> <br /> <br /> <section class="chunk"> <fieldset> <legend class="hd" > <span class="text"> <%= Resources.FormName.workorder%> </span> </legend> <div class="bd"> <table cellspacing="1" cellpadding="1" width="100%" border="0"> <tr> <td colspan="4"> <asp:TextBox Width="100px" ID="workordid" AutoCompleteType="Disabled" runat="server" Text='<%# Bind("workordid") %>' Visible="false"></asp:TextBox> </td> </tr> <tr> <td> <%--<asp:Label ID="Label1" runat="server" ForeColor="Red" Text="*" Width="1px"></asp:Label>--%> <asp:Label ID="Type" Text="Work Order No." runat="server" ></asp:Label> </td> <td> <%--<telerik:RadNumericTextBox Width="50%" ID="Workorderno" AutoCompleteType="Disabled" runat="server" FocusedStyle-BackColor="Lavender" MaxLength="8" onkeydown = "return (event.keyCode!=13);"> <NumberFormat GroupSeparator="" DecimalDigits="0" AllowRounding="true" KeepNotRoundedValue="false" /> <IncrementSettings InterceptMouseWheel="false" InterceptArrowKeys="false" /> </telerik:RadNumericTextBox>--%><%--CssClass="Capitalize1"--%> <telerik:RadTextBox Width="50%" ID="Workorderno" AutoCompleteType="Disabled" runat="server" FocusedStyle-BackColor="Lavender" MaxLength="16" onkeydown = "return (event.keyCode!=13);" Text='<%# Bind("workordno") %>' ></telerik:RadTextBox> </td> <td> <%--<asp:Label ID="Label4" runat="server" ForeColor="Red" Text="*" Width="1px"></asp:Label>--%> <asp:Label ID="ClientNam" Text="Work Order Date" runat="server"></asp:Label> </td> <td> <telerik:RadDatePicker ID="workorderdate" AutoCompleteType="Disabled" runat="server" Enabled="true" Width="50%"> <DateInput ID="DateInput1" DateFormat="dd/MM/yyyy" runat="server" ReadOnly="true"></DateInput> </telerik:RadDatePicker> </td> </tr> <tr> <td colspan="4" style="height: 5px;"> </td> </tr> <tr> <td> <asp:Label ID="StoreyN" Text="Contract No." runat="server"></asp:Label> </td> <td> <telerik:RadTextBox Width="50%" ID="ContractNo" runat="server" AutoCompleteType="Disabled" Text='9120211' FocusedStyle-BackColor="Lavender" Readonly="true" onkeydown = "return (event.keyCode!=13);" CssClass="Capitalize1"> </telerik:RadTextBox> </td> <td> <asp:Label ID="UnitN" Text="Client" runat="server"></asp:Label> </td> <td> <telerik:RadTextBox Width="95%" ID="Clientname" AutoCompleteType="Disabled" runat="server" FocusedStyle-BackColor="Lavender" Text="SP Powergrid Ltd" Readonly="true" MaxLength="30" onkeydown = "return (event.keyCode!=13);" CssClass="Capitalize1"></telerik:RadTextBox> </td> </tr> <tr> <td colspan="4" style="height: 5px;"> </td> </tr> <tr> <td> <asp:Label ID="MainCon" Text="Main Contractor" runat="server"></asp:Label> </td> <td> <telerik:RadTextBox Width="95%" ID="MainCont" AutoCompleteType="Disabled" runat="server" FocusedStyle-BackColor="Lavender" Text="Uniglory Construction Pte Ltd" Readonly="true" MaxLength="50" onkeydown = "return (event.keyCode!=13);" CssClass="Capitalize1"> </telerik:RadTextBox> </td> <td> <asp:Label ID="MainSubCon" Text="Main Sub Contractor" runat="server"></asp:Label> </td> <td> <telerik:RadTextBox Width="95%" ID="MainSubCont" AutoCompleteType="Disabled" runat="server" FocusedStyle-BackColor="Lavender" text="PowerCom Engineering Works Pte Ltd" Readonly="true" MaxLength="50" onkeydown = "return (event.keyCode!=13);" CssClass="Capitalize1"> </telerik:RadTextBox > </td> </tr> <tr> <td colspan="4" style="height: 5px;"> </td> </tr> <tr> <td> <asp:Label ID="workloc" Text="Work Location" runat="server"></asp:Label> </td> <td> <telerik:RadTextBox Width="95%" ID="WorlLocation" AutoCompleteType="Disabled" MaxLength="50" FocusedStyle-BackColor="Lavender" runat="server" onkeydown = "return (event.keyCode!=13);" CssClass="Capitalize1"> </telerik:RadTextBox> </td> <td> <asp:Label ID="ordamt" Text="Order Amount (S$)" runat="server"></asp:Label> </td> <td> <telerik:RadNumericTextBox Width="50%" ID="Orderamount" AutoCompleteType="Disabled" runat="server" FocusedStyle-BackColor="Lavender" MaxLength="8" onkeydown = "return (event.keyCode!=13);"> <NumberFormat GroupSeparator="," GroupSizes="3" DecimalDigits="2" AllowRounding="true" KeepNotRoundedValue="false" /> <IncrementSettings InterceptMouseWheel="false" InterceptArrowKeys="false" /> </telerik:RadNumericTextBox> </td> </tr> <tr> <td colspan="4" style="height: 5px;"> </td> </tr> <tr> <td> <asp:Label ID="commencemnet" Text="Commencement Date" runat="server"></asp:Label> </td> <td> <telerik:RadDatePicker ID="DateofCommencement" AutoCompleteType="Disabled" runat="server" Enabled="true" Width="50%"> <DateInput ID="DateInput2" DateFormat="dd/MM/yyyy" runat="server" ReadOnly="true" FocusedStyle-BackColor="Lavender" Width="50%"></DateInput> </telerik:RadDatePicker> </td> <td> <asp:Label ID="CompletionDat" Text="Completion Date" runat="server"></asp:Label> </td> <td> <telerik:RadDatePicker ID="DateofCompletion" AutoCompleteType="Disabled" runat="server" Enabled="true" Width="50%"> <DateInput ID="DateInput3" DateFormat="dd/MM/yyyy" runat="server" ReadOnly="true"></DateInput> </telerik:RadDatePicker> </td> </tr> <tr> <td colspan="4" style="height: 5px;"> </td> </tr> <tr> <td> <asp:Label ID="jointeramt" Text="Jointer Amount (S$)" runat="server"></asp:Label> </td> <td> <telerik:RadNumericTextBox Width="50%" ID="JointerAmount" AutoCompleteType="Disabled" runat="server" FocusedStyle-BackColor="Lavender" MaxLength="8" onkeydown = "return (event.keyCode!=13);"> <NumberFormat GroupSeparator="," GroupSizes="3" DecimalDigits="2" AllowRounding="true" KeepNotRoundedValue="false" /> <IncrementSettings InterceptMouseWheel="false" InterceptArrowKeys="false" /> </telerik:RadNumericTextBox> </td> <td> <asp:Label ID="surviour" Text="Surveyor Amount (S$)" runat="server"></asp:Label> </td> <td> <telerik:RadNumericTextBox Width="50%" ID="Surviouramount" AutoCompleteType="Disabled" runat="server" FocusedStyle-BackColor="Lavender" MaxLength="8" onkeydown = "return (event.keyCode!=13);"> <NumberFormat GroupSeparator="," GroupSizes="3" DecimalDigits="2" AllowRounding="true" KeepNotRoundedValue="false" /> <IncrementSettings InterceptMouseWheel="false" InterceptArrowKeys="false" /> </telerik:RadNumericTextBox> </td> </tr> <tr> <td colspan="4" style="height: 5px;"> </td> </tr> <tr> <td> <asp:Label runat="server" Text="Remarks"></asp:Label> </td> <td> <telerik:RadTextBox Width="95%" ID="Remark" AutoCompleteType="Disabled" MaxLength="500" FocusedStyle-BackColor="Lavender" runat="server" onkeydown = "return (event.keyCode!=13);" CssClass="Capitalize1"> </telerik:RadTextBox> </td> </tr> <tr> <td colspan="4" style="height: 5px;"> </td> </tr> </table> </div> </fieldset></section> </td> </tr> </table> <center> <table> <tr> <td> <telerik:RadButton ID="Button3" runat="server" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' Icon-PrimaryIconCssClass="rbOk"> </telerik:RadButton> <telerik:RadButton ID="Button4" runat="server" Text="Cancel" CausesValidation="false" CommandName="Cancel" Icon-PrimaryIconCssClass="rbCancel"> </telerik:RadButton> </td> </tr> </table> </center> </div> </FormTemplate> <PopUpSettings Modal="True"></PopUpSettings> </EditFormSettings> </MasterTableView> <ClientSettings> <Selecting AllowRowSelect="True" EnableDragToSelectRows="True" /> <ClientEvents OnFilterMenuShowing="filterMenuShowing" /> </ClientSettings> <FilterMenu OnClientShown="MenuShowing" /> </telerik:RadGrid> </td> </tr> </table></asp:Content>.aspx part
using System;using System.Web.UI;using System.Web.UI.WebControls;using Telerik.Web.UI;using DOSKMANAGEMENT.Models;using DoskContractServices;using System.Linq;using System.Collections;using System.Globalization;namespace DOSKMANAGEMENT.PMS{ public partial class workorder : System.Web.UI.Page { #region Public Variables DBClientADO oDBClientADO = new DBClientADO(); public static Int32 dupcount, maxva, dupcount1; public static Int32 Work = 0, Worklct = 0, OrdAmnt = 0, Workdate = 0, CommDate = 0, CoplDate = 0, DiiComm = 0, DifComp = 0, joinamnt = 0, survamnt = 0; public static string DeleteOption, PendingSearch; public static string projcode, usercode, formnam, compcode; #endregion protected void Page_Load(object sender, EventArgs e) { projcode = Convert.ToString(Session["projcode"]); usercode = Convert.ToString(Session["usercode"]); compcode = Convert.ToString(Session["compcode"]); if (!IsPostBack) { DeleteOption = "Not Deleted"; PendingSearch = "Pending"; } } protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e) { #region All if (DeleteOption == "All") { if (PendingSearch == "All1") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.compcode == compcode select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; } } else if (PendingSearch == "Pending") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.compcode == compcode && a.workstatus == "STR" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; } } else if (PendingSearch == "Completed") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.compcode == compcode && a.workstatus == "STC" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; } } else if (PendingSearch == "Certified") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.compcode == compcode && a.workstatus != "STR" && a.workstatus != "STC" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; } } } #endregion #region Deleted else if (DeleteOption == "Deleted") { if (PendingSearch == "All1") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status == "DEL" && a.compcode == compcode select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; } } else if (PendingSearch == "Pending") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status == "DEL" && a.compcode == compcode && a.workstatus == "STR" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; } } else if (PendingSearch == "Completed") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status == "DEL" && a.compcode == compcode && a.workstatus == "STC" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; } } else if (PendingSearch == "Certified") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status == "DEL" && a.compcode == compcode && a.workstatus != "STR" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; } } } #endregion #region Not Deleted else if (DeleteOption == "Not Deleted") { if (PendingSearch == "All1") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status != "DEL" && a.compcode == compcode select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; } } else if (PendingSearch == "Pending") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status != "DEL" && a.compcode == compcode && a.workstatus == "STR" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; } } else if (PendingSearch == "Completed") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status != "DEL" && a.compcode == compcode && a.workstatus == "STC" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; } } else if (PendingSearch == "Certified") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status != "DEL" && a.compcode == compcode && a.workstatus != "STR" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; } } } #endregion } protected void RadToolBar1_ButtonClick(object sender, RadToolBarEventArgs e) { } protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e) { dsworkorder oworkorder = new dsworkorder(); if (e.CommandName == RadGrid.PerformInsertCommandName) { if (e.Item is GridEditFormItem) { GridEditFormItem item = (GridEditFormItem)e.Item; RadTextBox Workorderno = (RadTextBox)item.FindControl("Workorderno"); RadDatePicker workorderdate = (RadDatePicker)item.FindControl("workorderdate"); RadTextBox ContractNo = (RadTextBox)item.FindControl("ContractNo"); RadTextBox Clientname = (RadTextBox)item.FindControl("Clientname"); RadTextBox MainCont = (RadTextBox)item.FindControl("MainCont"); RadTextBox MainSubCont = (RadTextBox)item.FindControl("MainSubCont"); RadTextBox WorklLocation = (RadTextBox)item.FindControl("WorlLocation"); RadDatePicker DateofCommencement = (RadDatePicker)item.FindControl("DateofCommencement"); RadDatePicker DateofCompletion = (RadDatePicker)item.FindControl("DateofCompletion"); RadNumericTextBox Orderamount = (RadNumericTextBox)item.FindControl("Orderamount"); RadNumericTextBox JointerAmount = (RadNumericTextBox)item.FindControl("JointerAmount"); RadNumericTextBox Surviouramount = (RadNumericTextBox)item.FindControl("Surviouramount"); RadTextBox Remark = (RadTextBox)item.FindControl("Remark"); oworkorder.workordno = Workorderno.Text; oworkorder.workordat = workorderdate.SelectedDate; oworkorder.contractno = System.Globalization.CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(ContractNo.Text); oworkorder.clientnam = System.Globalization.CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(Clientname.Text); oworkorder.maincontr = System.Globalization.CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(MainCont.Text); oworkorder.mainsubcon = System.Globalization.CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(MainSubCont.Text); oworkorder.worklocatn = System.Globalization.CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(WorklLocation.Text); oworkorder.commencement = DateofCommencement.SelectedDate; oworkorder.completion = DateofCompletion.SelectedDate; if (Orderamount.Text != "") oworkorder.orderamount = Convert.ToDecimal(Orderamount.Text); else oworkorder.orderamount = 0; if (JointerAmount.Text != "") oworkorder.jointeramt = Convert.ToDecimal(JointerAmount.Text); else oworkorder.jointeramt = 0; if (Surviouramount.Text != "") oworkorder.survivoram = Convert.ToDecimal(Surviouramount.Text); else oworkorder.survivoram = 0; oworkorder.status = "ADD"; oworkorder.oprstamp = usercode; oworkorder.timstamp = DateTime.Now; oworkorder.compcode = compcode; oworkorder.workstatus = "STR"; oworkorder.cerfinlamot = null; oworkorder.cerjoinamot = null; oworkorder.cersurvamot = null; oworkorder.actcompletion = null; oworkorder.Remarkss = Remark.Text; #region client code generation //using (var db = new DoskContractServicesDataContext(Globals.strcon)) //{ // var orgreqfinal = (from a in db.dsdatamasters // select new { a.clientcode, a.clientname, a.singapore }).tolist(); // dupcount = orgreqfinal.count(); // var maxvalue = (from a in db.dsdatamasters // select new { a.dataid }).tolist(); // var query = from p in db.dsdatamasters // select p.dataid; // if (query.count() > 1) // maxva = convert.toint16(query.max()) + 1; // else // maxva = 1; //} #endregion #region CheckNull if (oworkorder.workordno == "") { Work = 1; RadAjaxManager1.Alert(" Enter Work Order No"); Workorderno.Focus(); } else { Work = 0; } if (oworkorder.worklocatn == "") { Worklct = 1; RadAjaxManager1.Alert(" Enter Work Location"); WorklLocation.Focus(); } else { Worklct = 0; } if (oworkorder.orderamount <= 0) { OrdAmnt = 1; RadAjaxManager1.Alert(" Enter Order Amount "); Orderamount.Focus(); } else { OrdAmnt = 0; } if (oworkorder.jointeramt < 0) { joinamnt = 1; RadAjaxManager1.Alert(" Enter Jointer Amount "); JointerAmount.Focus(); } else { joinamnt = 0; } if (oworkorder.survivoram < 0) { survamnt = 1; RadAjaxManager1.Alert(" Enter Surveyor Amount "); Surviouramount.Focus(); } else { survamnt = 0; } if (workorderdate.IsEmpty) { Workdate = 1; RadAjaxManager1.Alert(" Select The Work Order Date"); } else { Workdate = 0; } if (DateofCommencement.IsEmpty) { CommDate = 1; RadAjaxManager1.Alert(" Select The Date Commencement"); } else { CommDate = 0; } if (DateofCompletion.IsEmpty) { CoplDate = 1; RadAjaxManager1.Alert(" Select The Date Completion"); } else { CoplDate = 0; } if (DateofCommencement.SelectedDate < workorderdate.SelectedDate) { DiiComm = 1; RadAjaxManager1.Alert(" Commencement Date should be greater than Work Order Date"); } else { DiiComm = 0; } if (DateofCompletion.SelectedDate < DateofCommencement.SelectedDate) { DifComp = 1; RadAjaxManager1.Alert(" Completion Date should be greater than Commencement Date"); } else { DifComp = 0; } #endregion using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var orgreqfinal = (from a in db.dsworkorders where a.workordno == Workorderno.Text && a.status != "del" select new { a.workordno, a.clientnam, a.contractno }).ToList(); dupcount1 = orgreqfinal.Count(); } if (dupcount1 == 0) { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var orgreqfinal = (from a in db.dsworkorders where a.workordno == Workorderno.Text && a.status != "del" select new { a.workordno, a.clientnam, a.contractno }).ToList(); dupcount = orgreqfinal.Count(); } if (dupcount > 0) { RadAjaxManager1.Alert(" Already given for this Work Order \n" + " Work Order : " + oworkorder.workordno); } else { if (oworkorder.workordno != "") { try { if (Work == 0 && OrdAmnt == 0 && Workdate == 0 && CommDate == 0 && CoplDate == 0 && Worklct == 0 && DiiComm == 0 && DifComp == 0 && survamnt == 0 && joinamnt == 0) { DbClient.Insert<dsworkorder>(oworkorder); RadGrid1.Rebind(); RadAjaxManager1.Alert(" data successfully saved \n" + " Work Order : " + oworkorder.workordno); RadGrid1.MasterTableView.IsItemInserted = false; RadGrid1.DataBind(); e.Canceled = true; } } catch (Exception ex) { RadGrid1.Controls.Add(new LiteralControl("unable to insert employee. reason: " + ex.Message)); } } else { RadAjaxManager1.Alert("Enter the Work Order No"); } } } else { RadAjaxManager1.Alert("Work Order No Is Already Entered"); } } } else if (e.CommandName == RadGrid.UpdateCommandName) { GridEditableItem editedItem = e.Item as GridEditableItem; if (e.Item is GridEditFormItem) { GridEditFormItem item = (GridEditFormItem)e.Item; TextBox workordid = (TextBox)item.FindControl("workordid"); RadTextBox Workorderno = (RadTextBox)item.FindControl("Workorderno"); RadDatePicker workorderdate = (RadDatePicker)item.FindControl("workorderdate"); RadTextBox ContractNo = (RadTextBox)item.FindControl("ContractNo"); RadTextBox Clientname = (RadTextBox)item.FindControl("Clientname"); RadTextBox MainCont = (RadTextBox)item.FindControl("MainCont"); RadTextBox MainSubCont = (RadTextBox)item.FindControl("MainSubCont"); RadTextBox WorklLocation = (RadTextBox)item.FindControl("WorlLocation"); RadDatePicker DateofCommencement = (RadDatePicker)item.FindControl("DateofCommencement"); RadDatePicker DateofCompletion = (RadDatePicker)item.FindControl("DateofCompletion"); RadNumericTextBox Orderamount = (RadNumericTextBox)item.FindControl("Orderamount"); RadNumericTextBox JointerAmount = (RadNumericTextBox)item.FindControl("JointerAmount"); RadNumericTextBox Surviouramount = (RadNumericTextBox)item.FindControl("Surviouramount"); RadTextBox Remark = (RadTextBox)item.FindControl("Remark"); oworkorder.workordid = Convert.ToInt32(workordid.Text); oworkorder.workordno = Workorderno.Text; oworkorder.workordat = workorderdate.SelectedDate; oworkorder.contractno = System.Globalization.CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(ContractNo.Text); oworkorder.clientnam = System.Globalization.CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(Clientname.Text); oworkorder.maincontr = System.Globalization.CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(MainCont.Text); oworkorder.mainsubcon = System.Globalization.CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(MainSubCont.Text); oworkorder.worklocatn = System.Globalization.CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(WorklLocation.Text); oworkorder.commencement = DateofCommencement.SelectedDate; oworkorder.completion = DateofCompletion.SelectedDate; if (Orderamount.Text != "") oworkorder.orderamount = Convert.ToDecimal(Orderamount.Text); else oworkorder.orderamount = 0; if (JointerAmount.Text != "") oworkorder.jointeramt = Convert.ToDecimal(JointerAmount.Text); else oworkorder.jointeramt = 0; if (Surviouramount.Text != "") oworkorder.survivoram = Convert.ToDecimal(Surviouramount.Text); else oworkorder.survivoram = 0; oworkorder.status = "MOD"; oworkorder.oprstamp = usercode; oworkorder.timstamp = DateTime.Now; oworkorder.compcode = compcode; oworkorder.workstatus = "STR"; oworkorder.cerfinlamot = null; oworkorder.cerjoinamot = null; oworkorder.cersurvamot = null; oworkorder.actcompletion = null; oworkorder.Remarkss = Remark.Text; #region Checknull if (oworkorder.workordno == "") { Work = 1; RadAjaxManager1.Alert(" Enter Work Order No"); Workorderno.Focus(); } else { Work = 0; } if (oworkorder.worklocatn == "") { Worklct = 1; RadAjaxManager1.Alert(" Enter Work Location"); WorklLocation.Focus(); } else { Worklct = 0; } if (oworkorder.orderamount <= 0) { OrdAmnt = 1; RadAjaxManager1.Alert(" Enter Order Amount "); Orderamount.Focus(); } else { OrdAmnt = 0; } if (oworkorder.jointeramt < 0) { joinamnt = 1; RadAjaxManager1.Alert(" Enter Jointer Amount "); JointerAmount.Focus(); } else { joinamnt = 0; } if (oworkorder.survivoram < 0) { survamnt = 1; RadAjaxManager1.Alert(" Enter Surveyor Amount "); Surviouramount.Focus(); } else { survamnt = 0; } if (workorderdate.IsEmpty) { Workdate = 1; RadAjaxManager1.Alert(" Select The Work Order Date"); } else { Workdate = 0; } if (DateofCommencement.IsEmpty) { CommDate = 1; RadAjaxManager1.Alert(" Select The Date Commencement"); } else { CommDate = 0; } if (DateofCompletion.IsEmpty) { CoplDate = 1; RadAjaxManager1.Alert(" Select The Date Completion"); } else { CoplDate = 0; } if (DateofCommencement.SelectedDate < workorderdate.SelectedDate) { DiiComm = 1; RadAjaxManager1.Alert(" Commencement Date should be greater than Work Order Date"); } else { DiiComm = 0; } if (DateofCompletion.SelectedDate < DateofCommencement.SelectedDate) { DifComp = 1; RadAjaxManager1.Alert(" Completion Date should be greater than Commencement Date"); } else { DifComp = 0; } #endregion using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var orgreqfinal = (from a in db.dsworkorders where a.workordno == Workorderno.Text && a.status != "del" select new { a.workordno, a.clientnam, a.contractno }).ToList(); dupcount1 = orgreqfinal.Count(); } if (dupcount1 == 1) { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var orgreqfinal = (from a in db.dsworkorders where a.workordid == oworkorder.workordid select new { a.status, a.workstatus }).ToList(); string statuschk = orgreqfinal[0].status.ToString(); if (statuschk != "DEL") { if (oworkorder.workordno != "") { try { if (Work == 0 && OrdAmnt == 0 && Workdate == 0 && CommDate == 0 && CoplDate == 0 && Worklct == 0 && DiiComm == 0 && DifComp == 0 && survamnt == 0 && joinamnt == 0) { DbClient.Update<dsworkorder>(oworkorder, "workordid==" + oworkorder.workordid); RadGrid1.Rebind(); RadAjaxManager1.Alert(" Data Successfully Modified \n" + " Work Order No. : " + oworkorder.workordno); RadGrid1.EditIndexes.Clear(); RadGrid1.DataBind(); e.Canceled = true; } } catch (Exception ex) { RadGrid1.Controls.Add(new LiteralControl("Unable to update Employee. Reason: " + ex.Message)); } } else { RadAjaxManager1.Alert("Select Data Type"); } } else { RadAjaxManager1.Alert("This Data is Deleted Data Edit is Not Possible"); } } } } } else if (e.CommandName == RadGrid.DeleteCommandName) { GridDataItem item = (GridDataItem)e.Item; string workid = item["workordid"].Text; string workordeno = item["workordno"].Text; //decimal contracno = item["contractno"].Text; using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var orgreqfinal = (from a in db.dsworkorders where a.workordid == Convert.ToInt16(workid) select new { a.status, a.workstatus }).ToList(); string statuschk = orgreqfinal[0].status.ToString(); string Workchk = orgreqfinal[0].workstatus.ToString(); if (statuschk != "DEL" && Workchk == "STR") { try { string preference = ("UPDATE dsworkorder SET status = 'DEL' ,WORKSTATUS = 'STR' , oprstamp = '" + usercode + "' where workordid = " + workid); long RecordAffect = oDBClientADO.ExecuteSql(preference); RadGrid1.Rebind(); RadAjaxManager1.Alert(" Data Successfully Deleted \n" + " Work Order No. : " + workordeno); } catch (Exception ex) { RadGrid1.Controls.Add(new LiteralControl("Unable to delete Id. Reason: " + ex.Message)); e.Canceled = true; } } else { RadAjaxManager1.Alert("This Data is Already Deleted Or Certification Over "); } } } } protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) { if (e.Item.OwnerTableView.IsItemInserted) { RadGrid1.MasterTableView.EditFormSettings.CaptionFormatString = "Create"; } else { RadGrid1.MasterTableView.EditFormSettings.CaptionFormatString = "Edit"; } if (e.Item is GridEditFormItem && e.Item.IsInEditMode) { if (e.Item.OwnerTableView.IsItemInserted) { GridEditFormItem item = (GridEditFormItem)e.Item; RadTextBox workordno = (RadTextBox)item.FindControl("Workorderno"); RadDatePicker dtcommencement1 = item.FindControl("DateofCommencement") as RadDatePicker; RadDatePicker dtcompletion = item.FindControl("DateofCompletion") as RadDatePicker; workordno.Focus(); } else { GridEditFormItem item = (GridEditFormItem)e.Item; RadTextBox workordno = (RadTextBox)item.FindControl("Workorderno"); RadDatePicker workorderdate = item.FindControl("workorderdate") as RadDatePicker; RadTextBox ContractNo = (RadTextBox)item.FindControl("ContractNo"); RadTextBox Clientname = (RadTextBox)item.FindControl("Clientname"); RadTextBox MainCont = (RadTextBox)item.FindControl("MainCont"); RadTextBox MainSubCont = (RadTextBox)item.FindControl("MainSubCont"); RadTextBox WorklLocation = (RadTextBox)item.FindControl("WorlLocation"); RadDatePicker dtcommencement1 = item.FindControl("DateofCommencement") as RadDatePicker; RadDatePicker dtcompletion = item.FindControl("DateofCompletion") as RadDatePicker; RadNumericTextBox Orderamount = item.FindControl("Orderamount") as RadNumericTextBox; RadNumericTextBox JointerAmount = item.FindControl("JointerAmount") as RadNumericTextBox; RadNumericTextBox Surviouramount = item.FindControl("Surviouramount") as RadNumericTextBox; RadTextBox Remark = (RadTextBox)item.FindControl("Remark"); workordno.ReadOnly = true; ContractNo.Focus(); if (e.Item.IsInEditMode) { GridEditableItem editedItem = e.Item as GridEditableItem; GridEditFormItem editForm = (GridEditFormItem)e.Item; string workid = editForm["workordid"].Text; if (workid != " ") { if (Convert.ToInt32(workid) > 0) { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var checkwork = (from a in db.dsworkorders where a.workordid == Convert.ToInt32(workid) select new { a.workstatus }).ToList(); string workchk = checkwork[0].workstatus.ToString(); if (workchk == "STR") { var Projtext = (from a in db.dsworkorders where a.workordid == Convert.ToInt32(workid) && a.workstatus == "STR" select new { a.workordid, a.workordno, a.workordat, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); workordno.Text = Projtext[0].workordno.ToString(); workorderdate.SelectedDate = Projtext[0].workordat; ContractNo.Text = Projtext[0].contractno.ToString(); Clientname.Text = Projtext[0].clientnam.ToString(); MainCont.Text = Projtext[0].maincontr.ToString(); MainSubCont.Text = Projtext[0].mainsubcon.ToString(); WorklLocation.Text = Projtext[0].worklocatn.ToString(); dtcommencement1.SelectedDate = Projtext[0].commencement; dtcompletion.SelectedDate = Projtext[0].completion; Orderamount.Text = Projtext[0].orderamount.ToString(); JointerAmount.Text = Projtext[0].jointeramt.ToString(); Surviouramount.Text = Projtext[0].survivoram.ToString(); Remark.Text = Projtext[0].Remarkss.ToString(); } else { RadGrid1.EditIndexes.Clear(); RadGrid1.DataBind(); RadAjaxManager1.Alert("This Work Order Already Certification is Done Cannot Be Edited"); e.Canceled = true; } } } } } } } } protected void RadGrid1_PreRender(object sender, EventArgs e) { GridCommandItem commandItem = RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0] as GridCommandItem; RadToolBar toolBar = commandItem.FindControl("RadToolBar1") as RadToolBar; RadToolBarItem textItem = toolBar.FindItemByValue("HeaderDisplay"); RadComboBox Comobovalue = (RadComboBox)textItem.FindControl("DeleteOption"); RadComboBox Pending = (RadComboBox)textItem.FindControl("PendingSearch"); GridHeaderItem item = RadGrid1.MasterTableView.GetItems(GridItemType.Header)[0] as GridHeaderItem; Comobovalue.SelectedValue = DeleteOption; Pending.SelectedValue = PendingSearch; //foreach (GridDataItem item1 in RadGrid1.Items) //{ // RadButton btn = (RadButton)item1.FindControl("Work"); // if (PendingSearch == "Completed" || PendingSearch == "Pending") // { // item["WorkNoAss"].Visible = true; // btn.Visible = true; // } // else // { // //item["WorkNoAss"].Visible = false; // item["WorkNoAss"].Text = ""; // btn.Visible = false; // } //} } protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridEditableItem && e.Item.IsInEditMode) { RadDatePicker workorderdate = (RadDatePicker)e.Item.FindControl("workorderdate"); RadDatePicker DateofCommencement = (RadDatePicker)e.Item.FindControl("DateofCommencement"); RadDatePicker DateofCompletion = (RadDatePicker)e.Item.FindControl("DateofCompletion"); RadNumericTextBox jointeramt = (RadNumericTextBox)e.Item.FindControl("JointerAmount"); RadNumericTextBox survivoram = (RadNumericTextBox)e.Item.FindControl("Surviouramount"); DateofCommencement.ClientEvents.OnDateSelected = "function (button,button1,args){changeEndDate('" + workorderdate.ClientID + "','" + DateofCommencement.ClientID + "','0');}"; DateofCompletion.ClientEvents.OnDateSelected = "function (button,button1,args){changeEndDate('" + DateofCommencement.ClientID + "','" + DateofCompletion.ClientID + "','1');}"; survivoram.Attributes.Add("onblur", string.Format("Surviour('{0}');", survivoram.ClientID)); jointeramt.Attributes.Add("onblur", string.Format("Jointer('{0}');", jointeramt.ClientID)); } } protected void DeleteOption_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e) { GridCommandItem commandItem = RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0] as GridCommandItem; RadToolBar toolBar = commandItem.FindControl("RadToolBar1") as RadToolBar; RadToolBarItem textItem = toolBar.FindItemByValue("HeaderDisplay"); RadComboBox Comobovalue = (RadComboBox)textItem.FindControl("DeleteOption"); RadComboBox Pending = (RadComboBox)textItem.FindControl("PendingSearch"); DeleteOption = Comobovalue.SelectedValue; PendingSearch = Pending.SelectedValue; #region ALL if (DeleteOption == "All") { if (PendingSearch == "All1") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } else if (PendingSearch == "Pending") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.workstatus == "STR" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } else if (PendingSearch == "Completed") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.compcode == compcode && a.workstatus == "STC" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } else if (PendingSearch == "Certified") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.workstatus != "STR" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } } #endregion #region DELETED else if (DeleteOption == "Deleted") { if (PendingSearch == "All1") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status == "DEL" && a.compcode == compcode select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } else if (PendingSearch == "Pending") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status == "DEL" && a.compcode == compcode && a.workstatus == "STR" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } else if (PendingSearch == "Completed") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status == "DEL" && a.compcode == compcode && a.workstatus == "STC" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } else if (PendingSearch == "Certified") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status == "DEL" && a.compcode == compcode && a.workstatus != "STR" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } } #endregion #region NOT DELETED else if (DeleteOption == "Not Deleted") { if (PendingSearch == "All1") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status != "DEL" && a.compcode == compcode select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } else if (PendingSearch == "Pending") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status != "DEL" && a.compcode == compcode && a.workstatus == "STR" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } else if (PendingSearch == "Completed") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status != "DEL" && a.compcode == compcode && a.workstatus == "STC" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } else if (PendingSearch == "Certified") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status != "DEL" && a.compcode == compcode && a.workstatus != "STR" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } } #endregion } protected void PendingSearch_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e) { GridCommandItem commandItem = RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0] as GridCommandItem; RadToolBar toolBar = commandItem.FindControl("RadToolBar1") as RadToolBar; RadToolBarItem textItem = toolBar.FindItemByValue("HeaderDisplay"); RadComboBox Comobovalue = (RadComboBox)textItem.FindControl("DeleteOption"); RadComboBox Pending = (RadComboBox)textItem.FindControl("PendingSearch"); DeleteOption = Comobovalue.SelectedValue; PendingSearch = Pending.SelectedValue; #region ALL if (DeleteOption == "All") { if (PendingSearch == "All1") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } else if (PendingSearch == "Pending") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.workstatus == "STR" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } else if (PendingSearch == "Completed") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.compcode == compcode && a.workstatus == "STC" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } else if (PendingSearch == "Certified") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.workstatus != "STR" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } } #endregion #region DELETED else if (DeleteOption == "Deleted") { if (PendingSearch == "All1") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status == "DEL" && a.compcode == compcode select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } else if (PendingSearch == "Pending") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status == "DEL" && a.compcode == compcode && a.workstatus == "STR" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } else if (PendingSearch == "Completed") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status == "DEL" && a.compcode == compcode && a.workstatus == "STC" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } else if (PendingSearch == "Certified") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status == "DEL" && a.compcode == compcode && a.workstatus != "STR" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } } #endregion #region NOT DELETED else if (DeleteOption == "Not Deleted") { if (PendingSearch == "All1") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status != "DEL" && a.compcode == compcode select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } else if (PendingSearch == "Pending") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status != "DEL" && a.compcode == compcode && a.workstatus == "STR" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } else if (PendingSearch == "Completed") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status != "DEL" && a.compcode == compcode && a.workstatus == "STC" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } else if (PendingSearch == "Certified") { using (var db = new DoskContractServicesDataContext(Globals.strCon)) { var result = (from a in db.dsworkorders where a.status != "DEL" && a.compcode == compcode && a.workstatus != "STR" select new { a.workordid, a.workordno, a.contractno, a.clientnam, a.maincontr, a.mainsubcon, a.worklocatn, a.commencement, a.completion, a.orderamount, a.jointeramt, a.survivoram, a.Remarkss }).ToList(); RadGrid1.DataSource = result; RadGrid1.Rebind(); } } } #endregion } }}.cs page
that is my coding side
thanks advance,
Mohamed