private bool Save() { Common.GatherMemvar(this, ref this.drEdit); this.drEdit["File_Tag"] = this.lbtFile_Tag.Text; if (!this.FormCheckValid()) { return(false); } //if (DataTool.SQLCheckExist("SYSRESOURCES", "File_Id", this.drEdit["File_Id"].ToString())) //{ // EpointMessage.MsgOk("Mã tập tin bị trùng !"); // return false; //} if (!SQLExec.Execute("Sp_UpdateResource_Ver", drEdit, CommandType.StoredProcedure)) { return(false); } //Upload file SaveResource_UpdateFile.SaveFile(this.drEdit["File_Id"].ToString(), this.drEdit["File_Name"].ToString(), this.drEdit["Ma_Nhom"].ToString(), this.drEdit["Catalog"].ToString(), this.drEdit["File_Type"].ToString(), this.drEdit["File_Tag"].ToString(), this.objFileContent, (DateTime)this.drEdit["Ngay_Ky"], this.drEdit["Description"].ToString(), (bool)this.drEdit["Duyet"]); return(true); }
new public void Load(enuEdit enuNew_Edit, DataRow drEdit) { //this.drEdit = drEdit; //this.enuNew_Edit = enuNew_Edit; //this.Tag = (char)enuNew_Edit + ", " + this.Tag; this.cboFile_Type.DataSource = SQLExec.ExecuteReturnDt("SELECT DISTINCT 'DLL' AS File_Type UNION ALL SELECT DISTINCT 'RPX' AS File_Type UNION ALL SELECT DISTINCT 'DOC' AS File_Type UNION ALL SELECT DISTINCT 'PDF' AS File_Type UNION ALL SELECT DISTINCT 'IMG' AS File_Type UNION ALL SELECT DISTINCT 'XLS' AS File_Type UNION ALL SELECT DISTINCT 'EXE' AS File_Type "); this.cboFile_Type.DisplayMember = "File_Type"; this.cboFile_Type.ValueMember = "File_Type"; //Common.ScaterMemvar(this, ref drEdit); //this.ShowDialog(); this.drEdit = drEdit; this.enuNew_Edit = enuNew_Edit; this.Tag = ((char)((ushort)enuNew_Edit)) + ", " + this.Tag; Common.ScaterMemvar(this, ref drEdit); if (enuNew_Edit == enuEdit.Edit) { //Không cho phép sửa File_ID khi nhấn nút Sửa txtFile_Id.Enabled = false; this.cboFile_Type.Enabled = false; this.objFileContent = SaveResource_UpdateFile.LoadResource(this.drEdit["File_Id"].ToString()); if (this.objFileContent != null) { using (Stream stream = new MemoryStream()) { new BinaryFormatter().Serialize(stream, this.objFileContent); this.lblSize.Text = "(" + stream.Length.ToString() + ")"; } } } this.ShowImage(); this.BindingLanguage(); this.LoadDicName(); this.ShowDialog(); }
private void UploadFile() { OpenFileDialog dialog = new OpenFileDialog(); dialog.RestoreDirectory = true; dialog.Multiselect = true; dialog.Filter = "All files (*.*)|*.*"; if (dialog.ShowDialog() == DialogResult.OK) { foreach (string strFileName in dialog.FileNames) { this.objFileContent = File.ReadAllBytes(strFileName); string strTag = Path.GetExtension(strFileName).Substring(1).ToUpper(); string strFile_ID = System.IO.Path.GetFileName(strFileName); string strFile_Name = System.IO.Path.GetFileName(strFileName); //Upload file SaveResource_UpdateFile.SaveFile(strFile_ID, strFile_Name, "", "", strTag, strTag, this.objFileContent, DateTime.Now, "", true); } } }