Here is the entire page.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Inventory.aspx.cs" Inherits="Inventory" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>FormPanel - Coolite Toolkit Examples</title>
<script runat="server">
private bool cancel;
private string message;
protected void Store1_AfterRecordInserted(object sender, AfterRecordInsertedEventArgs e)
{
//The deleted and updated records confirms automatic (depending AffectedRows field)
//But you can override this in AfterRecordUpdated and AfterRecordDeleted event
//For insert we should set new id for refresh on client
//If we don't set new id then old id will be used
if (e.Confirmation.Confirm && !string.IsNullOrEmpty(insertedValue))
{
e.Confirmation.ConfirmRecord(insertedValue);
insertedValue = "";
}
}
private string insertedValue;
protected void SqlDataSource1_Inserted(object sender, SqlDataSourceStatusEventArgs e)
{
//use e.AffectedRows for ensure success action. The store read this value and set predefined Confirm depend on e.AffectedRows
//The Confirm can be granted or denied in OnRecord....ed event
insertedValue = e.Command.Parameters["@newId"].Value != null
? e.Command.Parameters["@newId"].Value.ToString()
: "";
}
protected void Store1_AfterAjaxEvent(object sender, AfterAjaxEventArgs e)
{
if (e.Response.Success)
{
// set to .Success to false if we want to return a failure
e.Response.Success = !cancel;
e.Response.Msg = message;
}
}
protected void Store1_BeforeAjaxEvent(object sender, BeforeAjaxEventArgs e)
{
string emulError = e.Parameters["EmulateError"];
if (emulError == "1")
{
throw new Exception("Emulating error");
}
}
protected void Store1_RefershData(object sender, StoreRefreshDataEventArgs e)
{
this.Store1.DataBind();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Debug" />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:CMMS_Connection %>"
DeleteCommand="DELETE FROM TblInventoryMaster WHERE (ItemID = @ItemID)"
InsertCommand="INSERT INTO TblInventoryMaster
(PropertyClassID
,ItemName
,Nomenclature
,SerialNumber
,Model
,PartNumber
,StockNumber
,UnitofMeasure
,Manufacturer
,LocationBldg
,LocationRoom
,LocationOther
,Warranty
,SoftwareLicenseExpireDate
,PurchaseOrderNumber
,ItemCost
,PurchaseOrderDate
,ExpectedReceiveDate
,RecieveDate
,DisposalDate
,ShelfLifeCide
,PurchaseOrderStatusID
,WSS_DocumentRepository)
VALUES
(@PropertyClassID
,@ItemName
,@Nomenclature
,@SerialNumber
,@Model
,@PartNumber
,@StockNumber
,@UnitofMeasure
,@Manufacturer
,@LocationBldg
,@LocationRoom
,@LocationOther
,@Warranty
,@SoftwareLicenseExpireDate
,@PurchaseOrderNumber
,@ItemCost
,@PurchaseOrderDate
,@ExpectedReceiveDate
,@RecieveDate
,@DisposalDate
,@ShelfLifeCide
,@PurchaseOrderStatusID
,@WSS_DocumentRepository);
SELECT @newId = @@Identity;"
SelectCommand="SELECT
ItemID,
PropertyClassID
,ItemName
,Nomenclature
,SerialNumber
,Model
,PartNumber
,StockNumber
,UnitofMeasure
,Manufacturer
,LocationBldg
,LocationRoom
,LocationOther
,Warranty
,SoftwareLicenseExpireDate
,PurchaseOrderNumber
,ItemCost
,PurchaseOrderDate
,ExpectedReceiveDate
,RecieveDate
,DisposalDate
,ShelfLifeCide
,PurchaseOrderStatusID
,WSS_DocumentRepository
FROM TblInventoryMaster"
UpdateCommand="UPDATE TblInventoryMaster
SET PropertyClassID = @PropertyClassID
,ItemName = @ItemName
,Nomenclature = @Nomenclature
,SerialNumber = @SerialNumber
,Model = @Model
,PartNumber = @PartNumber
,StockNumber = @StockNumber
,UnitofMeasure = @UnitofMeasure
,Manufacturer = @Manufacturer
,LocationBldg = @LocationBldg
,LocationRoom = @LocationRoom
,LocationOther = @LocationOther
,Warranty = @Warranty
,SoftwareLicenseExpireDate = @SoftwareLicenseExpireDate
,PurchaseOrderNumber = @PurchaseOrderNumber
,ItemCost = @ItemCost
,PurchaseOrderDate = @PurchaseOrderDate
,ExpectedReceiveDate = @ExpectedReceiveDate
,RecieveDate = @RecieveDate
,DisposalDate = @DisposalDate
,ShelfLifeCide = @ShelfLifeCide
,PurchaseOrderStatusID = @PurchaseOrderStatusID
,WSS_DocumentRepository = @WSS_DocumentRepository
WHERE (ItemID = @ItemID)"
OnInserted="SqlDataSource1_Inserted">
<DeleteParameters>
<asp:Parameter Name="ItemID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="PropertyClassID" Type="Int32" />
<asp:Parameter Name="ItemName" Type="String" />
<asp:Parameter Name="Nomenclature" Type="String" />
<asp:Parameter Name="SerialNumber" Type="String" />
<asp:Parameter Name="Model" Type="String" />
<asp:Parameter Name="PartNumber" Type="String" />
<asp:Parameter Name="StockNumber" Type="String" />
<asp:Parameter Name="UnitofMeasure" Type="String" />
<asp:Parameter Name="Manufacturer" Type="String" />
<asp:Parameter Name="LocationBldg" Type="String" />
<asp:Parameter Name="LocationRoom" Type="String" />
<asp:Parameter Name="LocationOther" Type="String" />
<asp:Parameter Name="Warranty" Type="String" />
<asp:Parameter Name="SoftwareLicenseExpireDate" Type="String" />
<asp:Parameter Name="PurchaseOrderNumber" Type="String" />
<asp:Parameter Name="ItemCost" Type="String" />
<asp:Parameter Name="PurchaseOrderDate" Type="String" />
<asp:Parameter Name="ExpectedReceiveDate" Type="String" />
<asp:Parameter Name="RecieveDate" Type="String" />
<asp:Parameter Name="DisposalDate" Type="String" />
<asp:Parameter Name="ShelfLifeCide" Type="String" />
<asp:Parameter Name="PurchaseOrderStatusID" Type="Int32" />
<asp:Parameter Name="WSS_DocumentRepository" Type="String" />
<asp:Parameter Name="ItemID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="PropertyClassID" Type="Int32" />
<asp:Parameter Name="ItemName" Type="String" />
<asp:Parameter Name="Nomenclature" Type="String" />
<asp:Parameter Name="SerialNumber" Type="String" />
<asp:Parameter Name="Model" Type="String" />
<asp:Parameter Name="PartNumber" Type="String" />
<asp:Parameter Name="StockNumber" Type="String" />
<asp:Parameter Name="UnitofMeasure" Type="String" />
<asp:Parameter Name="Manufacturer" Type="String" />
<asp:Parameter Name="LocationBldg" Type="String" />
<asp:Parameter Name="LocationRoom" Type="String" />
<asp:Parameter Name="LocationOther" Type="String" />
<asp:Parameter Name="Warranty" Type="String" />
<asp:Parameter Name="SoftwareLicenseExpireDate" Type="String" />
<asp:Parameter Name="PurchaseOrderNumber" Type="String" />
<asp:Parameter Name="ItemCost" Type="String" />
<asp:Parameter Name="PurchaseOrderDate" Type="String" />
<asp:Parameter Name="ExpectedReceiveDate" Type="String" />
<asp:Parameter Name="RecieveDate" Type="String" />
<asp:Parameter Name="DisposalDate" Type="String" />
<asp:Parameter Name="ShelfLifeCide" Type="String" />
<asp:Parameter Name="PurchaseOrderStatusID" Type="Int32" />
<asp:Parameter Name="WSS_DocumentRepository" Type="String" />
<asp:Parameter Direction="Output" Name="newId" Type="Int32" />
</InsertParameters>
</asp:SqlDataSource>
<ext:Store ID="Store1" runat="server"
DataSourceID="SqlDataSource1"
OnAfterAjaxEvent="Store1_AfterAjaxEvent"
OnBeforeAjaxEvent="Store1_BeforeAjaxEvent"
UseIdConfirmation="true"
OnAfterRecordInserted="Store1_AfterRecordInserted"
OnRefreshData="Store1_RefershData">
<Reader>
<ext:JsonReader ReaderID="ItemID">
<Fields>
<ext:RecordField Name="PropertyClassID" />
<ext:RecordField Name="ItemName" />
<ext:RecordField Name="Nomenclature" />
<ext:RecordField Name="SerialNumber" />
<ext:RecordField Name="Model" />
<ext:RecordField Name="PartNumber" />
<ext:RecordField Name="StockNumber" />
<ext:RecordField Name="UnitofMeasure" />
<ext:RecordField Name="Manufacturer" />
<ext:RecordField Name="LocationBldg" />
<ext:RecordField Name="LocationRoom" />
<ext:RecordField Name="LocationOther" />
<ext:RecordField Name="Warranty" />
<ext:RecordField Name="SoftwareLicenseExpireDate" Type="Date" />
<ext:RecordField Name="PurchaseOrderNumber" />
<ext:RecordField Name="ItemCost" />
<ext:RecordField Name="PurchaseOrderDate" Type="Date" />
<ext:RecordField Name="ExpectedReceiveDate" Type="Date" />
<ext:RecordField Name="RecieveDate" Type="Date" />
<ext:RecordField Name="DisposalDate" Type="Date" />
<ext:RecordField Name="ShelfLifeCide" />
<ext:RecordField Name="PurchaseOrderStatusID" />
<ext:RecordField Name="WSS_DocumentRepository" />
</Fields>
</ext:JsonReader>
</Reader>
<SortInfo Field="ItemName" Direction="ASC" />
<Listeners>
<LoadException Handler="Ext.Msg.alert('Status - Load failed', e.message || e )" />
<CommitFailed Handler="Ext.Msg.alert('Status - Commit failed', 'Reason: ' + msg)" />
<SaveException Handler="Ext.Msg.alert('Status - Save failed', e.message || e)" />
<CommitDone Handler="Ext.Msg.alert('Status - Commit', 'The data successfully saved');" />
</Listeners>
</ext:Store>
<ext:Panel ID="Panel1" runat="server" Width="800" Height="800">
<Body>
<ext:BorderLayout ID="BorderLayout1" runat="server">
<West>
<ext:GridPanel
ID="GridPanel1"
runat="server"
StoreID="Store1"
StripeRows="true"
Title="Grid"
TrackMouseOver="true"
Width="500"
AutoExpandColumn="ItemName">
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column ColumnID="ItemName" Header="Item Name" Width="160" Sortable="true" DataIndex="ItemName" />
<ext:Column Header="Nomenclature" Width="75" Sortable="true" DataIndex="Nomenclature" /> </Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
<Listeners>
<RowSelect Handler="#{FormPanel1}.getForm().loadRecord(record);" />
</Listeners>
</ext:RowSelectionModel>
</SelectionModel>
</ext:GridPanel>
</West>
<Center>
<ext:FormPanel ID="FormPanel1" runat="server" Title="Form Panel" StoreID="Store1" BodyStyle="padding:5px;" ButtonAlign="Right">
<Body>
<ext:FormLayout ID="FormLayout1" runat="server">
<ext:Anchor Horizontal="95%">
<ext:TextField ID="PropertyClassID" DataIndex="PropertyClassID" runat="server" FieldLabel="Property Class" />
</ext:Anchor>
<ext:Anchor Horizontal="95%">
<ext:TextField ID="ItemName" DataIndex="ItemName" runat="server" FieldLabel="Item Name" />
</ext:Anchor>
<ext:Anchor Horizontal="95%">
<ext:TextField ID="Nomenclature" DataIndex="Nomenclature" runat="server" FieldLabel="Nomenclature" />
</ext:Anchor>
<ext:Anchor Horizontal="95%">
<ext:TextField ID="SerialNumber" DataIndex="SerialNumber" runat="server" FieldLabel="Serial Number" />
</ext:Anchor>
<ext:Anchor Horizontal="95%">
<ext:TextField ID="Model" DataIndex="Model" runat="server" FieldLabel="Model" />
</ext:Anchor>
<ext:Anchor Horizontal="95%">
<ext:TextField ID="PartNumber" DataIndex="PartNumber" runat="server" FieldLabel="Part Number" />
</ext:Anchor>
<ext:Anchor Horizontal="95%">
<ext:TextField ID="StockNumber" DataIndex="StockNumber" runat="server" FieldLabel="Stock Number" />
</ext:Anchor>
<ext:Anchor Horizontal="95%">
<ext:TextField ID="UnitofMeasure" DataIndex="UnitofMeasure" runat="server" FieldLabel="Unit of Measure " />
</ext:Anchor>
<ext:Anchor Horizontal="95%">
<ext:TextField ID="Manufacturer" DataIndex="Manufacturer" runat="server" FieldLabel="Manufacturer" />
</ext:Anchor>
<ext:Anchor Horizontal="95%">
<ext:TextField ID="LocationBldg" DataIndex="LocationBldg" runat="server" FieldLabel="Location Bldg" />
</ext:Anchor>
<ext:Anchor Horizontal="95%">
<ext:TextField ID="LocationRoom" DataIndex="LocationRoom" runat="server" FieldLabel="Location Room" />
</ext:Anchor>
<ext:Anchor Horizontal="95%">
<ext:TextField ID="LocationOther" DataIndex="LocationOther" runat="server" FieldLabel="Location Other" />
</ext:Anchor>
<ext:Anchor Horizontal="95%">
<ext:DateField ID="Warranty" DataIndex="Warranty" runat="server" FieldLabel="Warranty" />
</ext:Anchor>
<ext:Anchor Horizontal="95%">
<ext:DateField ID="SoftwareLicenseExpireDate" DataIndex="SoftwareLicenseExpireDate" runat="server" FieldLabel="Software License Expire Date" />
</ext:Anchor>
<ext:Anchor Horizontal="95%">
<ext:TextField ID="PurchaseOrderNumber" DataIndex="PurchaseOrderNumber" runat="server" FieldLabel="Purchase Order Number" />
</ext:Anchor>
<ext:Anchor Horizontal="95%">
<ext:TextField ID="ItemCost" DataIndex="ItemCost" runat="server" FieldLabel="Item Cost" />
</ext:Anchor>
<ext:Anchor Horizontal="95%">
<ext:DateField ID="PurchaseOrderDate" DataIndex="PurchaseOrderDate" runat="server" FieldLabel="Purchase Order Date" />
</ext:Anchor>
<ext:Anchor Horizontal="95%">
<ext:DateField ID="ExpectedReceiveDate" DataIndex="ExpectedReceiveDate" runat="server" FieldLabel="Expected Receive Date" />
</ext:Anchor>
<ext:Anchor Horizontal="95%">
<ext:DateField ID="RecieveDate" DataIndex="RecieveDate" runat="server" FieldLabel="Recieve Date" />
</ext:Anchor>
<ext:Anchor Horizontal="95%">
<ext:DateField ID="DisposalDate" DataIndex="DisposalDate" runat="server" FieldLabel="Disposal Date" />
</ext:Anchor>
<ext:Anchor Horizontal="95%">
<ext:TextField ID="ShelfLifeCide" DataIndex="ShelfLifeCide" runat="server" FieldLabel="Shelf Life Cide" />
</ext:Anchor>
<ext:Anchor Horizontal="95%">
<ext:TextField ID="PurchaseOrderStatusID" DataIndex="PurchaseOrderStatusID" runat="server" FieldLabel="Purchase Order Status" />
</ext:Anchor>
<ext:Anchor Horizontal="95%">
<ext:TextField ID="WSS_DocumentRepository" DataIndex="WSS_DocumentRepository" runat="server" FieldLabel="Test" />
</ext:Anchor>
</ext:FormLayout>
</Body>
<Buttons>
<ext:Button ID="ButtonUpdate" runat="server" Text="Add New" Icon="Disk">
<Listeners>
<Click Handler="#{GridPanel1}.insertRecord(0, {});#{FormPanel1}.getForm().updateRecord(#{Store1}.getAt(0, {}));#{Store1}.save()" />
</Listeners>
</ext:Button>
<ext:Button ID="ButtonReset" runat="server" Text="Reset Fields">
<Listeners>
<Click Handler="#{GridPanel1}.save();" />
</Listeners>
</ext:Button>
<ext:Button ID="btnInsert" runat="server" Text="Save" Icon="Add">
<Listeners>
<Click Handler="#{FormPanel1}.getForm().updateRecord(#{GridPanel1}.getSelectionModel().getSelected());#{GridPanel1}.save();" />
</Listeners>
</ext:Button>
</Buttons>
</ext:FormPanel>
</Center>
</ext:BorderLayout>
</Body>
</ext:Panel>
</form>
</body>
</html>
Still need to change my reset button back to clear the form fields (its in the original example) and add some code that will disable the buttons appropriately, because if you click the save button while there is no record it will cause a JavaScript error.
I need to add validation and a few combo boxes. I'll post that later as well.