/// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void EditAsset_Click(object sender, DirectEventArgs e)
        {
            if (!int.TryParse(hdfKeyRecord.Text, out var id) || id <= 0)
            {
                return;
            }
            var attachFile = AttachFileController.GetById(id);

            if (attachFile != null)
            {
                cbxSelectedEmployee.Text   = attachFile.FullName;
                hdfEmployeeSelectedId.Text = attachFile.RecordId.ToString();
                txtAttachFileName.Text     = attachFile.AttachFileName;
                txtNote.Text       = attachFile.Note;
                hdfAttachFile.Text = attachFile.URL;
            }

            // show window
            btnUpdate.Show();
            btnUpdateNew.Hide();
            btnUpdateClose.Hide();
            cbxSelectedEmployee.Disabled = true;
            wdAttachFile.Title           = @"Cập nhật thông tin tệp tin đính kèm";
            wdAttachFile.Show();
        }
Exemple #2
0
        protected void InsertOrUpdate(object sender, DirectEventArgs e)
        {
            try
            {
                var controller = new AttachFileController();
                var attachFile = new hr_AttachFile();
                // var util = new Util();
                attachFile.AttachFileName = txtAttachFileName.Text;
                attachFile.Note           = txtNote.Text;
                if (!string.IsNullOrEmpty(hdfEmployeeSelectedId.Text))
                {
                    attachFile.RecordId = Convert.ToInt32(hdfEmployeeSelectedId.Text);
                }
                attachFile.CreatedDate = DateTime.Now;
                attachFile.EditedDate  = DateTime.Now;
                // upload file
                string path = string.Empty;
                if (file_cv.HasFile)
                {
                    path = UploadFile(file_cv, Constant.PathAttachFile);
                }

                if (path != "")
                {
                    attachFile.URL = path;
                    HttpPostedFile file = file_cv.PostedFile;
                    attachFile.SizeKB = file.ContentLength / 1024;
                }
                else
                {
                    attachFile.URL    = hdfAttachFile.Text;
                    attachFile.SizeKB = double.Parse(hdfFileSizeKB.Text);
                }

                if (e.ExtraParams["Command"] == "Update")
                {
                    if (!string.IsNullOrEmpty(hdfKeyRecord.Text))
                    {
                        attachFile.Id = Convert.ToInt32(hdfKeyRecord.Text);
                        controller.Update(attachFile);
                    }
                }
                else
                {
                    controller.Insert(attachFile);
                }

                if (e.ExtraParams["Close"] == "True")
                {
                    wdAttachFile.Hide();
                }

                //reload data
                gridAttachFile.Reload();
            }
            catch (Exception ex)
            {
                ExtNet.MessageBox.Alert("Có lỗi xảy ra", ex.Message).Show();
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="directEventArgs"></param>
 protected void Delete(object sender, DirectEventArgs directEventArgs)
 {
     try
     {
         if (!int.TryParse(hdfKeyRecord.Text, out var id) || id <= 0)
         {
             return;
         }
         AttachFileController.Delete(id);
         gridAttachFile.Reload();
         RM.RegisterClientScriptBlock("Grid_Reload", "ReloadGrid();");
     }
     catch (Exception ex)
     {
         Dialog.Alert("Có lỗi xảy ra trong quá trình xóa: {0}".FormatWith(ex.Message));
     }
 }