Esempio n. 1
0
        /// <summary>
        /// @author : TrungMT
        /// @CreateDate:04/04/2008
        /// @Description: Process add Clip in UI
        /// </summary>
        /// <param name="pClip">Clip</param>
        public void AddClipUI(Clip pClip)
        {
            // Add row to grid
            DataRow row = ((DataView)mdgrClip.DataSource).Table.NewRow();
            row["Clip_ID"] = pClip.ClipID;
            row["CODE"] = pClip.Code;
            row["NAME"] = pClip.Name;
            row["CUSTOMER_ID"] = pClip.CustomerID;
            row["URL"] = pClip.URL;
            row["UPLOAD_DATE"] = pClip.UploadDate;
            row["LENGTH"] = pClip.Length;
            row["DESCRIPTION"] = pClip.Description;
            row["TYPE"] = pClip.Type;
            row["CUSTOMER_NAME"] = pClip.CustomerName;
            row["LOCAL_NAME"] = pClip.LocalName;
            row["##STT##"] = mdgrClip.Rows.Count + 1;
            ((DataView)mdgrClip.DataSource).Table.Rows.Add(row);

            // change current row to last row
            mdgrClip.CurrentCell = mdgrClip.Rows[mdgrClip.RowCount - 1].Cells[0];
            mdgrClip.CurrentRow.Selected = true;
            SetButtonStatus();

            //GenSTT();
        }
Esempio n. 2
0
        /// <summary>
        /// @author : TrungMT
        /// @CreateDate:04/03/2008
        /// @Description: Create new Clip and return Clip id auto increment
        /// </summary>
        /// <param name="pClip">Clip</param>
        public int Create(Clip pClip)
        {
            IDbDataParameter[] parameters = {
                MakeParameter("@Code", DbType.String, 10),
                MakeParameter("@Name", DbType.String, 400),
                MakeParameter("@CUSTOMER_ID", DbType.Int32, 4),
                MakeParameter("@URL", DbType.String, 1000),
                MakeParameter("@UPLOAD_DATE", DbType.DateTime, 18),
                MakeParameter("@LENGTH", DbType.String, 8),
                MakeParameter("@DESCRIPTION", DbType.String, 400),
                MakeParameter("@TYPE", DbType.String, 10),
                MakeParameter("@LOCAL_NAME", DbType.String, 1000)
            };

            parameters[0].Value = pClip.Code;
            parameters[1].Value = pClip.Name;
            parameters[2].Value = pClip.CustomerID;
            parameters[3].Value = pClip.URL;
            parameters[4].Value = pClip.AutoSetUploadDate ? (object)DBNull.Value : (object) pClip.UploadDate;
            parameters[5].Value = pClip.Length;
            parameters[6].Value = pClip.Description;
            parameters[7].Value = pClip.Type;
            parameters[8].Value = pClip.LocalName;
            int rowAffected = 0;
            return RunProcedure("sp_ADV_Clip_INSERT", parameters, out rowAffected);
        }
Esempio n. 3
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/04/2008
 /// @Description: Constrctor to update selected Clip
 /// </summary>
 public FrmClipItem(FrmClip frmClip, Clip pClip)
     : this()
 {
     mfrmClip = frmClip;
     mClip = pClip;
     //mOldClip = System.Clo
     mblnUpdate = true;
     this.Text = "Cap nhat clip";
 }
Esempio n. 4
0
        /// <summary>
        /// @author : TrungMT
        /// @CreateDate:04/03/2008
        /// @Description: Delete 1 Clip with Clip_id
        /// </summary>
        /// <param name="pClip">Clip</param>
        public int Delete(Clip pClip)
        {
            IDbDataParameter[] parameters = {
                MakeParameter("@Clip_ID", DbType.Int32, 10)
            };

            parameters[0].Value = pClip.ClipID;
            int rowAffected = 0;
            RunProcedure("sp_ADV_Clip_DELETE", parameters, out rowAffected);
            return rowAffected;
        }
Esempio n. 5
0
        /// <summary>
        /// @author : TrungMT
        /// @CreateDate:04/07/2008
        /// @Description: Upload 1 clip
        /// </summary>
        /// <param name="pClip">Clip</param>
        private void UploadOneFile(Clip pClip)
        {
            try
            {
                // Clear the url stored to db, just wait until file update okie
                String pstrLocalFilePath = pClip.URL;
                SetProcessingLabel("Uploading: " + pClip.Code + " - " + pClip.Name + " - " + pstrLocalFilePath);
                //pClip.URL = "";

                // Get local file infor
                FileInfo fileInfo = new FileInfo(pstrLocalFilePath);
                // check is file exists
                if (!fileInfo.Exists)
                    throw new Exception("Không tìm thấy file để tải lên server.");

                pClip.LocalName = fileInfo.Name;

                // If this is upload new one, must have clip_id for name of clip in file server
                if (UploadMode == UPLOAD_MODE.UPLOAD_NEW)
                {
                    pClip.ClipID = -1;
                    pClip.ClipID = bClip.Add(pClip);
                     // Define type and new server file name
                    pClip.Type = fileInfo.Extension;
                    pClip.URL = pClip.ClipID + fileInfo.Extension;
                    //pClip.AutoSetUploadDate = true;

                }
                // If this is reupload, must delete old clip then reupload
                else if (UploadMode == UPLOAD_MODE.RE_UPLOAD)
                {
                    // Delete old server file name
                    // ftpConnection.Delete

                    // Define type and new server file name
                    pClip.Type = fileInfo.Extension;
                    pClip.URL = pClip.ClipID + fileInfo.Extension;
                    //pClip.AutoSetUploadDate = true;
                }
                bClip.Update(pClip);

                // Uploading percentage is 0%
                SetProcessingValue(0);
                // Get file size init for update, and init total uploaded is 0 bytes
                long lFileSize = mftpConnection.InitStreamToUpload(pstrLocalFilePath, pClip.URL);
                int intUploaded = 0;
                long lTotalUploaded = 0;
                // If file size is zero
                if (lFileSize <= 0)
                {
                    // Every things is immediate 100%
                    //mftpConnection.UploadAllContent();
                    SetProcessingValue(100);
                    SetProcessingStyle(ProgressBarStyle.Marquee);
                }

                    do
                    {
                        // If pause clicked, wait
                        if (Pause)
                            continue;
                        if (Cancel)
                            return;
                        // Upload each part of content depend on buffer size
                        intUploaded = mftpConnection.UploadPartOfContent();
                        lTotalUploaded += intUploaded;
                        // Update processing percentage.
                        if (lFileSize > 0)
                            SetProcessingValue((int)((lTotalUploaded * 100) / lFileSize));
                    } while (intUploaded > 0);

            }
            catch (Exception exp)
            {
                throw exp;
            }
            finally
            {
                // release stream after using
                mftpConnection.ReleaseStream();
            }
        }
Esempio n. 6
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/07/2008
 /// @Description: Set clips arrau to upload
 /// </summary>
 /// <param name="pClips">Clip[]</param>
 public void SetUploadClip(Clip[] pClips)
 {
     mUploadClips = pClips;
     OverallMax = mUploadClips.Length;
     OverallMin = 0;
 }
Esempio n. 7
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/03/2008
 /// @Description: Update 1 Clip with Clip_id
 /// </summary>
 public int Update(Clip pClip)
 {
     PrClip Clip = new PrClip(Connection);
     int intRowAffected = 0;
     try
     {
         Open();
         intRowAffected = Clip.Update(pClip);
         if (pClip.AutoSetUploadDate)
             pClip.UploadDate = Qtc.Libs.Util.DBUtil.getDBSystemTime(Connection);
         Commit();
     }
     catch (Exception exp)
     {
         Rollback();
         throw exp;
     }
     finally
     {
         Close();
     }
     return intRowAffected;
 }
Esempio n. 8
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/03/2008
 /// @Description: Retrieves all Clip denpend on param
 /// </summary>
 public DataSet Retrieves(Clip pClip)
 {
     PrClip Clip = new PrClip(Connection);
     try
     {
         Open();
         return Clip.Search(pClip);
     }
     catch (Exception exp)
     {
         throw exp;
     }
     finally
     {
         Close();
     }
 }
Esempio n. 9
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/03/2008
 /// @Description: Delete 1 Clip with Clip_id
 /// </summary>
 public int Delete(Clip pClip)
 {
     PrClip Clip = new PrClip(Connection);
     int intRowAffected = 0;
     try
     {
         Open();
         intRowAffected = Clip.Delete(pClip);
         Commit();
     }
     catch (Exception exp)
     {
         Rollback();
         throw exp;
     }
     finally
     {
         Close();
     }
     return intRowAffected;
 }
Esempio n. 10
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/03/2008
 /// @Description: make search param depend on combo box
 /// </summary>
 private Clip MakeSearchParam()
 {
     Clip clip = new Clip();
     clip.ClipID = -1;
     clip.CustomerID = -1;
     clip.Code = (mcboSearch.SelectedIndex == 1) ? mtxtSearch.Text.Trim() : null;
     clip.Name = (mcboSearch.SelectedIndex == 2) ? mtxtSearch.Text.Trim() : null;
     clip.Type = (mcboSearch.SelectedIndex == 3) ? mtxtSearch.Text.Trim() : null;
     clip.CustomerCode = (mcboSearch.SelectedIndex == 4) ? mtxtSearch.Text.Trim() : null;
     clip.CustomerName = (mcboSearch.SelectedIndex == 5) ? mtxtSearch.Text.Trim() : null;
     clip.LocalName = (mcboSearch.SelectedIndex == 6) ? mtxtSearch.Text.Trim() : null;
     return clip;
 }
Esempio n. 11
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/04/2008
 /// @Description: Update new Clip in UI
 /// </summary>
 /// <param name="pClip">Clip</param>
 public void UpdateClipUI(Clip pClip)
 {
     // Update from data to row in grid
     mdgrClip.CurrentRow.Cells["Clip_ID"].Value = pClip.ClipID;
     mdgrClip.CurrentRow.Cells["CODE"].Value = pClip.Code;
     mdgrClip.CurrentRow.Cells["NAME"].Value = pClip.Name;
     mdgrClip.CurrentRow.Cells["CUSTOMER_ID"].Value = pClip.CustomerID;
     mdgrClip.CurrentRow.Cells["URL"].Value = pClip.URL;
     mdgrClip.CurrentRow.Cells["UPLOAD_DATE"].Value = pClip.UploadDate;
     mdgrClip.CurrentRow.Cells["LENGTH"].Value = pClip.Length;
     mdgrClip.CurrentRow.Cells["DESCRIPTION"].Value = pClip.Description;
     mdgrClip.CurrentRow.Cells["TYPE"].Value = pClip.Type;
     mdgrClip.CurrentRow.Cells["CUSTOMER_NAME"].Value = pClip.CustomerName;
     mdgrClip.CurrentRow.Cells["LOCAL_NAME"].Value = pClip.LocalName;
 }
Esempio n. 12
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/04/2008
 /// @Description: Get current Clip from grid
 /// </summary>
 /// <param name="return">Clip</param>
 public Clip GetCurrentClip()
 {
     // Get current row data into Clip
     Clip Clip = new Clip();
     Clip.ClipID = ((Int32)mdgrClip.CurrentRow.Cells["Clip_ID"].Value);
     Clip.Name = (String)mdgrClip.CurrentRow.Cells["NAME"].Value;
     Clip.Code = (String)mdgrClip.CurrentRow.Cells["CODE"].Value;
     Clip.CustomerID = (Int32)mdgrClip.CurrentRow.Cells["CUSTOMER_ID"].Value;
     Clip.URL = (String)mdgrClip.CurrentRow.Cells["URL"].Value;
     Clip.UploadDate = (DateTime)mdgrClip.CurrentRow.Cells["UPLOAD_DATE"].Value;
     Clip.Length = (string)mdgrClip.CurrentRow.Cells["LENGTH"].Value;
     Clip.Description = (String)mdgrClip.CurrentRow.Cells["DESCRIPTION"].Value;
     Clip.Type = (String)mdgrClip.CurrentRow.Cells["TYPE"].Value;
     Clip.CustomerName = (String)mdgrClip.CurrentRow.Cells["CUSTOMER_NAME"].Value;
     Clip.LocalName = (String)mdgrClip.CurrentRow.Cells["LOCAL_NAME"].Value;
     // Return
     return Clip;
 }
Esempio n. 13
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;
            }
        }
Esempio n. 14
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;
            }
        }
Esempio n. 15
0
        /// <summary>
        /// @author : TrungMT
        /// @CreateDate:04/03/2008
        /// @Description: Searh all Clip
        /// </summary>
        public DataSet Search(Clip pClip)
        {
            IDbDataParameter[] parameters = {
                MakeParameter("@Clip_ID", DbType.Int32, 10),
                MakeParameter("@CLIP_CODE", DbType.String, 10),
                MakeParameter("@CLIP_NAME", DbType.String, 200),
                MakeParameter("@CUSTOMER_ID", DbType.Int32, 10),
                MakeParameter("@UPLOAD_DATE_TO", DbType.DateTime, 16),
                MakeParameter("@UPLOAD_DATE_FROM", DbType.DateTime, 16),
                MakeParameter("@DESCRIPTION", DbType.String, 1000),
                MakeParameter("@TYPE", DbType.String, 10),
                MakeParameter("@CUSTOMER_CODE", DbType.String, 10),
                MakeParameter("@CUSTOMER_NAME", DbType.String, 200),
                MakeParameter("@LOCAL_NAME", DbType.String, 1000),
            };

            parameters[0].Value = (pClip.ClipID < 0) ? (object)DBNull.Value : (object)pClip.ClipID;
            parameters[1].Value = (pClip.Code == null) ? (object)DBNull.Value : (object)pClip.Code;
            parameters[2].Value = (pClip.Name == null) ? (object)DBNull.Value : (object)pClip.Name;
            parameters[3].Value = (pClip.CustomerID < 0) ? (object)DBNull.Value : (object)pClip.CustomerID;
            parameters[4].Value = DBNull.Value;
            parameters[5].Value = DBNull.Value;
            parameters[6].Value = (pClip.Description == null) ? (object)DBNull.Value : (object)pClip.Description;
            parameters[7].Value = (pClip.Type == null) ? (object)DBNull.Value : (object)pClip.Type;
            parameters[8].Value = (pClip.CustomerCode == null) ? (object)DBNull.Value : (object)pClip.CustomerCode;
            parameters[9].Value = (pClip.CustomerName == null) ? (object)DBNull.Value : (object)pClip.CustomerName;
            parameters[10].Value = (pClip.LocalName == null) ? (object)DBNull.Value : (object)pClip.LocalName;

            return RunProcedure("sp_ADV_Clip_SELECT_SEARCH", parameters, "ADV_Clip");
        }