Can anyone tell me that how could i call navigation method as shown in below C#.Net code.
Code:namespace valveautomation { public partial class data1 : System.Web.UI.Page { public SqlConnection con; public SqlDataAdapter da; public DataTable dt; public DataSet ds; public SqlCommand cmd; protected void Page_Load(object sender, EventArgs e) { SendSampleData("00000000"); con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename='F:\Visual Studio\vs 2010\PRL\valveautomation\valveautomation\App_Data\Database1.mdf';Integrated Security=True;User Instance=True"); con.Open(); da = new SqlDataAdapter("SELECT *FROM Table1", con); ds = new DataSet(); da.Fill(ds); dt = ds.Tables[0]; } public void Navigation() { for (; ; ) { try { da = new SqlDataAdapter("SELECT *FROM Table1 WHERE (CAST(date AS Date) = CAST(GETDATE() AS Date)) AND (CAST(time AS time(7)) = CAST(GETDATE() AS time(7)))", con); ds = new DataSet(); da.Fill(ds); StringBuilder Selection1 = new StringBuilder(); string sequn ="0"; if (ds.Tables[0].Rows.Count > 0) { int durationMinute = Convert.ToInt16(ds.Tables[0].Rows[0].ItemArray[3]); DataRow row = ds.Tables[0].Rows[0]; for (int i = 1; i <= 6; i++) { if (bool.Parse(row[string.Format("V{0}", i)].ToString())) Selection1.Append("1"); else Selection1.Append("0"); } Selection1.Append("00"); sequn = Selection1.ToString(); SendSampleData(sequn); // sending sequence to serial port delay(durationMinute); SendSampleData("00000000"); } else { } } catch (Exception) { } } } public void SendSampleData(String sequence) { // Instantiate the communications // port with some basic settings SerialPort port = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One); // Open the port for communications port.Open(); // Write a string port.Write("Hello World"); port.WriteLine(sequence); // Write a set of bytes // port.Write(new byte[] { 0x0A, 0xE2, 0xFF }, 0, 3); // Close the port port.Close(); } public void delay(int minute) { for(int i=minute;i>0;i--) { System.Threading.Thread.Sleep(60000); } } } }




Reply With Quote
