private void button1_Click_1(object sender, EventArgs e) { if (Helper.Exists("client", "name", nameTxtBx.Text)) { MessageBox.Show("Client name exists"); return; } string clientID = 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\" + clientID.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\" + clientID.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 client(clientID, orgID, name, email, password, status, contact, image, address, created, sync,action, lawyer,registration) VALUES ('" + clientID + "','" + Helper.orgID + "','" + this.nameTxtBx.Text + "','" + this.emailTxtBx.Text + "','" + Helper.MD5Hash(this.passwordTxtBx.Text) + "','" + this.statusCbx.Text + "','" + this.contactTxtBx.Text + "','" + clientID.Trim() + ".jpg" + "','" + this.addressTxtBx.Text + "','" + DateTime.Now.Date.ToString("yyyy-MM-dd") + "','f','create','" + supervisorCbx.Text + "','" + Convert.ToDateTime(this.regDate.Text).ToString("yyyy-MM-dd") + "');"; Helper.Execute(Query, DBConnect.conn); MessageBox.Show("Information saved"); ClientForm frm = new ClientForm(); frm.MdiParent = MainForm.ActiveForm; frm.Show(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void toolStripButton4_Click(object sender, EventArgs e) { ClientForm frm = new ClientForm(); frm.MdiParent = this; frm.Dock = DockStyle.Fill; frm.Show(); }
private void toolStripButton1_Click_1(object sender, EventArgs e) { ClientForm frm = new ClientForm(); frm.MdiParent = MainForm.ActiveForm; frm.Show(); this.Close(); }
private void button3_Click_1(object sender, EventArgs e) { string fileID = Guid.NewGuid().ToString(); string Query = "DELETE from client WHERE clientID ='" + id + "'"; Helper.Execute(Query, DBConnect.conn); MessageBox.Show("Information deleted"); ClientForm frm = new ClientForm(); frm.MdiParent = MainForm.ActiveForm; frm.Dock = DockStyle.Fill; frm.Show(); this.Close(); }
private void updateBtn_Click_1(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 `client` SET `name`='" + this.nameTxtBx.Text + "',`email`='" + this.emailTxtBx.Text + "',`image`='" + id.Trim() + ".jpg" + "' ,`password`='" + Helper.MD5Hash(this.passwordTxtBx.Text) + "',`status`='" + this.statusCbx.Text + "',`contact`='" + this.contactTxtBx.Text + "',`address`='" + this.addressTxtBx.Text + "',`sync`='f',`lawyer`='" + supervisorCbx.Text + "',`action`='update' WHERE clientID = '" + id + "'"; } else { Query = "UPDATE `client` SET `name`='" + this.nameTxtBx.Text + "',`email`='" + this.emailTxtBx.Text + "',`image`='" + id.Trim() + ".jpg" + "',`status`='" + this.statusCbx.Text + "',`contact`='" + this.contactTxtBx.Text + "',`address`='" + this.addressTxtBx.Text + "',`sync`='f',`lawyer`='" + supervisorCbx.Text + "',`action`='update' WHERE clientID = '" + id + "'"; } Helper.Execute(Query, DBConnect.conn); MessageBox.Show("Information Updated"); ClientForm frm = new ClientForm(); frm.MdiParent = MainForm.ActiveForm; frm.Dock = DockStyle.Fill; frm.Show(); this.Close(); }