Exemplo n.º 1
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();
            }
        }
Exemplo n.º 2
0
        public AttachFileModel(hr_AttachFile file)
        {
            _attachFile = file ?? new hr_AttachFile();

            Id             = _attachFile.Id;
            RecordId       = _attachFile.RecordId;
            AttachFileName = _attachFile.AttachFileName;
            URL            = _attachFile.URL;
            SizeKB         = _attachFile.SizeKB;
            Note           = _attachFile.Note;
            IsApproved     = _attachFile.IsApproved;
            CreatedDate    = _attachFile.CreatedDate;
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        public void Update(hr_AttachFile obj)
        {
            var record = hr_AttachFileServices.GetById(obj.Id);

            if (record != null)
            {
                record.AttachFileName = obj.AttachFileName;
                record.Note           = obj.Note;
                record.CreatedBy      = obj.CreatedBy;
                record.CreatedDate    = obj.CreatedDate;
                record.EditedDate     = obj.EditedDate;
                record.SizeKB         = obj.SizeKB;
                record.URL            = obj.URL;
                record.IsApproved     = obj.IsApproved;
                record.RecordId       = obj.RecordId;
                hr_AttachFileServices.Update(obj);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="attach"></param>
 public void Insert(hr_AttachFile attach)
 {
     hr_AttachFileServices.Create(attach);
 }