private void Scan(string name) { try { Nwuram.Framework.scan.scanImg fImg = new Nwuram.Framework.scan.scanImg(); fImg.ShowDialog(); this.TopMost = true; byte[] img_array = fImg.img_array; this.TopMost = false; if (img_array != null) { if (isLandLoard) { frmNameFile frmNF = new frmNameFile(); if (DialogResult.OK != frmNF.ShowDialog()) { return; } name = frmNF.getComment; } byte[] byteFile = img_array; saveFileToDataBase(byteFile, name, ".jpg", doc_Type, date_doc); //} } } catch { MessageBox.Show("Ошибка при работе со сканером!"); } }
private void btEditName_Click(object sender, EventArgs e) { int indexRow = dgvScan.CurrentRow.Index; frmNameFile frmNF = new frmNameFile(); frmNF.getComment = dtScan.DefaultView[indexRow]["cName"].ToString(); if (DialogResult.OK == frmNF.ShowDialog()) { if (id_Doc != 0 && dtScan != null && dtScan.DefaultView.Count > 0 && dgvScan.CurrentRow != null) { int ind = dgvScan.CurrentRow.Index; int id = int.Parse(dtScan.DefaultView[ind]["id"].ToString()); if (dtScan.DefaultView[indexRow]["Path"] != DBNull.Value) { string oldName = dtScan.DefaultView[indexRow]["Path"].ToString() + "\\" + dtScan.DefaultView[indexRow]["cName"].ToString() + dtScan.DefaultView[indexRow]["Extension"].ToString(); string newName = dtScan.DefaultView[indexRow]["Path"].ToString() + "\\" + frmNF.getComment + dtScan.DefaultView[indexRow]["Extension"].ToString(); if (File.Exists(oldName)) { try { File.Move(oldName, newName); } catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); } } } lRename.Add(id); } string fileName = frmNF.getComment; dtScan.DefaultView[indexRow]["cName"] = fileName; dtScan.AcceptChanges(); } }