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()); } }
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()); } }