private void bt_refresh_Click(object sender, EventArgs e) { Variable.Tab_sec = Variable.Tab_default; AdminHome form2 = new AdminHome(); form2.Closed += (s, args) => this.Close(); form2.Show(); }
private void bt_delete_SM_Click(object sender, EventArgs e) { Variable.Tab_sec = Variable.Tab_default; //int sm_id=0; //sm_id = int.Parse(cb_sm_list.SelectedValue.ToString()); // MessageBox.Show("inside delete"); if (Variable.sm_id == "0") { MessageBox.Show("Need to select Security Manager Before Delete Operation"); } else { Data_send = "Admin_Delete_SM|" + Variable.gusername + "|" + Variable.sm_id; // MessageBox.Show(Data_send); 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("Selected Security manager has been deleted"); this.Hide(); //MessageBox.Show("User has been successfully Logout"); AdminHome form2 = new AdminHome(); form2.Closed += (s, args) => this.Close(); form2.Show(); } else { MessageBox.Show("Error in Operations"); } clientSocket2.Close(); } } catch (Exception e1) { MessageBox.Show(e1.ToString()); clientSocket2.Close(); } } }
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(); } }
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(); } }
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_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()); } }
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......!"); } }
private void bt_SM_halt_changes_Click(object sender, EventArgs e) { String Data; String I1 = "0"; foreach (DataGridViewColumn dc in dgv_sm_work_detail.Columns) { if (dc.HeaderText == "Security Manager Status Change") { I1 = dc.Index.ToString(); // MessageBox.Show(I1); } } String halt_sm_id = "0"; String allow_sm_id = "0"; foreach (DataGridViewRow row in dgv_sm_work_detail.Rows) { if (row.Cells["userid"].Value == DBNull.Value) { } else { Data = (String)row.Cells["userid"].Value; // MessageBox.Show(Data); Data = (String)row.Cells[int.Parse(I1)].Value; // MessageBox.Show(Data); if (Data == "Allow") { Data = (String)row.Cells["userid"].Value; allow_sm_id = allow_sm_id + "," + Data.Trim(); } if (Data == "Halt") { Data = (String)row.Cells["userid"].Value; halt_sm_id = halt_sm_id + "," + Data.Trim(); } } } Data_send = "Admin_Sm_Halt|" + Variable.gusername + "|" + allow_sm_id + "|" + halt_sm_id; /* Variable.Tab_sec = Variable.Tab_default; * if (Variable.Tab_sec.Columns.Count > 0) * { * Variable.Tab_sec.Reset(); * }*/ //MessageBox.Show(Data_send); 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("Security Manager Status updated in database"); clientSocket2.Close(); this.Hide(); AdminHome form2 = new AdminHome(); 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()); } }