Exemplo n.º 1
0
        /// <summary>
        /// @author : TrungMT
        /// @CreateDate:04/04/2008
        /// @Description: Process update data
        /// </summary>
        private bool UpdateData()
        {
            // Valid condition for update
            if (!ValidUpdate())
                return false;
            // Ask user is sure about update
            if (!MsgBoxVN.ShowConfirm(InternalGlobal.UPDATE_QUESTION_MSG, InternalGlobal.UPDATE_QUESTION_CAPTION))
                return false;
            try
            {
                // Update on data
                //BClip bClip = new BClip();
                //GetClipFromCtrl();
                //bClip.Update(mClip);

                // Check if user want to reupload clip on file server
                bool blnUploadNewFile = false;
                if (!txtURL.Text.Equals(mClip.URL))
                {
                    blnUploadNewFile = MsgBoxVN.ShowConfirm("Bạn đã đổi đường dẫn file!\n\r Vậy bạn muốn tải lại file khác lên server?", InternalGlobal.UPDATE_QUESTION_MSG);
                    if (!blnUploadNewFile)
                        txtURL.Text = mClip.URL;
                }

                // Get clip from control
                GetClipFromCtrl();

                // if upload new file
                if (blnUploadNewFile)
                {
                    Clip[] clips = new Clip[1];
                    FrmUploadClip frmUpload = new FrmUploadClip();
                    clips[0] = mClip;
                        frmUpload.UploadMode = FrmUploadClip.UPLOAD_MODE.RE_UPLOAD;
                        frmUpload.SetUploadClip(clips);
                        frmUpload.Init();
                        frmUpload.Start();
                        frmUpload.ShowDialog();
                }
                // if no, just update database, url no changed
                else
                {
                    BClip bClip = new BClip();
                    mClip.AutoSetUploadDate = false;
                    bClip.Update(mClip);
                }

                // Update some ui
                txtURL.Text = mClip.URL;
                txtType.Text = mClip.Type;

                // Update UI of parent form
                mfrmClip.UpdateClipUI(mClip);
                if (mClip.AutoSetUploadDate)
                    dteUploaDate.Value = mClip.UploadDate;

                // show success message and close form
                StoreItem();
                MsgBoxVN.ShowInfor(InternalGlobal.UPDATE_SUCCESS_MSG, InternalGlobal.UPDATE_QUESTION_CAPTION);
                Close();
                return true;
            }
            catch (Exception exp)
            {
                MsgBoxVN.ShowError(exp.Message,Dic.STRING_WARNING);
                return false;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// @author : TrungMT
        /// @CreateDate:04/04/2008
        /// @Description: Process add data
        /// </summary>
        private bool Add()
        {
            // Valid condition for add
            if (!ValidAdd())
                return false;
            try
            {
                // Add data
                //BClip bClip = new BClip();
                GetClipFromCtrl();
                Clip[] clips = new Clip[1];
                FrmUploadClip frmUpload = new FrmUploadClip();
                clips[0] = mClip;
                frmUpload.UploadMode = FrmUploadClip.UPLOAD_MODE.UPLOAD_NEW;
                frmUpload.SetUploadClip(clips);
                frmUpload.Init();
                frmUpload.Start();
                frmUpload.ShowDialog();

                if (mClip.ClipID >= 0)
                    mfrmClip.AddClipUI(mClip);
                dteUploaDate.Value = mClip.UploadDate;
                // Reinit component
                InitComponent();
                return true;

            }
            catch (Exception exp)
            {
                MsgBoxVN.ShowError(exp.Message,Dic.STRING_WARNING);
                return false;
            }
        }