• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 349
  • Last Modified:

i want an alarm message when two field exceed this value

Hi,
i have the following for :
date:
station name:
inflow target:
outflow target:
inflow actual:
change of storage:
outflow actual:


and i have a bit of complicated issue,that when a user enters the inflow actual and change of storage,they should satisfy the following equation:

inflow actual - (change of storage) =~ outflow ctual
(=~ means the value of the right hand side should be equal or different by 2.5% from the left hand side)

i want the user when entering those values ,if they are more than the specified criteria,it gives a warning pop up message saying(your value exceeds the agreed range,do you want to continue)then yes or no buttons in order to fill the remaining fields of the form and press confirm to save them.
is that possible???
0
noor21
Asked:
noor21
  • 7
  • 7
  • 2
2 Solutions
 
Maulik ModiCommented:
Intresting Question and answer is "its possible!!"

You can write the above business logic in client side script and invoke it when you have all Quantities with you and if this script returns false, invoke other script to display appropriate pop-up message and at the end based on which button user selects do the appropriate action.

<script language="javascript">
//function to access control on the form, given id:
function cbGetElement(eName)
{      
 return document.getElementById(eName);
}

//function to check business rule, returns true or false:
function CheckInflow()
{
   var Inflow=  cbGetElement('<%=this.UniqueID%>_txtInflow').Value;
   var ActualOutFlow = ...
    var ChangeofSource=  ...
       
    //Validate business rule and return true or false:
    .....
}
</script>

In order to show pop up message I'd request you to refer this article:
http://www.eggheadcafe.com/articles/javascript_modal_dialog.asp

Cheers!!!
maulikCE

0
 
noor21Author Commented:
i am using vb.net and i am really finding it hard to read ur java code,is there link on text click pop up message
0
 
Maulik ModiCommented:
Look, web applications composed of client side coding and server side coding. Client side means code that executes on visitors browser..e.g. hide and show certain fields when user selects particular country. Its mainly used to give immediate response to user's action. They are called client side scripts  - mainly written in JavaScript or Jscript. You can go for Vbscript which only runs in Internet Explorer.All browsers recognize Javascript, so I have given you code snippet in the same..

Other is server side, which you can write in your favourite language that .NET supports...In server side scripts you do some backend processing, maintain user sessions, control display of form..

Taking your specific use, its good to go for client side script(I've written in javascript), as we want to show immediate response when user enters value beyond certain criteria.

Regards.
MaulikCE
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
RejojohnyCommented:
cld u post the aspx code .. so as to see what ur controls are named as .. it would help to give u the exact code ...
0
 
noor21Author Commented:
i have the form.aspx page that has the form and submit button that opens a pop up window that has the values of the form to be confirmed by the user:

form.aspx:
-------------
<script language="javascript">
               function OpenNewWindow()
               {
                    window.open('pumping_confirm.aspx', '', 'menu=no,location=no,status=no');
               }
            </script>





while in the pop up window this is the code:
--------------------------------------------------------

Try
            Dim MySQL As String = "Insert into pumping_station_operation_data([date],station_id,inflow_target,outflow_target,inflow_actual,outflow_actual,storage,change_of_storage_target,change_of_storage) values (@txttext1,@texttest2,@txttest3,@txttest4,@txttest5,@txttest6,@txttest7,@txttest8,@txttest9)"
            Dim myConn As SqlConnection = New SqlConnection("******************")
            Dim Cmd As New SqlCommand(MySQL, myConn)
            Cmd.Parameters.Add(New SqlParameter("@txttext1", TextBox1.Text))
            Cmd.Parameters.Add(New SqlParameter("@texttest2", TextBox2.Text))
            Cmd.Parameters.Add(New SqlParameter("@txttest3", TextBox3.Text))
            Cmd.Parameters.Add(New SqlParameter("@txttest4", TextBox4.Text))
            Cmd.Parameters.Add(New SqlParameter("@txttest5", TextBox5.Text))
            Cmd.Parameters.Add(New SqlParameter("@txttest6", TextBox6.Text))
            Cmd.Parameters.Add(New SqlParameter("@txttest7", TextBox7.Text))
            Cmd.Parameters.Add(New SqlParameter("@txttest8", TextBox8.Text))
            Cmd.Parameters.Add(New SqlParameter("@txttest9", TextBox9.Text))
            Label1.Text = "Your Data Is Saved"

            myConn.Open()
            Cmd.ExecuteNonQuery()
        Catch ex As SqlClient.SqlException
            Dim lstrScript As String
            lstrScript += "<Script language = javascript>alert('You Have Entered Duplicate Date!');</Script>"
            Page.RegisterClientScriptBlock("ErroOnPage", lstrScript)
        End Try
        BindData()







Sub BindData()


        Dim myConn As SqlConnection = New SqlConnection("*****************8")
        Dim MySQL As String
        MySQL = "Select * from pumping_station_operation_data "
        Dim Cmd1 As New SqlCommand(MySQL, myConn)


        Dim ds As DataSet = New DataSet
        Dim Cmd As New SqlDataAdapter(MySQL, myConn)
        Cmd.Fill(ds, "pump_operation_data")
        mydatagrid.DataSource = ds.Tables("pump_operation_data").DefaultView
        mydatagrid.DataBind()
    End Sub
0
 
RejojohnyCommented:
i asked for the aspx code of the page where u want the validation ...
0
 
noor21Author Commented:
thats it Rejojohny:

Try
            Dim MySQL As String = "Insert into pumping_station_operation_data([date],station_id,inflow_target,outflow_target,inflow_actual,outflow_actual,storage,change_of_storage_target,change_of_storage) values (@txttext1,@texttest2,@txttest3,@txttest4,@txttest5,@txttest6,@txttest7,@txttest8,@txttest9)"
            Dim myConn As SqlConnection = New SqlConnection("******************")
            Dim Cmd As New SqlCommand(MySQL, myConn)
            Cmd.Parameters.Add(New SqlParameter("@txttext1", TextBox1.Text))
            Cmd.Parameters.Add(New SqlParameter("@texttest2", TextBox2.Text))
            Cmd.Parameters.Add(New SqlParameter("@txttest3", TextBox3.Text))
            Cmd.Parameters.Add(New SqlParameter("@txttest4", TextBox4.Text))
            Cmd.Parameters.Add(New SqlParameter("@txttest5", TextBox5.Text))
            Cmd.Parameters.Add(New SqlParameter("@txttest6", TextBox6.Text))
            Cmd.Parameters.Add(New SqlParameter("@txttest7", TextBox7.Text))
            Cmd.Parameters.Add(New SqlParameter("@txttest8", TextBox8.Text))
            Cmd.Parameters.Add(New SqlParameter("@txttest9", TextBox9.Text))
            Label1.Text = "Your Data Is Saved"

            myConn.Open()
            Cmd.ExecuteNonQuery()
        Catch ex As SqlClient.SqlException
            Dim lstrScript As String
            lstrScript += "<Script language = javascript>alert('You Have Entered Duplicate Date!');</Script>"
            Page.RegisterClientScriptBlock("ErroOnPage", lstrScript)
        End Try
 BindData()







Sub BindData()


        Dim myConn As SqlConnection = New SqlConnection("*****************8")
        Dim MySQL As String
        MySQL = "Select * from pumping_station_operation_data "
        Dim Cmd1 As New SqlCommand(MySQL, myConn)


        Dim ds As DataSet = New DataSet
        Dim Cmd As New SqlDataAdapter(MySQL, myConn)
        Cmd.Fill(ds, "pump_operation_data")
        mydatagrid.DataSource = ds.Tables("pump_operation_data").DefaultView
        mydatagrid.DataBind()
    End Sub


0
 
RejojohnyCommented:
i mean the script .. the HTML (ASPX) page .. the tags .. <asp:textbox> etc ....
0
 
noor21Author Commented:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm4.aspx.vb" Inherits="water_control.WebForm4"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
      <HEAD>
            <title>generation station operation data</title>
            <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
            <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
            <meta content="JavaScript" name="vs_defaultClientScript">
            <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
            <script language="javascript">
               function OpenNewWindow()
               {
                    window.open('WebForm5.aspx', '', 'menu=no,location=no,status=no');
               }
            </script>
      </HEAD>
      <body MS_POSITIONING="GridLayout" background="file:///C:/Documents%20and%20Settings/Desktop/design/wcc_pic/New%20Image1.JPG">
            <form id="Form1" method="post" runat="server">
                  <TABLE id="Table1" style="Z-INDEX: 101; LEFT: 176px; WIDTH: 360px; POSITION: absolute; TOP: 256px; HEIGHT: 384px"
                        cellSpacing="1" cellPadding="1" width="360" border="1">
                        <TR>
                              <TD style="WIDTH: 206px; HEIGHT: 31px"><STRONG>Date:</STRONG></TD>
                              <TD style="HEIGHT: 31px"><asp:textbox id="TextBox1" runat="server"></asp:textbox></TD>
                        </TR>
                        <TR>
                              <TD style="WIDTH: 206px"><STRONG>Station Name:</STRONG></TD>
                              <TD><asp:dropdownlist id="ddlcustomer" runat="server" Width="120px"></asp:dropdownlist></TD>
                        </TR>
                        <TR>
                              <TD style="WIDTH: 206px"><STRONG>Production:</STRONG></TD>
                              <TD><asp:textbox id="TextBox3" runat="server"></asp:textbox></TD>
                        </TR>
                        <TR>
                              <TD style="WIDTH: 206px"><STRONG>Outflow:</STRONG></TD>
                              <TD><asp:textbox id="TextBox4" runat="server"></asp:textbox></TD>
                        </TR>
                        <TR>
                              <TD style="WIDTH: 206px"><STRONG>Storage:</STRONG></TD>
                              <TD><asp:textbox id="TextBox5" runat="server"></asp:textbox></TD>
                        </TR>
                        <TR>
                              <TD style="WIDTH: 206px"><STRONG>Internal Consumption:</STRONG></TD>
                              <TD><asp:textbox id="TextBox6" runat="server"></asp:textbox></TD>
                        </TR>
                        <TR>
                              <TD style="WIDTH: 206px"><STRONG>Total MGD:</STRONG></TD>
                              <TD><asp:textbox id="TextBox7" runat="server"></asp:textbox></TD>
                        </TR>
                        <TR>
                              <TD style="WIDTH: 206px"><STRONG>Production Target:</STRONG></TD>
                              <TD><asp:textbox id="TextBox8" runat="server"></asp:textbox></TD>
                        </TR>
                        <TR>
                              <TD style="WIDTH: 206px"><STRONG>Change Of&nbsp; Storage Target:</STRONG></TD>
                              <TD><asp:textbox id="TextBox9" runat="server"></asp:textbox></TD>
                        </TR>
                        <TR>
                              <TD style="WIDTH: 206px"><STRONG>Change Of&nbsp; Storage:</STRONG></TD>
                              <TD><asp:textbox id="TextBox10" runat="server"></asp:textbox></TD>
                        </TR>
                        <TR>
                              <TD style="WIDTH: 206px"><INPUT style="WIDTH: 72px; HEIGHT: 24px" onclick="javascript:OpenNewWindow();" type="button"
                                          value="Submit">
                                    <asp:button id="Button1" runat="server" Width="64px" Text="Clear"></asp:button></TD>
                              <TD></TD>
                        </TR>
                  </TABLE>
                  <asp:label id="Label1" style="Z-INDEX: 102; LEFT: 48px; POSITION: absolute; TOP: 216px" runat="server"></asp:label><asp:label id="Label2" style="Z-INDEX: 103; LEFT: 224px; POSITION: absolute; TOP: 216px" runat="server"></asp:label>
                  <HR style="Z-INDEX: 104; LEFT: 16px; POSITION: absolute; TOP: 208px" width="100%" SIZE="1">
                  <HR style="Z-INDEX: 105; LEFT: 16px; POSITION: absolute; TOP: 240px" width="100%" SIZE="1">
                  <asp:HyperLink id="HyperLink6" style="Z-INDEX: 107; LEFT: 408px; POSITION: absolute; TOP: 656px"
                        runat="server" NavigateUrl="view_generation.aspx">Click Here</asp:HyperLink>
                  <asp:HyperLink id="HyperLink7" style="Z-INDEX: 108; LEFT: 16px; POSITION: absolute; TOP: 160px"
                        runat="server" NavigateUrl="disti.aspx" ImageUrl="file:///C:\Documents and Settings\Desktop\design\wcc_pic\button3D.jpg">HyperLink</asp:HyperLink>
                  <asp:HyperLink id="HyperLink8" style="Z-INDEX: 109; LEFT: 144px; POSITION: absolute; TOP: 160px"
                        runat="server" NavigateUrl="line.aspx" ImageUrl="file:///C:\Documents and Settings\Desktop\design\wcc_pic\button40.jpg">HyperLink</asp:HyperLink>
                  <asp:HyperLink id="HyperLink9" style="Z-INDEX: 110; LEFT: 272px; POSITION: absolute; TOP: 160px"
                        runat="server" NavigateUrl="tanks.aspx" ImageUrl="file:///C:\Documents and Settings\Desktop\design\wcc_pic\button43.jpg">HyperLink</asp:HyperLink>
                  <asp:HyperLink id="HyperLink10" style="Z-INDEX: 111; LEFT: 400px; POSITION: absolute; TOP: 160px"
                        runat="server" NavigateUrl="first.aspx" ImageUrl="file:///C:\Documents and Settings\Desktop\design\wcc_pic\button46.jpg">HyperLink</asp:HyperLink>
                  <asp:HyperLink id="HyperLink11" style="Z-INDEX: 112; LEFT: 528px; POSITION: absolute; TOP: 160px"
                        runat="server" NavigateUrl="logout.aspx" ImageUrl="file:///C:\Documents and Settings\Desktop\design\wcc_pic\button22.jpg">HyperLink</asp:HyperLink><IMG style="Z-INDEX: 113; LEFT: 24px; POSITION: absolute; TOP: 16px" alt="" src="file:///C:\Documents and Settings\Desktop\design\wcc_pic\UNTITLED-21 copy.gif">
                  <HR style="Z-INDEX: 114; LEFT: 16px; POSITION: absolute; TOP: 152px" width="100%" SIZE="1">
                  <asp:Label id="Label3" style="Z-INDEX: 106; LEFT: 72px; POSITION: absolute; TOP: 656px" runat="server"
                        Width="328px" Font-Bold="True" Font-Size="Small">To View The Generation Station  Operation Data</asp:Label>
            </form>
            <br>
            <br>
            <br>
      </body>
</HTML>
0
 
noor21Author Commented:
any help with this????
0
 
noor21Author Commented:
any answer for my question,its urgent
0
 
RejojohnyCommented:
sorry .. but was very busy with some other work and was not frequenting EE so much ..
it would be very nice to name controls with a name explaining what that control is all about and not as "textbox1", textbox2" etc .. its very difficult to debug ur code

as for ur problem .. u will have to call a client script function (i have used vbscript) to do the validation for all the texbox which needs the validation i.e.
inflow actual
change of storage
outflow ctual

for that in the page load event write the code (.vb file)
assuming textbox5 is "inflow actual"
      textbox5.attributes.add("onchange", "vbscript:CheckValue")
same code for all the other controls

then in the aspx page define the function
<head>
....... ur exiting code
<script language = vbscript>
   Sub CheckValue
         'assuming textbox5 is "actual storage"
         '     textbox10 is "change of storage"
         '     TextBox4 is "outflow actual"

         Dim ldblDiff, ldblOutFlowActual
         ldblDiff = (document.getElementById("textbox5").value - document.getElementById("textbox10").value)
         ldblOutFlowActual = document.getElementById("textbox4").value
 
         if ldblDiff >= ldblOutFlowActual and ldblDiff <= (ldblOutFlowActual * 2.5) / 100 then
            ' is valid
         else
           ' not valid
               if msgbox ("Error during validation, do u want to continue", vbquestion+vbyesno) = vbNo then
                      'the user does not want to continue .. do what u want to do here .. empty the texbox or something like that
               end if
         end if


   End Sub
</script>
</head>
0
 
noor21Author Commented:
for that in the page load event write the code (.vb file)---------------------->what do u mean by that?
0
 
RejojohnyCommented:
u have a code-behind file? .. basically whereever ur server-side code is ...
0
 
RejojohnyCommented:
I have already given a complete solution using javascript ...
0
 
RejojohnyCommented:
sorry .. vbscript .. client script ...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 7
  • 7
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now