private void Back_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            this.Hide();
            UserHome frm3 = new UserHome();

            frm3.Closed += (s, args) => this.Close();
            frm3.Show();
        }
Пример #2
0
        private void bt_refresh_Click(object sender, EventArgs e)
        {
            this.Hide();

            UserHome form2 = new UserHome();

            form2.Closed += (s, args) => this.Close();
            form2.Show();
        }
Пример #3
0
        private void post_add_Click(object sender, EventArgs e)
        {
            Add = add_text.Text.ToString();
            //MessageBox.Show(Add);
            AddDescr  = Add_Descr.Text.ToString();
            Data_send = "Add_Insert|" + Variable.gusername + "|" + Add + "|" + AddDescr;
            //MessageBox.Show(Data_send);
            try
            {
                clientSocket.Connect(Variable.ipaddress, Variable.port);
                STR_W           = new StreamWriter(clientSocket.GetStream());
                STR_R           = new StreamReader(clientSocket.GetStream());
                STR_W.AutoFlush = true;
                if (clientSocket.Connected)
                {
                    STR_W.WriteLine(Data_send);
                    string returndata; returndata = STR_R.ReadLine();

                    if (returndata == "Success")
                    {
                        //          MessageBox.Show("Your add has been Posted for Review");
                        this.Hide();
                        UserHome frm1 = new UserHome();
                        frm1.Show();
                        clientSocket.Close();
                    }
                    else
                    {
                        clientSocket.Close();
                        this.Hide();
                        PostNewAddHere form3 = new PostNewAddHere();
                        form3.Show();
                    }
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.ToString());
            }
        }
Пример #4
0
 private void show_next_form()
 {
     if (Variable.gusertype == "admin")
     {
         this.Hide();
         AdminHome form2 = new AdminHome();
         form2.Closed += (s, args) => this.Close();
         form2.Show();
     }
     else if (Variable.gusertype == "secmgr")
     {
         this.Hide();
         SecurityManagerHome form2 = new SecurityManagerHome();
         form2.Closed += (s, args) => this.Close();
         form2.Show();
     }
     else if (Variable.gusertype == "enduser")
     {
         this.Hide();
         UserHome form2 = new UserHome();
         form2.Closed += (s, args) => this.Close();
         form2.Show();
     }
 }
Пример #5
0
 private void bt_back_to_pre_form_Click(object sender, EventArgs e)
 {
     if (Variable.gusertype == "admin")
     {
         this.Hide();
         AdminHome form2 = new AdminHome();
         form2.Closed += (s, args) => this.Close();
         form2.Show();
     }
     else if (Variable.gusertype == "secmgr")
     {
         this.Hide();
         SecurityManagerHome form2 = new SecurityManagerHome();
         form2.Closed += (s, args) => this.Close();
         form2.Show();
     }
     else if (Variable.gusertype == "enduser")
     {
         this.Hide();
         UserHome form2 = new UserHome();
         form2.Closed += (s, args) => this.Close();
         form2.Show();
     }
 }
Пример #6
0
        private void bt_login_Click(object sender, EventArgs e)
        {
            //byte[] bytes = new byte[1024];

            username = txt_username.Text;
            MessageBox.Show(username);

            //binding socket

            // eplocal = new IPEndPoint(IPAddress.Parse(SR_IP), Convert.ToInt32("12000"));
            //skt.Bind(eplocal);

            /*
             * try
             * {
             *  epremote = new IPEndPoint(IPAddress.Parse("10.0.0.2"), Convert.ToInt32("12000"));
             *  //skt.Connect("10.0.0.2",12000);
             *  skt.Connect(epremote);
             *  byte[] msg = Encoding.ASCII.GetBytes("Login");
             *  skt.Send(msg);
             *  byte[] msg1 = Encoding.ASCII.GetBytes(txt_username.Text);
             *  skt.Send(msg1);
             *  byte[] msg2 = Encoding.ASCII.GetBytes(txt_passwd.Text);
             *  skt.Send(msg2);
             *
             *  buffer = new byte[1500];
             *  skt.Receive(buffer);
             *  string returndata = System.Text.Encoding.ASCII.GetString(buffer);
             *  MessageBox.Show(returndata);
             * }
             * catch (Exception e1)
             * {
             *  MessageBox.Show("ArgumentNullException : {0}", e1.ToString());
             * }*/

            /*// start
             * byte[] bytes = new byte[1024];
             *
             * // Connect to a remote device.
             * try
             * {
             *  // Establish the remote endpoint for the socket.
             *  // This example uses port 11000 on the local computer.
             *  // IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName())
             *  //IPAddress ipAddress = ipHostInfo.AddressList[0];
             *  //IPEndPoint remoteEP = new IPEndPoint('10.0.0.2', 12000);
             *
             *  // Create a TCP/IP  socket.
             *
             *  // Connect the socket to the remote endpoint. Catch any errors.
             *  try
             *  {
             *      sender.Connect("10.0.0.2", 12000);
             *
             *      // Console.WriteLine("Socket connected to {0}",
             *      //   new Socket(AddressFamily.InterNetwork,
             *      //SocketType.Stream, ProtocolType.Tcp).RemoteEndPoint.ToString());
             *
             *      // Encode the data string into a byte array.
             *      byte[] msg = Encoding.ASCII.GetBytes("Login");
             *
             *      // Send the data through the socket.
             *      int bytesSent = sender.Send(msg);
             *
             *      msg = Encoding.ASCII.GetBytes(txt_username.Text);
             *      bytesSent = sender.Send(msg);
             *
             *      msg = Encoding.ASCII.GetBytes(txt_passwd.Text);
             *      bytesSent = sender.Send(msg);
             *
             *      // Receive the response from the remote device.
             *      int bytesRec = sender.Receive(bytes);
             *      Console.WriteLine("Echoed test = {0}",
             *          Encoding.ASCII.GetString(bytes, 0, bytesRec));
             *      sender.Shutdown(SocketShutdown.Both);
             *      sender.Close();
             *
             *  }
             *  catch (ArgumentNullException ane)
             *  {
             *      Console.WriteLine("ArgumentNullException : {0}", ane.ToString());
             *  }
             *  catch (SocketException se)
             *  {
             *      Console.WriteLine("SocketException : {0}", se.ToString());
             *  }
             *  catch (Exception e3)
             *  {
             *      Console.WriteLine("Unexpected exception : {0}", e3.ToString());
             *  }
             *
             * }
             * catch (Exception e4)
             * {
             *  Console.WriteLine(e4.ToString());
             * }
             * // end*/

            try
            {
                //epremote = new IPEndPoint(IPAddress.Parse("10.0.0.2"), Convert.ToInt32("12000"));
                clientSocket.Connect("10.0.0.2", 12000);
                STR_W           = new StreamWriter(clientSocket.GetStream());
                STR_R           = new StreamReader(clientSocket.GetStream());
                STR_W.AutoFlush = true;
                if (clientSocket.Connected)
                {
                    STR_W.WriteLine("Login|" + txt_username.Text + "|" + txt_passwd.Text);

                    //STR_W.WriteLine(txt_username.Text);

                    //STR_W.WriteLine(txt_passwd.Text);

                    string returndata;

                    returndata = STR_R.ReadLine();
                    if (returndata == "Failed")
                    {
                        MessageBox.Show("Username or Password is incorrect");
                    }
                    else
                    {
                        clientSocket.Close();
                        Variable.gusername = txt_username.Text;
                        Variable.gusertype = returndata;
                        MessageBox.Show("Login Successful.........!", returndata);
                        if (returndata == "admin")
                        {
                            this.Hide();
                            AdminHome frm = new AdminHome();
                            frm.Show();
                        }
                        if (returndata == "enduser")
                        {
                            this.Hide();
                            UserHome frm1 = new UserHome();
                            frm1.Show();
                        }
                        if (returndata == "secmgr")
                        {
                            this.Hide();
                            SecurityManagerHome frm2 = new SecurityManagerHome();
                            frm2.Show();
                        }
                    }

                    /* NetworkStream serverStream = clientSocket.GetStream();
                     * byte[] outStream = System.Text.Encoding.ASCII.GetBytes("Login");
                     * serverStream.Write(outStream, 0, outStream.Length);
                     * //serverStream.Flush();
                     * NetworkStream serverStream1 = clientSocket.GetStream();
                     * byte[] outStream2 = System.Text.Encoding.ASCII.GetBytes(username);
                     * serverStream1.Write(outStream, 0, outStream2.Length);
                     * // serverStream.Flush();
                     * NetworkStream serverStream2 = clientSocket.GetStream();
                     * byte[] outStream3 = System.Text.Encoding.ASCII.GetBytes(txt_passwd.Text);
                     * serverStream2.Write(outStream, 0, outStream3.Length);
                     * serverStream.Flush();
                     *
                     *                  byte[] inStream = new byte[1024];
                     * serverStream.Read(inStream, 0, inStream.Length);
                     * string returndata = System.Text.Encoding.ASCII.GetString(inStream);
                     * MessageBox.Show(returndata);*/
                }
            }


            catch (Exception e4)
            {
                Console.WriteLine(e4.ToString());
            }
        }
Пример #7
0
        private void bt_login_Click(object sender, EventArgs e)
        {
            username = txt_username.Text;
            //  MessageBox.Show(username);



            try
            {
                clientSocket.Connect(Variable.ipaddress, Variable.port);
                STR_W           = new StreamWriter(clientSocket.GetStream());
                STR_R           = new StreamReader(clientSocket.GetStream());
                STR_W.AutoFlush = true;
                if (clientSocket.Connected)
                {
                    STR_W.WriteLine("Login|" + txt_username.Text + "|" + txt_passwd.Text);



                    string returndata;

                    returndata = STR_R.ReadLine();
                    if (returndata == "Failed")
                    {
                        MessageBox.Show("Username or Password is incorrect");
                        this.Hide();
                        Login frm = new Login();
                        frm.Show();
                    }
                    else
                    {
                        clientSocket.Close();
                        Variable.gusername = txt_username.Text;
                        Variable.gusertype = returndata;
                        MessageBox.Show("Login Successful.........!", returndata);
                        if (returndata == "admin")
                        {
                            this.Hide();
                            AdminHome frm = new AdminHome();
                            frm.Show();
                        }
                        if (returndata == "enduser")
                        {
                            this.Hide();
                            UserHome frm1 = new UserHome();
                            frm1.Show();
                        }
                        if (returndata == "secmgr")
                        {
                            this.Hide();

                            this.Hide();



                            SecurityManagerHome form2 = new SecurityManagerHome();
                            form2.Closed += (s, args) => this.Close();
                            form2.Show();
                        }
                    }
                }
            }


            catch (Exception e4)
            {
                Console.WriteLine(e4.ToString());
            }
        }
Пример #8
0
        private void bt_Profile_Click(object sender, EventArgs e)
        {
            if (txt_username.Text != "" && txt_passwd.Text != "" && txt_passwd_confirm.Text != "" && txt_full_name.Text != "" && txt_gender.Text != "" && txt_location.Text != "" && txt_Contact_no.Text != "" && cb_security_qus.Text != "" && txt_ans.Text != "")
            {
                if (txt_Contact_no.Text.Length < 10)
                {
                    MessageBox.Show("Contact no. should be 10 digit......!");
                }
                else
                {
                    if (txt_passwd.Text != txt_passwd_confirm.Text)
                    {
                        txt_passwd.Clear();
                        txt_passwd_confirm.Clear();
                    }
                    else
                    {
                        Data_send = "Profile_Change|" + txt_username.Text + "|" + txt_passwd.Text + "|" + txt_full_name.Text + "|" + txt_gender.Text + "|" + txt_location.Text + "|" + txt_Contact_no.Text + "|" + cb_security_qus.Text + "|" + txt_ans.Text;
                        //        MessageBox.Show(Data_send);
                        try
                        {
                            clientSocket.Connect(Variable.ipaddress, Variable.port);
                            STR_W           = new StreamWriter(clientSocket.GetStream());
                            STR_R           = new StreamReader(clientSocket.GetStream());
                            STR_W.AutoFlush = true;
                            Data_send       = "Profile_Change|" + txt_username.Text + "|" + txt_passwd.Text + "|" + txt_full_name.Text + "|" + txt_gender.Text + "|" + txt_location.Text + "|" + txt_Contact_no.Text + "|" + cb_security_qus.Text + "|" + txt_ans.Text;
                            if (clientSocket.Connected)
                            {
                                STR_W.WriteLine(Data_send);


                                string returndata;

                                returndata = STR_R.ReadLine();
                                //String returndata2 = STR_R.ReadLine();
                                //              MessageBox.Show(returndata);
                                //  MessageBox.Show(returndata2);
                                if (returndata == "Success")
                                {
                                    clientSocket.Close();
                                    if (Variable.gusertype == "admin")
                                    {
                                        this.Hide();
                                        AdminHome form2 = new AdminHome();
                                        form2.Closed += (s, args) => this.Close();
                                        form2.Show();
                                    }
                                    else if (Variable.gusertype == "secmgr")
                                    {
                                        this.Hide();
                                        SecurityManagerHome form2 = new SecurityManagerHome();
                                        form2.Closed += (s, args) => this.Close();
                                        form2.Show();
                                    }
                                    else if (Variable.gusertype == "enduser")
                                    {
                                        this.Hide();
                                        UserHome form2 = new UserHome();
                                        form2.Closed += (s, args) => this.Close();
                                        form2.Show();
                                    }
                                    // this.show_next_form();
                                }
                                if (returndata == "User already present")
                                {
                                    txt_passwd.Clear();
                                    txt_passwd_confirm.Clear();
                                    txt_username.Clear();
                                    clientSocket.Close();
                                    MessageBox.Show("Username is already present");

                                    this.Hide();
                                    Register form2 = new Register();
                                    form2.Closed += (s, args) => this.Close();
                                    form2.Show();
                                }
                            }
                        }
                        catch (Exception e1)
                        {
                            MessageBox.Show(e1.ToString());
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Must need to fill each field......!");
            }
        }