Advertisement
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: |
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
#Region " Declarations "
' User Controls - Menu
''Private _XmlOutput As String = Server.MapPath("Data\EggPricingOutput.xml")
Private _XmlInput As String = Server.MapPath("Data\EggPricingTemplate.xml")
Private _XmlPreview As String = Server.MapPath("Data\EggPricingPreview.xml")
#End Region
Dim sTemp As Integer = Nothing
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
ShowFormOnScreen()
End If
End Sub
Private Function InitFiles() As Boolean
'
Try
If Not System.IO.File.Exists(_XmlPreview) Then
System.IO.File.Copy(_XmlInput, _XmlPreview)
End If
Return True
Catch ex As Exception
Return False
End Try
'
End Function
Private Function CreateDataSource() As DataSet
'
Dim xml As New XmlDataDocument
'
xml.DataSet.ReadXmlSchema(_XmlPreview)
xml.Load(_XmlPreview)
'
Return xml.DataSet
'
End Function
Private Sub ShowFormOnScreen()
'
lblMessage.Visible = False
Try
If InitFiles() Then
Dim ds As DataSet = CreateDataSource()
'
With UltraWebGrid1
.DataSource = ds.Tables(0)
.DataBind()
End With
txtSaleDate.Text = ds.Tables(1).Rows(0).Item(0).ToString
txtComment.Text = ds.Tables(1).Rows(0).Item(1).ToString
Else
With lblMessage
.Visible = True
.CssClass = "labelRed"
.Text = "File can NOT be created. Please contact the A1S help desk at (914) 697-5357."
End With
End If
Catch ex As Exception
With lblMessage
.Visible = True
.CssClass = "labelRed"
.Text = "An error occurred. Please contact the A1S help desk at (914) 697-5357."
End With
End Try
'
End Sub
Public Sub doClearAll()
Dim ds As DataSet = CreateDataSource()
Dim row As DataRow
For Each row In ds.Tables(0).Rows
row("unit_price") = ""
row("case_price") = ""
row("SRP") = ""
Next
ds.WriteXml(_XmlPreview)
'sTemp = 5
With UltraWebGrid1
'.EditItemIndex = -1
.DataSource = CreateDataSource().Tables(0)
.DataBind()
End With
txtSaleDate.Text = ""
txtComment.Text = ""
Me.lblMessage.Text = ""
Me.UltraWebGrid1.DisplayLayout.SelectedRows.Clear()
'
End Sub
Private Sub btnPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPreview.Click
'
If ConstractXML() Then
Session("rtnPage") = "/dairy/EggInputForm.aspx"
Response.Redirect("/dairy/Preview.aspx")
End If
'
End Sub
Private Function ConstractXML() As Boolean
'
' Add comment and date fields to xml
'
Dim ds As DataSet
'
Try
ds = CreateDataSource()
ds.Tables(1).Rows(0).Item(0) = txtSaleDate.Text
ds.Tables(1).Rows(0).Item(1) = txtComment.Text
ds.WriteXml(_XmlPreview)
Return True
Catch ex As Exception
Response.Write(ex.Message)
Response.Write("<br/><font color='red' >Error occurred.Preview file has not been created.</font>")
Return False
Finally
End Try
'
End Function
Private Sub UltraWebGrid1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.LayoutEventArgs) Handles UltraWebGrid1.InitializeLayout
UltraWebGrid1.DisplayLayout.AllowUpdateDefault = AllowUpdate.Yes
UltraWebGrid1.DisplayLayout.AllowAddNewDefault = AllowAddNew.Yes
UltraWebGrid1.Bands(0).Columns.FromKey("ID").Move(0)
UltraWebGrid1.Bands(0).Columns.FromKey("pack.size").Move(1)
UltraWebGrid1.Bands(0).Columns.FromKey("Description").Move(2)
UltraWebGrid1.Bands(0).Columns.FromKey("unit_price").Move(3)
UltraWebGrid1.Bands(0).Columns.FromKey("case_price").Move(4)
UltraWebGrid1.Bands(0).Columns.FromKey("srp").Move(5)
UltraWebGrid1.DisplayLayout.Bands(0).Columns(6).Hidden = True
UltraWebGrid1.DisplayLayout.Bands(0).Columns(7).Hidden = True
UltraWebGrid1.DisplayLayout.Bands(0).Columns(8).Hidden = True
UltraWebGrid1.DisplayLayout.Bands(0).Columns(0).Header.Caption = "ID"
UltraWebGrid1.DisplayLayout.Bands(0).Columns(1).Header.Caption = "Pack/Size"
UltraWebGrid1.DisplayLayout.Bands(0).Columns(2).Header.Caption = "Description"
UltraWebGrid1.DisplayLayout.Bands(0).Columns(3).Header.Caption = "Unit Price"
UltraWebGrid1.DisplayLayout.Bands(0).Columns(4).Header.Caption = "Case Price"
UltraWebGrid1.DisplayLayout.Bands(0).Columns(5).Header.Caption = "SRP"
UltraWebGrid1.DisplayLayout.Bands(0).Columns(0).Key = "ID"
UltraWebGrid1.DisplayLayout.Bands(0).Columns(1).Key = "pack.size"
UltraWebGrid1.DisplayLayout.Bands(0).Columns(2).Key = "Description"
UltraWebGrid1.DisplayLayout.Bands(0).Columns(3).Key = "unit_price"
UltraWebGrid1.DisplayLayout.Bands(0).Columns(4).Key = "case_price"
UltraWebGrid1.DisplayLayout.Bands(0).Columns(5).Key = "SRP"
UltraWebGrid1.DisplayLayout.Bands(0).Columns(0).Width = Unit.Pixel(100)
UltraWebGrid1.DisplayLayout.Bands(0).Columns(1).Width = Unit.Pixel(100)
UltraWebGrid1.DisplayLayout.Bands(0).Columns(2).Width = Unit.Pixel(430)
UltraWebGrid1.DisplayLayout.Bands(0).Columns(3).Width = Unit.Pixel(100)
UltraWebGrid1.DisplayLayout.Bands(0).Columns(4).Width = Unit.Pixel(100)
UltraWebGrid1.DisplayLayout.Bands(0).Columns(5).Width = Unit.Pixel(100)
' set the DataKeyField so when the events are thrown the
' row.datakey property can be populated
e.Layout.Bands(0).DataKeyField = "GUID"
' turn on edit, update, delete and show the AddNewBox
e.Layout.AllowAddNewDefault = Infragistics.WebUI.UltraWebGrid.AllowAddNew.Yes
e.Layout.AllowDeleteDefault = Infragistics.WebUI.UltraWebGrid.AllowDelete.Yes
e.Layout.AllowUpdateDefault = Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes
UltraWebGrid1.DisplayLayout.AddNewBox.Style.BackColor = Color.BlanchedAlmond
e.Layout.AddNewBox.Hidden = False
' set the default cell click action to edit
e.Layout.CellClickActionDefault = _
Infragistics.WebUI.UltraWebGrid.CellClickAction.Edit
e.Layout.CellClickActionDefault = _
Infragistics.WebUI.UltraWebGrid.CellClickAction.CellSelect
' add a hidden GUID column to band(0)
With e.Layout.Bands(0)
Dim objTable As DataTable = New DataTable
Dim objRow As DataRow
.Columns.Add("GUID")
.Columns.FromKey("GUID").Hidden = True
' .Rows.Add(objRow)
' Next i
End With
End Sub
Private Sub UltraWebGrid1_UpdateRow(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.RowEventArgs) Handles UltraWebGrid1.UpdateRow
Dim oldRow As UltraGridRow = CType(e.Data, UltraGridRow)
Dim dataKey As String = CStr(e.Row.DataKey)
'newer fields
'Dim ID As String = e.Row.Cells(0).Value
'Dim PackSize As String = e.Row.Cells(1).Value
'Dim Description As String = e.Row.Cells(2).Value
'Dim Description As String = e.Row.Cells(2).Value
Dim sUnitPrice As String = e.Row.Cells(3).Value
Dim sSRP As String = e.Row.Cells(5).Value
Dim CasePrice As Decimal
'Dim sCasePrice As String = e.Row.Cells(4).Value
If Not IsNumeric(sUnitPrice) Then
With lblMessage
.Visible = True
.CssClass = "labelRed"
.Text = "Last Price field must be numeric! Your data is not saved. Please reenter your Last Price."
End With
Exit Sub
ElseIf Not IsNumeric(sSRP) Then
With lblMessage
.Visible = True
.CssClass = "labelRed"
.Text = "Current Price field must be numeric! Your data is not saved. Please reenter your Current Price."
End With
Exit Sub
End If
Dim ds As DataSet = CreateDataSource()
Dim row As DataRow = ds.Tables(0).Rows(e.Row.Index)
If IsNumeric(sUnitPrice) Then
CasePrice = Convert.ToDecimal(e.Row.Cells(7).Value) * Convert.ToDecimal(sUnitPrice)
row("case_price") = System.Decimal.Round(CasePrice, 2)
End If
row("SRP") = sSRP
ds.WriteXml(_XmlPreview)
Me.UltraWebGrid1.DisplayLayout.SelectedRows.Clear()
With UltraWebGrid1
'.EditItemIndex = -1
.DataSource = CreateDataSource().Tables(0)
.DataBind()
End With
With lblMessage
.Visible = True
.CssClass = "labelGreen"
.Text = "Your data was succesfully modified and saved."
End With
End Sub
Private Sub UltraWebGrid1_UpdateGrid(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.UpdateEventArgs) Handles UltraWebGrid1.UpdateGrid
Dim table As DataTable
Dim row As UltraGridRow
End Sub
Private Sub BtnClearAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClearAll.Click
Call doClearAll()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'
Dim ds As DataSet = CreateDataSource()
Dim row As DataRow
For Each row In ds.Tables(0).NewRow
row("unit_price") = ""
row("case_price") = ""
row("SRP") = ""
Next
ds.WriteXml(_XmlPreview)
ds.Tables(1).Rows(0).Item(0) = txtSaleDate.Text
ds.Tables(1).Rows(0).Item(1) = txtComment.Text
ds.WriteXml(_XmlPreview)
ds.WriteXmlSchema("EggPricingPreview.xml")
If ds.Tables.Count = 0 Then
With lblMessage
.Visible = True
.CssClass = "labelRed"
.Text = " There is no file located Please add a file to create your data"
End With
Exit Sub
End If
End Sub
|
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
|
Loading Advertisement... |