示例#1
0
        //Display data into gridview when DataSet!=null
        private void BindData()
        {
            //tgridViewTable.FilterActive = true;
            tgridViewTable.FilterBar = true;
            MST_SearchPartyBO objBO = new MST_SearchPartyBO();

            tgridViewTable.EditActive  = true;
            tgridViewTable.DataChanged = true;
            tgridViewTable.AllowSort   = true;
            tgridViewTable.ForeColor   = System.Drawing.Color.LemonChiffon;
            tgridViewTable.DataSource  = dset.Tables[0];
            for (int i = 0; i < tgridViewTable.Splits[0].DisplayColumns.Count; i++)
            {
                tgridViewTable.Splits[0].DisplayColumns[i].Locked = true;
                tgridViewTable.Splits[0].DisplayColumns[i].AutoSize();
                if (dset.Tables[0].Columns[i].DataType == typeof(DateTime))
                {
                    tgridViewTable.Splits[0].DisplayColumns[i].DataColumn.NumberFormat = Constants.DATETIME_FORMAT;
                }
            }
            tgridViewTable.Splits[0].DisplayColumns[0].Locked = !SelectMultiRow;
            tgridViewTable.AllowUpdate = SelectMultiRow;
            tgridViewTable.AllowAddNew = false;
            tgridViewTable.AllowDelete = false;
            tgridViewTable.Row         = 0;
            tgridViewTable.Col         = 1;
            tgridViewTable.Focus();
        }
示例#2
0
        //Generate to Command SQL
        private void GetAll()
        {
            strCondition = strOnlyHashTable;
            MST_SearchPartyBO objBO = new MST_SearchPartyBO();

            iCurrentPage = 1;
            TotalRecord  = objBO.GetRowCount(strTable, strCondition);
            GetNumberOfPage();
            dset = objBO.GetList(strTable, strKeyWord, SelectMultiRow, strCondition, iCurrentPage, PCSComUtils.Common.Constants.CountPage);
            BindData();
        }
示例#3
0
        private void btnMove_Click(object sender, EventArgs e)
        {
            if (iCurrentPage == cmbPage.SelectedIndex + 1)
            {
                return;
            }
            iCurrentPage = cmbPage.SelectedIndex + 1;
            MST_SearchPartyBO objBO = new MST_SearchPartyBO();

            dset = objBO.GetList(strTable, strKeyWord, SelectMultiRow, strCondition, iCurrentPage, PCSComUtils.Common.Constants.CountPage);
            BindData();
        }
示例#4
0
        //Load form
        private void SearchParty_Load(object sender, EventArgs e)
        {
            if (dset != null && dset.Tables.Count > 0)
            {
                InitCombobox();
                BindData();
                return;
            }
            if (string.IsNullOrEmpty(strKeyWord.Trim()))
            {
                MessageBox.Show("Hệ thống bị lỗi  xin vui lòng chuyền khóa chính của bảng", SystemProperty.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            strCondition = GenerateFilterConditionToSQL(strFiedValue, strFiedName, mHashtable);
            MST_SearchPartyBO objBO = new MST_SearchPartyBO();

            TotalRecord = objBO.GetRowCount(strTable, strCondition);
            GetNumberOfPage();
            dset = objBO.GetList(strTable, strKeyWord, SelectMultiRow, strCondition, iCurrentPage, PCSComUtils.Common.Constants.CountPage);
            InitCombobox();
            BindData();
            this.Text = strTable;
        }
示例#5
0
 private void tgridViewTable_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.F9)
     {
         ExportDataToExcel(); return;
     }
     if (e.KeyCode == Keys.F2)
     {
         iCurrentPage = 1;
         strCondition = strOnlyHashTable;
         MST_SearchPartyBO objBO = new MST_SearchPartyBO();
         TotalRecord = objBO.GetRowCount(strTable, strCondition);
         GetNumberOfPage();
         InitCombobox();
         dset = objBO.GetList(strTable, strKeyWord, SelectMultiRow, strCondition, iCurrentPage, PCSComUtils.Common.Constants.CountPage);
         BindData();
         ValueFilter = string.Empty; return;
     }
     if (GetTotalPage > 1 && (e.KeyCode == Keys.PageDown || e.KeyCode == Keys.PageUp || e.KeyCode == Keys.Home || e.KeyCode == Keys.End))
     {
         bool bContinue = false;
         if (e.KeyCode == Keys.PageDown && GetTotalPage > iCurrentPage)
         {
             iCurrentPage++; bContinue = true;
         }
         if (e.KeyCode == Keys.PageUp && iCurrentPage > 1)
         {
             iCurrentPage--; bContinue = true;
         }
         if (e.KeyCode == Keys.Home && iCurrentPage > 1)
         {
             iCurrentPage = 1; bContinue = true;
         }
         if (e.KeyCode == Keys.End && iCurrentPage < GetTotalPage)
         {
             iCurrentPage = GetTotalPage; bContinue = true;
         }
         if (bContinue)
         {
             cmbPage.SelectedIndex = iCurrentPage - 1;
             MST_SearchPartyBO objBO = new MST_SearchPartyBO();
             dset = objBO.GetList(strTable, strKeyWord, SelectMultiRow, strCondition, iCurrentPage, PCSComUtils.Common.Constants.CountPage);
             BindData();
         }
     }
     //MessageBox.Show(tgridViewTable.Row.ToString());
     //e.KeyCode == Keys.F4
     if (tgridViewTable.FilterBar == true && !string.IsNullOrEmpty(ValueFilter) && e.KeyCode == Keys.Enter)
     {
         const string METHOD_NAME = ".tgridViewTable_KeyDown()";
         try
         {
             if (sender.Equals(mniContain))
             {
                 enmLike = LikeCondition.Contain;
             }
             else
             {
                 enmLike = sender.Equals(mniEndWith) ? LikeCondition.EndWith : LikeCondition.StartWith;
             }
             string strColoumName = tgridViewTable.Columns[tgridViewTable.Col].Caption;
             if (tgridViewTable.Col == 0)
             {
                 return;
             }
             string strColoumValue = string.Empty;
             strCondition = strOnlyHashTable;
             if (strCondition != null && strCondition.Length > 0)
             {
                 strCondition += " AND ";
             }
             strCondition += strColoumName + " like N'%" + ValueFilter + "%' ";
             iCurrentPage  = 1;
             strCondition  = FormControlComponents.KillInjectionInLikeClause(strCondition);
             MST_SearchPartyBO objBO = new MST_SearchPartyBO();
             TotalRecord = objBO.GetRowCount(strTable, strCondition);
             GetNumberOfPage();
             InitCombobox();
             dset = objBO.GetList(strTable, strKeyWord, SelectMultiRow, strCondition, iCurrentPage, PCSComUtils.Common.Constants.CountPage);
             BindData();
             ValueFilter = string.Empty;
         }
         catch (PCSException ex)
         {
             // Displays the error message if throwed from PCSException.
             PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
             try
             {
                 // Log error message into log file.
                 Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
             }
             catch
             {
                 // Show message if logger has an error.
                 PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
             }
         }
         catch (Exception ex)
         {
             // Displays the error message if throwed from system.
             PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
             try
             {
                 // Log error message into log file.
                 Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
             }
             catch
             {
                 // Show message if logger has an error.
                 PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
             }
         }
         return;
     }
     if (e.KeyCode == Keys.Enter)
     {
         GetDataRow();
     }
 }