示例#1
0
        public bool ShowHotSearch(ref string ErrMsg, params string[] LangIDs)
        {
            try
            {
                ErrMsg="";
                this.Text=m_Caption;

                strLangID = LangIDs;

                if (boolMultiLine == false)
                {
                    dgSelectedRecords.Visible = false;
                    panelMultiBtns.Visible = false;
                    if (boolLevelSearch)
                        panelLevel.Visible = true;

                    //dgRecords.Width = dgRecords.Width + 100;
                    //dgSearch.Width = dgSearch.Width + 100;
                    //panelLevel.Left = dgSearch.Width - panelLevel.Width;
                    this.panelStdBtns.Location = new System.Drawing.Point(93, 302);
                    this.Size = new System.Drawing.Size(352, 359);
                    this.grpData.Size = new Size(339, 298);
                    lblcomments.Visible = false;
                    //dgRecords.Width = dgSearch.Width;
                    btnRemove.Enabled = btnRemoveAll.Enabled = false;

                }
                else
                {
                    btnRemove.Enabled = btnRemoveAll.Enabled = false;
                    //dgRecords.MaximumSize = new Size(314, 296);
                    //dgSelectedRecords.MaximumSize = new Size(314, 296);
                    //this.BackColor = Color.SeaGreen;
                }
                dgRecords.SetDefault=false;
                //** To Prevent Sorting Special Functionality In HotSearcg Grids**/
                dgRecords.HandleGridSort = false;
                dgSelectedRecords.HandleGridSort = false;
                //** To Prevent Sorting Special Functionality In HotSearcg Grids**/
                dgRecords.LangIDs = LangIDs;
                if(dgRecords.DesignGridFromSQL( m_Sql,ref strErrMsg )==false)
                {
                    ErrMsg=strErrMsg;
                    return false;
                }

                //if (boolLevelSearch == true)
                //{
                //    //this.KeyDown += new KeyEventHandler(BackSpaceKeyDown);
                //    arlHierarchyLevel = new ArrayList();
                //    arlHierarchyValue = new ArrayList();
                //    arlPrimKey = new ArrayList();
                //}

                if( dtBeforeHotSearch != null )
                {
                    DataTable dtRecords = (DataTable)(dgRecords.DataSource);
                    clsSqlOperations objMinus = new clsSqlOperations();
                    System.Data.DataTable dtModified = objMinus.Minus( dtRecords, dtBeforeHotSearch, UK_HotSearch, UK_CurrentTable );
                    dgRecords.SetDataBinding(dtModified,"");
                    objMinus = null;
                }

                //if(dgSearch.DesignGrid(dgRecords,ref strErrMsg)==false)
                //{
                //    ErrMsg=strErrMsg;
                //    return false;
                //}

                dgRecords.MultiLine = boolMultiLine;
                dgSelectedRecords.MultiLine = boolMultiLine;

                dgSelectedRecords.SetDataBinding(((DataTable)dgRecords.DataSource).Clone(), "");
                //Debanjan Routh
                //The following code is added because the header text of the selected
                //grid was not coming coorect.The language converted text was not coming
                //Here the header text of the Records grid is simply copied to the
                //header text of the Selected Grid.
                for (int i = 0; i < dgSelectedRecords.Columns.Count; i++)
                {
                    dgSelectedRecords.Columns[i].HeaderText = dgRecords.Columns[i].HeaderText;
                }
                /////
                //dgRecords.AssociatedSearchGrid = dgSearch;
                //dgSearch.Focus();
                this.ShowDialog();
                return true;
            }
            catch(Exception ex)
            {
                ErrMsg=ex.Source + " - " + ex.Message;
                return false;
            }
        }
示例#2
0
        private void btnAdd_Click_1(object sender, EventArgs e)
        {
            try
            {
                object[] obj;
                CurrencyManager cmanag = (CurrencyManager)dgRecords.BindingContext[dgRecords.DataSource];
                if (cmanag.List.Count == 0)
                {
                    return;
                }
                DataRowView view = (DataRowView)cmanag.Current;
                DataTable dtnew = view.DataView.ToTable();
                DataTable dtMain = ((DataTable)dgRecords.DataSource).Clone();
                dtMain.BeginLoadData();
                dtMain.Merge(dtnew, true, MissingSchemaAction.Error);
                dtMain.EndLoadData();
                dtSelected = ((DataTable)dgSelectedRecords.DataSource).Copy();
                DataTable dtToBeRemoved = dtMain.Clone();
                ArrayList list = new ArrayList();
                for (int i = 0; i < dgRecords.SelectedRows.Count; i++)
                {
                    if (boolRestrictTo999Rows == true && dtSelected.Rows.Count == 999)
                        break;

                    DataGridViewRow selectedrow = dgRecords.SelectedRows[i];
                    int index = selectedrow.Index;
                    obj = new object[dtMain.Columns.Count];
                    for (int k = 0; k < dtMain.Columns.Count; k++)
                    {
                        obj[k] = dtMain.Rows[index][k].ToString();
                    }
                    dtToBeRemoved.LoadDataRow(obj, true);
                    dtSelected.LoadDataRow(obj, true);
                    list.Add(dtMain.Rows[i]);
                    dgRecords.Update();
                    obj = null;

                }

                clsSqlOperations objMinus = new clsSqlOperations();
                DataTable dtOutPut = objMinus.Minus(dtMain, dtToBeRemoved);
                objMinus = null;

                if (boolRestrictTo999Rows == true)
                {
                    if (dtSelected.Rows.Count == 999)
                        DisableEnableBtn(true);
                    else
                        DisableEnableBtn(false);
                }

                dtnew.AcceptChanges();
                dtMain.AcceptChanges();
                dgRecords.DataSource = dtOutPut;
                //dgRecords.dtFullData = dtOutPut;

                dgSelectedRecords.DataSource = reverse_datatable(dtSelected);
                //dgSearch.dataUpgrade(dtSelected);
                //lblcomments.Text = dtSelected.Rows.Count + " out of " + dgSearch.FullData.Rows.Count + " rows selected";
                dtMain.Dispose();
                dtSelected.Dispose();
                dtOutPut.Dispose();
                dtnew.Dispose();
                dtToBeRemoved.Dispose();
                dgRecords.Refresh();
                dgSelectedRecords.Refresh();
                GenerateCurrentData();
                this.btnRemove.Enabled = true;
                this.btnRemoveAll.Enabled = true;
                if (dgRecords.Rows.Count == 0)
                {
                    btnAdd.Enabled = false;
                    btnAddAll.Enabled = false;
                }
             }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message, "COMPONENT ERROR", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }
        }
示例#3
0
        private void GenerateCurrentData()
        {
            //clsSqlOperations _oper;
            //DataTable dtTemp ;
            ////DataTable dtTemp = ((DataTable)dgRecords.DataSource).Clone();

            //DataTable dtSelectedData = (DataTable)dgSelectedRecords.DataSource;
            //if (dtSelectedData.Rows.Count >0)
            //{
            //    _oper = new clsSqlOperations();
            //    dtTemp = _oper.Minus(dgRecords.dtFullData, dtSelectedData);
            //    dgRecords.dtCurrentData = dtTemp;
            //}
            //else
            //{
            //    dgRecords.dtCurrentData = dgRecords.dtFullData.Copy(); ;
            //}

                clsSqlOperations _oper;
                DataTable dtTemp;
                DataTable dtSelectedDataTemp = (DataTable)dgSelectedRecords.DataSource;
                DataTable dtSelectedData = dgRecords.dtFullData.Clone();
                object[] objRow;
                int i = 0;
                foreach (DataRow _row in dtSelectedDataTemp.Rows)
                {

                    objRow = new object[dtSelectedDataTemp.Columns.Count];
                    for (int k = 0; k < dtSelectedDataTemp.Columns.Count; k++)
                    {
                        //objRow[k] =(object)dgSelectedRecords.Rows[i].Cells[k].Value;
                        objRow[k] = (object)_row[k];
                    }
                    dtSelectedData.LoadDataRow(objRow, true);
                    i++;
                }

                if (dtSelectedData.Rows.Count > 0)
                {
                    _oper = new clsSqlOperations();
                    dtTemp = _oper.Minus(dgRecords.dtFullData, dtSelectedData);
                    dgRecords.dtCurrentData = dtTemp;
                }
                else
                {
                    dgRecords.dtCurrentData = dgRecords.dtFullData.Copy(); ;
                }
        }