private void button2_Click_1(object sender, EventArgs e) { UserForm frm = new UserForm(); frm.MdiParent = MainForm.ActiveForm; frm.Show(); this.Close(); }
private void toolStripButton1_Click(object sender, EventArgs e) { UserForm frm = new UserForm(); frm.MdiParent = MainForm.ActiveForm; frm.Show(); this.Close(); }
private void toolStripButton1_Click_2(object sender, EventArgs e) { try { UserForm frm = new UserForm(); frm.MdiParent = this; frm.Dock = DockStyle.Fill; frm.Show(); } catch { } }
private void button3_Click(object sender, EventArgs e) { if (MessageBox.Show("Confirm or no?", "Confirm deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { string fileID = Guid.NewGuid().ToString(); string Query = "DELETE from user WHERE userID ='" + id + "'"; Helper.Execute(Query, DBConnect.conn); MessageBox.Show("Information deleted"); UserForm frm = new UserForm(); frm.MdiParent = MainForm.ActiveForm; frm.Dock = DockStyle.Fill; frm.Show(); this.Close(); } }
private void updateBtn_Click(object sender, EventArgs e) { string filename = @"c:\Case\\images\" + id.Trim() + ".jpg"; FileStream fstream = new FileStream(filename, FileMode.Create); imgCapture.Image.Save(fstream, System.Drawing.Imaging.ImageFormat.Jpeg); fstream.Close(); string image = @"c:\Case\\images\" + id.Trim() + ".jpg"; if (System.IO.File.Exists(image)) { try { string filepath = image; string localPath = new Uri(filepath).LocalPath; string remotePath = Helper.uploadUrl; WebClient theClient = new WebClient(); byte[] responseArray = theClient.UploadFile(remotePath, filepath); Console.WriteLine("\nResponse Received.The contents of the file uploaded are:\n{0}", System.Text.Encoding.ASCII.GetString(responseArray)); theClient.Dispose(); } catch (Exception c) { } } string Query; if (passwordTxtBx.Text != "") { Query = "UPDATE `users` SET `name`='" + this.nameTxtBx.Text + "',`email`='" + this.emailTxtBx.Text + "',`image`='" + id.Trim() + ".jpg" + "' ,`password`='" + Helper.MD5Hash(this.passwordTxtBx.Text) + "',`designation`='" + this.designationCbx.Text + "',`status`='" + this.statusCbx.Text + "',`contact`='" + this.contactTxtBx.Text + "',`address`='" + this.addressTxtBx.Text + "',`sync`='f',`charge`='" + this.chargeTxtBx.Text + "',`supervisor`='" + supervisorCbx.Text + "',`action`='update' WHERE userID = '" + id + "'"; } else { Query = "UPDATE `users` SET `name`='" + this.nameTxtBx.Text + "',`email`='" + this.emailTxtBx.Text + "',`image`='" + id.Trim() + ".jpg" + "',`designation`='" + this.designationCbx.Text + "',`status`='" + this.statusCbx.Text + "',`contact`='" + this.contactTxtBx.Text + "',`address`='" + this.addressTxtBx.Text + "',`sync`='f',`charge`='" + this.chargeTxtBx.Text + "',`supervisor`='" + supervisorCbx.Text + "',`action`='update' WHERE userID = '" + id + "'"; } Helper.Execute(Query, DBConnect.conn); MessageBox.Show("Information Updated"); UserForm frm = new UserForm(); frm.MdiParent = MainForm.ActiveForm; frm.Dock = DockStyle.Fill; frm.Show(); this.Close(); }
private void button1_Click(object sender, EventArgs e) { if (Helper.Exists("users", "name", nameTxtBx.Text)) { MessageBox.Show("User name exists"); return; } if (Helper.Exists("users", "contact", contactTxtBx.Text)) { MessageBox.Show("User contact exists"); return; } string userID = Guid.NewGuid().ToString(); string paths = @"c:\Case\images"; if (!Directory.Exists(paths)) { DirectoryInfo dim = Directory.CreateDirectory(paths); Console.WriteLine("The directory was created successfully at {0}.", Directory.GetCreationTime(paths)); } string filename = @"c:\Case\\images\" + userID.Trim() + ".jpg"; FileStream fstream = new FileStream(filename, FileMode.Create); imgCapture.Image.Save(fstream, System.Drawing.Imaging.ImageFormat.Jpeg); fstream.Close(); string image = @"c:\Case\\images\" + userID.Trim() + ".jpg"; if (System.IO.File.Exists(image)) { try { string filepath = image; string localPath = new Uri(filepath).LocalPath; string remotePath = Helper.uploadUrl; WebClient theClient = new WebClient(); byte[] responseArray = theClient.UploadFile(remotePath, filepath); Console.WriteLine("\nResponse Received.The contents of the file uploaded are:\n{0}", System.Text.Encoding.ASCII.GetString(responseArray)); theClient.Dispose(); } catch (Exception c) { } } try { string Query = "INSERT INTO users(userID, orgID, name, email, password, designation, status, contact, image, address, category, created, sync, charge, supervisor) VALUES ('" + userID + "','" + Helper.orgID + "','" + this.nameTxtBx.Text + "','" + this.emailTxtBx.Text + "','" + Helper.MD5Hash(this.passwordTxtBx.Text) + "','" + this.designationCbx.Text + "','" + this.statusCbx.Text + "','" + this.contactTxtBx.Text + "','" + userID.Trim() + ".jpg" + "','" + this.addressTxtBx.Text + "','staff','" + DateTime.Now.Date.ToString("yyyy-MM-dd") + "','f','" + this.chargeTxtBx.Text + "','" + supervisorCbx.Text + "');"; Helper.Execute(Query, DBConnect.conn); MessageBox.Show("Information saved"); UserForm frm = new UserForm(); frm.MdiParent = MainForm.ActiveForm; frm.Show(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }