private void bt_refresh_entries_Click(object sender, EventArgs e) // On refresh Click Form gets refreshed
        {
            Variable.Tab_sec = Variable.Tab_default;



            this.Hide();
            SecurityManagerHome form3 = new SecurityManagerHome();

            form3.Closed += (s, args) => this.Close();
            form3.Show();
        }
Пример #2
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();
     }
 }
Пример #3
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();
     }
 }
Пример #4
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());
            }
        }
        private void bt_submit_changes_Click(object sender, EventArgs e)  // coding for Submit Button
        {
            String Data;
            String I1 = "0";

            foreach (DataGridViewColumn dc in dgv_review_data.Columns)
            {
                if (dc.HeaderText == "Review")
                {
                    I1 = dc.Index.ToString();
                    // MessageBox.Show(I1);
                }
            }

            String allowed_add_id      = "0";
            String allowed_comment_id  = "0";
            String rejected_add_id     = "0";
            String rejected_comment_id = "0";

            foreach (DataGridViewRow row in dgv_review_data.Rows)
            {
                Data = (String)row.Cells["userid"].Value;
                // MessageBox.Show(Data);

                Data = (String)row.Cells[int.Parse(I1)].Value;
                // MessageBox.Show(Data);

                if (row.Cells["userid"].Value == DBNull.Value)
                {
                }
                else
                {
                    if (Data == "Allow")
                    {
                        Data = "";
                        Data = (String)row.Cells["Type"].Value;
                        // MessageBox.Show(Data);
                        if (Data == "add")
                        {
                            Data = "";
                            Data = (String)row.Cells["addid"].Value;
                            //  MessageBox.Show(Data);

                            allowed_add_id = allowed_add_id + "," + Data.Trim();
                        }
                        if (Data == "comment")
                        {
                            Data = "";
                            Data = (String)row.Cells["commentid"].Value;
                            // MessageBox.Show(Data);
                            allowed_comment_id = allowed_comment_id + "," + Data.Trim();
                        }
                    }
                    if (Data == "Reject")
                    {
                        Data = "";
                        Data = (String)row.Cells["Type"].Value;
                        //  MessageBox.Show(Data);
                        if (Data == "add")
                        {
                            Data = "";
                            Data = (String)row.Cells["addid"].Value;
                            //     MessageBox.Show(Data);

                            rejected_add_id = rejected_add_id + "," + Data.Trim();
                        }
                        if (Data == "comment")
                        {
                            Data = "";
                            Data = (String)row.Cells["commentid"].Value;
                            MessageBox.Show(Data);
                            rejected_comment_id = rejected_comment_id + "," + Data.Trim();
                        }
                    }
                }
            }

            Data_send = "SM_ALLOW|" + Variable.gusername + "|" + allowed_add_id + "|" + allowed_comment_id + "|" + rejected_add_id + "|" + rejected_comment_id; // sending all id to server
            //MessageBox.Show(Data_send); // sending data to server
            try
            {
                clientSocket2.Connect(Variable.ipaddress, Variable.port);
                STR_W           = new StreamWriter(clientSocket2.GetStream());
                STR_R           = new StreamReader(clientSocket2.GetStream());
                STR_W.AutoFlush = true;
                if (clientSocket2.Connected)
                {
                    STR_W.WriteLine(Data_send);
                    string returndata;

                    returndata = STR_R.ReadLine();

                    if (returndata == "Success")
                    {
                        MessageBox.Show("Review add & comments are updated in database");
                        clientSocket2.Close();

                        Variable.Tab_sec = Variable.Tab_default;


                        this.Hide();
                        SecurityManagerHome form2 = new SecurityManagerHome();
                        form2.Closed += (s, args) => this.Close();
                        form2.Show();
                    }
                    else
                    {
                        MessageBox.Show("Error in updating in database");
                        clientSocket2.Close();
                    }
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.ToString());
            }
        }
Пример #6
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());
            }
        }
Пример #7
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......!");
            }
        }