private void btnDelete_Click(object sender, EventArgs e) { try { _RownIndex = grvData.FocusedRowHandle; if (grvData.DataSource == null) { return; } int id = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID)); if (id == 0) { return; } if (MessageBox.Show("Bạn có chắc muốn xóa file [" + grvData.GetFocusedRowCellValue(colName).ToString() + "] không?", TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } File3DModel model = (File3DModel)File3DBO.Instance.FindByPK(id); model.IsDeleted = true; File3DBO.Instance.Update(model); LoadInfoSearch(); } catch (Exception ex) { MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnChooseFile_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); if (_gModel.Type == 0) { ofd.Filter = "Files pcblib|*.pcblib"; } else { ofd.Filter = "Files schlib|*.schlib"; } ofd.Multiselect = true; if (ofd.ShowDialog() == DialogResult.OK) { foreach (string item in ofd.FileNames) { FileInfo fInfo = new FileInfo(item); if (Path.GetExtension(item).ToUpper() == ".pcblib".ToUpper() || Path.GetExtension(item).ToUpper() == ".schlib".ToUpper()) { File3DModel model = new File3DModel(); model.Datemodified = fInfo.LastWriteTime; model.Length = fInfo.Length; model.Name = Path.GetFileName(fInfo.FullName); model.Path = fInfo.FullName; model.ProductGroupID = TextUtils.ToInt(cboParent.SelectedValue); _listFileModel.Add(model); } } } loadGrid(); }
private void repositoryItemHyperLinkEdit1_Click_1(object sender, EventArgs e) { try { string action = grvData.GetFocusedRowCellValue(colAction).ToString(); string path = ""; File3DModel model = (File3DModel)File3DBO.Instance.FindByPK(ID); DateTime date = TextUtils.ToDate(grvData.GetFocusedRowCellValue(colDate).ToString()); if (action == "Thêm mới") { path = model.Path; } else { path = model.Path.Replace(model.Name, date.ToString("dd-MM-yyyy") + @"\" + model.Name).Trim(); } FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.Description = "Chọn nơi lưu trữ"; if (fbd.ShowDialog() == DialogResult.OK) { _hu = fbd.SelectedPath + @"\" + Path.GetFileName(path); File.Copy(path, _hu, true); MessageBox.Show("Tải file xuống thành công!"); } } catch (Exception ex) { TextUtils.ShowError(ex); } }
private void btnChooseFile_Click(object sender, EventArgs e) { if (cboParent.Text == "Datasheet") { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "File pdf|*.pdf|All File|*.*"; ofd.Multiselect = true; if (ofd.ShowDialog() == DialogResult.OK) { foreach (string item in ofd.FileNames) { FileInfo fInfo = new FileInfo(item); File3DModel model = new File3DModel(); model.Datemodified = fInfo.LastWriteTime; model.Length = fInfo.Length; model.Name = Path.GetFileName(fInfo.FullName); model.Path = fInfo.FullName; model.ProductGroupID = TextUtils.ToInt(cboParent.SelectedValue); _listFileModel.Add(model); } } } else { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "File .ipt|*ipt|All File|*.*"; ofd.Multiselect = false; if (ofd.ShowDialog() == DialogResult.OK) { if (cboParent.Text != Path.GetFileNameWithoutExtension(ofd.FileName)) { MessageBox.Show("Tên của file phải giống tên sản phẩm", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } FileInfo fInfo = new FileInfo(ofd.FileName); File3DModel model = new File3DModel(); model.Datemodified = fInfo.LastWriteTime; model.Length = fInfo.Length; model.Name = Path.GetFileName(fInfo.FullName); model.Path = fInfo.FullName; model.ProductGroupID = TextUtils.ToInt(cboParent.SelectedValue); _listFileModel.Add(model); } } loadGrid(); }
private void btnDeleteApprove_Click(object sender, EventArgs e) { ProcessTransaction pt = new ProcessTransaction(); pt.OpenConnection(); pt.BeginTransaction(); try { for (int i = 0; i < grvData.RowCount; i++) { if (grvData.DataSource == null) { return; } int id = TextUtils.ToInt(grvData.GetRowCellValue(i, colID)); if (id == 0) { return; } File3DModel model = (File3DModel)File3DBO.Instance.FindByPK(id); if (!model.IsDeleted) { continue; } if (MessageBox.Show("Bạn có chắc muốn duyệt xóa file [" + grvData.GetFocusedRowCellValue(colName).ToString() + "] ?", TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { continue; } pt.Delete("File3D", id); File.Delete(model.Path); } pt.CommitTransaction(); LoadInfoSearch(); } catch (Exception ex) { MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { pt.CloseConnection(); } }
private void btnSave_Click(object sender, EventArgs e) { ProcessTransaction pt = new ProcessTransaction(); pt.OpenConnection(); pt.BeginTransaction(); progressBar1.Visible = true; progressBar1.Minimum = 0; progressBar1.Maximum = grvData.RowCount; progressBar1.Value = 0; for (int i = 0; i < grvData.RowCount; i++) { try { string filePath = Path.Combine(_dPath, grvData.GetRowCellValue(i, colName).ToString()); if (filePath != grvData.GetRowCellValue(i, colPath).ToString()) { FileInfo fi = new FileInfo(filePath); if (File.Exists(filePath)) { DialogResult result = MessageBox.Show("Đã tồn tại file: [" + grvData.GetRowCellValue(i, colName).ToString() + "] trên thư viện." + Environment.NewLine + "Bạn có muốn upload file không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { //Tạo một folder chứa file cũ string folderPath = Path.GetDirectoryName(filePath) + @"\" + DateTime.Now.ToString("dd-MM-yyyy"); Directory.CreateDirectory(folderPath); File.Copy(filePath, folderPath + @"\" + fi.Name, true); File.Delete(filePath); File.Copy(grvData.GetRowCellValue(i, colPath).ToString(), filePath, true); } } else { File.Copy(grvData.GetRowCellValue(i, colPath).ToString(), Path.Combine(_dPath, grvData.GetRowCellValue(i, colName).ToString())); } } //Kiểm tra đã có trong cơ sở dữ liệu hay chưa ArrayList listFile = new ArrayList(); try { listFile = File3DBO.Instance.FindByExpression(new Expression("Name", Path.GetFileName(filePath)) .And(new Expression("ProductGroupID", _gModel.ID))); } catch (Exception) { } if (listFile.Count == 0) { File3DModel model = new File3DModel(); model.Datemodified = TextUtils.ToDate(grvData.GetRowCellValue(i, colDatemodified).ToString()); model.Length = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colLength)); model.Name = Path.GetFileName(grvData.GetRowCellValue(i, colPath).ToString()); model.ProductGroupID = CatID; model.Path = @"" + filePath; pt.Insert(model); } else { File3DModel model1 = (File3DModel)listFile[0]; model1.Length = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colLength)); model1.Datemodified = TextUtils.ToDate(grvData.GetRowCellValue(i, colDatemodified).ToString()); pt.Update(model1); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Lỗi"); continue; } progressBar1.Value += i; } progressBar1.Visible = false; pt.CommitTransaction(); pt.CloseConnection(); MessageBox.Show("Lưu trữ thành công.", "Thông báo"); DialogResult = DialogResult.OK; }
protected File3DFacade(File3DModel model) : base(model) { }