Пример #1
0
        public void AddRow(DevExpress.XtraGrid.Views.Grid.GridView View)
        {
            int currentRow;

            currentRow = View.FocusedRowHandle;

            if (currentRow < 0)
            {
                currentRow = View.GetDataRowHandleByGroupRowHandle(currentRow);
            }

            //if (View.GroupedColumns.Count == 0)
            //    return;

            //string grp = View.GetRowCellValue(currentRow, colGRP).ToString();
            //GenelDataSet.XGTRow xgtRow = this.genelDataSet.XGT.FindByGRPID(grp, "+");

            View.AddNewRow();
            View.SetRowCellValue(View.FocusedRowHandle, colTUR, View.GetRowCellValue(currentRow, colTUR));

            //View.UpdateCurrentRow();
            View.MakeRowVisible(View.FocusedRowHandle, true);
            View.FocusedColumn = colTOP;
            View.ShowEditor();
        }
Пример #2
0
 private void toolStripMenuItemAdd_Click(object sender, EventArgs e)
 {
     if (CurrentgridView == null)
     {
         return;
     }
     CurrentgridView.AddNewRow();
 }
Пример #3
0
        internal static void addNewRowInGroupMode(DevExpress.XtraGrid.Views.Grid.GridView View)
        {
            //Get the handle of the source data row
            //The row will provide group column values for a new row
            int rowHandle = View.GetDataRowHandleByGroupRowHandle(View.FocusedRowHandle);

            //Store group column values
            object[] groupValues      = null;
            int      groupColumnCount = View.GroupedColumns.Count;

            if (groupColumnCount > 0)
            {
                groupValues = new object[groupColumnCount];
                for (int i = 0; i < groupColumnCount; i++)
                {
                    groupValues[i] = View.GetRowCellValue(rowHandle, View.GroupedColumns[i]);
                }
            }
            //Add a new row
            View.AddNewRow();
            //Get the handle of the new row
            int    newRowHandle = View.FocusedRowHandle;
            object newRow       = View.GetRow(newRowHandle);

            //Set cell values corresponding to group columns
            if (groupColumnCount > 0)
            {
                for (int i = 0; i < groupColumnCount; i++)
                {
                    View.SetRowCellValue(newRowHandle, View.GroupedColumns[i], groupValues[i]);
                }
            }
            //Accept the new row
            //The row moves to a new position according to the current group settings
            View.UpdateCurrentRow();
            //Locate the new row
            for (int n = 0; n < View.DataRowCount; n++)
            {
                if (View.GetRow(n).Equals(newRow))
                {
                    View.FocusedRowHandle = n;
                    break;
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Add New IBT Detail
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void simpleButton2_Click(object sender, System.EventArgs e)
        {
            if (canAdd)
            {
                if (this.lkBranchTo.EditValue.ToString() == "Select Branch" | this.lkBranchTo.EditValue.ToString() == "")
                {
                    ACMS.Utils.UI.ShowErrorMessage(this, "Please select valid Branch Code", "Error");
                }
                else if (this.simpleButton2.Text == "Cancel")
                {
                    this.Close();
                }
                else
                {
                    try
                    {
                        CheckAvailableQuantity(sender, null);
                    }
                    catch
                    {
                    }
                    if (canSave)
                    {
                        int currentRow;
                        currentRow = gridView1.FocusedRowHandle;
                        if (currentRow < 0)
                        {
                            currentRow = gridView1.GetDataRowHandleByGroupRowHandle(currentRow);
                        }
                        gridView1.AddNewRow();

                        gridView1.ShowEditor();
                    }
                }
            }
            else
            {
                UI.ShowErrorMessage(this, "Invalid Operation. Please change valid product quantity", "Error");
            }
        }
Пример #5
0
        private void btn_Add_Click(object sender, System.EventArgs e)
        {
            if (canAdd)
            {
                if (this.lkBranchTo.EditValue.ToString() == "")
                {
                    ACMS.Utils.UI.ShowErrorMessage(this, "Please select valid Branch Code", "Error");
                }

                else if (this.btn_Add.Text == "Cancel")
                {
                    this.Close();
                }

                else
                {
                    CheckAvailableQuantity(sender, null);
                    if (canSave)
                    {
                        int currentRow;
                        currentRow = gridView1.FocusedRowHandle;
                        //	if(currentRow < 0)
                        //	{
                        currentRow = gridView1.GetDataRowHandleByGroupRowHandle(currentRow);
                        gridView1.AddNewRow();
                        gridView1.ShowEditor();
                        //		}
                    }            //can save
                }                //end if
            }
            else
            {
                UI.ShowErrorMessage(this, "Invalid Operation. Please change valid product quantity", "Error");
                //this.gridView1.MoveBy(inValidQuantityRow);
            }
        }
Пример #6
0
        private void InsertAll_Donhang(DataColumnChangeEventArgs e)// Khải hoàn
        {
            string MaCN = "";

            if (_data.DrCurrentMaster["NgayCT"] == DBNull.Value)
            {
                return;
            }
            string sql = "select * from wDonHangChuaGiao where NgayGDK<='" + DateTime.Parse(_data.DrCurrentMaster["NgayCT"].ToString()).ToShortDateString() + "'";

            if (_data.DrCurrentMaster["MaCN"] != DBNull.Value)
            {
                MaCN = _data.DrCurrentMaster["MaCN"].ToString();
                sql += " and MaCN='" + MaCN + "'";
            }
            sql += " order by NgayGDK, SoCT";
            DataTable dtTable = _data.DbData.GetDataTable(sql);

            DevExpress.XtraGrid.Views.Grid.GridView gvMain = gc.MainView as DevExpress.XtraGrid.Views.Grid.GridView;
            for (int i = 0; i < dtTable.Rows.Count; i++)
            {
                DataRow drdt = dtTable.Rows[i];
                gvMain.AddNewRow();


                int j = gvMain.DataRowCount;
                foreach (DataColumn col in dtTable.Columns)
                {
                    if (_data.DsData.Tables[1].Columns.Contains(col.ColumnName))
                    {
                        _data.LstDrCurrentDetails[_data.LstDrCurrentDetails.Count - 1][col.ColumnName] = drdt[col.ColumnName];
                        if (gvMain.Columns[col.ColumnName] == null)
                        {
                            continue;
                        }
                        {
                            GridColumn       g = gvMain.Columns[col.ColumnName];
                            CDTRepGridLookup r = g.ColumnEdit as CDTRepGridLookup;
                            if (r == null)
                            {
                                continue;
                            }
                            BindingSource bs = r.DataSource as BindingSource;
                            if (!r.Data.FullData)
                            {
                                r.Data.GetData();
                                bs.DataSource = r.Data.DsData.Tables[0];
                                r.DataSource  = bs;
                            }

                            DataTable tbRep = bs.DataSource as DataTable;
                            int       index = r.GetIndexByKeyValue(drdt[g.FieldName]);

                            DataRow RowSelected = null;
                            if (index >= 0)
                            {
                                RowSelected = tbRep.Rows[index];
                            }
                            if (RowSelected != null)
                            {
                                _data.SetValuesFromListDt(_data.LstDrCurrentDetails[j], g.FieldName, drdt[g.FieldName].ToString(), RowSelected);
                            }
                        }
                    }
                }
                _data.DsData.Tables[1].Rows.Add(_data.LstDrCurrentDetails[_data.LstDrCurrentDetails.Count - 1]);
            }
        }
Пример #7
0
        private void ValidMtID(DataColumn colMT, string value)
        {
            string fieldName = colMT.ColumnName;

            foreach (CDTGridLookUpEdit tmp in _glist)
            {
                if (tmp.Properties.Buttons[0].Tag != null)
                {
                    if ((tmp.Properties.Buttons[0].Tag as DataRow)["QueryInsertDt"].ToString() == string.Empty)
                    {
                        continue;
                    }
                    if (!this.isRefreshed)
                    {
                        this.Refresh(this, new EventArgs());
                        this.isRefreshed = true;
                    }
                    if (fieldName.ToLower() == (tmp.Properties.Buttons[0].Tag as DataRow)["FieldName"].ToString().ToLower())
                    {
                        try
                        {
                            string query = (tmp.Properties.Buttons[0].Tag as DataRow)["QueryInsertDt"].ToString();
                            //xoa cac dong da nhap
                            DevExpress.XtraGrid.Views.Grid.GridView gvMain = gc.MainView as DevExpress.XtraGrid.Views.Grid.GridView;
                            if (colMT.Table.TableName == "MT29" && fieldName == "MT2AID") //Piriou
                            {
                                gvMain.SelectAll();
                                gvMain.DeleteSelectedRows();
                                //gvMain.ClearSelection();
                                _data.LstDrCurrentDetails.Clear();
                            }

                            //gvMain.SelectAll();
                            //gvMain.DeleteSelectedRows();
                            ////gvMain.ClearSelection();
                            //_data.LstDrCurrentDetails.Clear();

                            //string fieldName = e.Column.ColumnName;
                            if (value == string.Empty)
                            {
                                continue;
                            }
                            DataTable dtTable;
                            query   = query.Replace("@" + fieldName, value);
                            dtTable = _data.DbData.GetDataTable(query);

                            for (int i = 0; i < dtTable.Rows.Count; i++)
                            {
                                DataRow drdt = dtTable.Rows[i];
                                gvMain.AddNewRow();

                                int j = gvMain.DataRowCount;
                                foreach (DataColumn col in dtTable.Columns)
                                {
                                    if (_data.DsData.Tables[1].Columns.Contains(col.ColumnName))
                                    {
                                        _data.LstDrCurrentDetails[_data.LstDrCurrentDetails.Count - 1][col.ColumnName] = drdt[col.ColumnName];
                                        if (gvMain.Columns[col.ColumnName] == null)
                                        {
                                            continue;
                                        }
                                        {
                                            GridColumn       g = gvMain.Columns[col.ColumnName];
                                            CDTRepGridLookup r = g.ColumnEdit as CDTRepGridLookup;
                                            if (r == null)
                                            {
                                                continue;
                                            }
                                            BindingSource bs = r.DataSource as BindingSource;
                                            if (!r.Data.FullData)
                                            {
                                                r.Data.GetData();
                                                bs.DataSource = r.Data.DsData.Tables[0];
                                                r.DataSource  = bs;
                                            }


                                            DataTable tbRep = bs.DataSource as DataTable;
                                            int       index = r.GetIndexByKeyValue(drdt[g.FieldName]);
                                            if (index == -1)
                                            {
                                                continue;
                                            }
                                            DataRow RowSelected = tbRep.Rows[index];
                                            if (RowSelected != null)
                                            {
                                                _data.SetValuesFromListDt(_data.LstDrCurrentDetails[j], g.FieldName, drdt[g.FieldName].ToString(), RowSelected);
                                            }
                                        }
                                    }
                                }
                                _data.DsData.Tables[1].Rows.Add(_data.LstDrCurrentDetails[_data.LstDrCurrentDetails.Count - 1]);
                            }
                            // gvMain.AddNewRow();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                }
            }
        }