private void panChat_DragDrop(object sender, DragEventArgs e) { try { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { var files = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (var filePath in files) { FileInfo F = new FileInfo(filePath); int isfolder = DBase.IsFolder(filePath); if (isfolder == 1) { continue; } byte[] content = new byte[3]; content = System.IO.File.ReadAllBytes(filePath); dtitem.Rows[0]["TYPE"] = F.Extension; dtitem.Rows[0]["FILENAME"] = F.Name; dtitem.Rows[0]["THUMBNAIL"] = new byte[3]; if (F.Extension.ToUpper() == ".JPG" || F.Extension.ToUpper() == ".PNG" || F.Extension.ToUpper() == ".BMP" || F.Extension.ToUpper() == ".GIF") { try { dtitem.Rows[0]["THUMBNAIL"] = DBase.ImageToByte(DBase.ResizeImage(Image.FromFile(filePath), 50, 50)); } catch (Exception ex) { continue; } } else { try { dtitem.Rows[0]["THUMBNAIL"] = DBase.ImageToByte(Icon.ExtractAssociatedIcon(filePath).ToBitmap()); } catch (Exception ex) { continue; } } dtitem.Rows[0]["TEXT"] = Text; dtitem.Rows[0]["CDATETIME"] = DHuy.GetServerTime(); dtitem.Rows[0]["FILEDATA"] = content; int kq = DHuy.INSERT_IDENTITY("CHAT", dtitem); if (kq > 0) { edtChat.Focus(); edtChat.Text = ""; RefreshChat_Append(); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void Save_Click(object sender, EventArgs e) { foreach (Control C in this.Controls) { if (C.GetType() == typeof(PictureBox)) { try { try { dt.Rows[0][C.Name.Replace("edt", "")] = new byte[3]; dt.Rows[0][C.Name.Replace("edt", "")] = DBase.ImageToByte(((PictureBox)C).Image); } catch (Exception ex) { } } catch (Exception ex) { } } } int kq = 0; if (type == 0 || Clone == 1) { kq = (int)DHuy.INSERT_IDENTITY(TableName, dt); if (kq > 0) { MessageBox.Show("Insert Succesful!"); if (Parent != null) { Parent.RefreshInsert(kq.ToString()); } this.Close(); } } else if (type == 1) { kq = DHuy.UPDATE(TableName, dt, KEYCOL); if (kq > 0) { MessageBox.Show("Saved!"); if (Parent != null) { Parent.RefreshSelect(); } this.Close(); } } }
private void Save_Click(object sender, EventArgs e) { DataTable dt = DHuy.SELECT_NEWROW("USER_PCS"); dt.Rows[0]["ID"] = ID; dt.Rows[0]["USERCODE"] = USERCODE; dt.Rows[0]["PCS_ID"] = edtPCS_ID.Text; dt.Rows[0]["PASS"] = edtPass.Text; if (edtPass.Text == "") { dt.Rows[0]["PASS"] = ""; } else { dt.Rows[0]["PASS"] = DHuy.HideFood(edtPass.Text, "ForTheWin", new byte[256]); } dt.Rows[0]["PCS_NAME"] = edtPCS_NAME.Text; int kq = 0; if (isUpdate == 0) { kq = DHuy.INSERT_IDENTITY("USER_PCS", dt); } else { if (ID > 0) { kq = DHuy.UPDATE("USER_PCS", dt, "ID"); } } if (kq > 0) { Res = 1; // MessageBox.Show("Saved!"); this.Close(); } }
private void btnOK_Click(object sender, EventArgs e) { Text = edtChat.Text; if (Text.Replace(" ", "") == "") { return; } dtitem.Rows[0]["TEXT"] = Text; dtitem.Rows[0]["TYPE"] = ""; dtitem.Rows[0]["FILENAME"] = ""; dtitem.Rows[0]["FILEDATA"] = new byte[3]; dtitem.Rows[0]["THUMBNAIL"] = new byte[3]; dtitem.Rows[0]["CDATETIME"] = DHuy.GetServerTime(); int kq = DHuy.INSERT_IDENTITY("CHAT", dtitem); if (kq > 0) { edtChat.Focus(); edtChat.Text = ""; RefreshChat_Append(); } }