BeginEdit() public method

public BeginEdit ( ) : void
return void
示例#1
0
        private void mapControlToCommandGrid_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            var Cell = mapControlToCommandGrid.Rows[e.RowIndex].Cells[e.ColumnIndex];
            var Row  = Cell.OwningRow;
            var Col  = Cell.OwningColumn;

            if (Col.IsDataBound && Col.Name == "CatCmdIdColumn")
            {
                if (mapControlToCommandGrid.CurrentCell.EditType == typeof(DataGridViewComboBoxEditingControl))
                {
                    DataGridViewComboBoxCell cb = (DataGridViewComboBoxCell)mapControlToCommandGrid[e.ColumnIndex, e.RowIndex];
                    cb.DataSource = catCmdsBindingSource;
                }
            }
            else if (Col.IsDataBound && Col.Name == "midiControlTypeColumn")
            {
                ControlType ctrlType    = (ControlType)Row.Cells["midiControlTypeColumn"].Value;
                CatCmd      CatCmdValue = (CatCmd)Row.Cells["CatCmdIdColumn"].Value;
                var         attr        = CatCmdDb.Get(CatCmdValue);
                if (attr.ControlType != ctrlType)
                {
                    System.Data.DataRowView obj = (System.Data.DataRowView)mapControlToCommandGrid.CurrentRow.DataBoundItem;
                    obj.BeginEdit();
                    obj.Row["CatCmdId"] = 0;
                    obj.EndEdit();
                }
            }
        }
 public static void EditarDT(DataRowView vistaFilaActual, Ventas entidad)
 {
     vistaFilaActual.BeginEdit();
     vistaFilaActual["IdPCVEN"] = entidad.IdPc.ToString();
     vistaFilaActual["FechaMSTK"] = entidad.Fecha.ToString();
     vistaFilaActual["IdClienteVEN"] = entidad.IdCliente.ToString();
     vistaFilaActual.EndEdit();
 }
示例#3
0
        private void mapControlToCommandGrid_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
        {
            var Cell = mapControlToCommandGrid.Rows[e.RowIndex].Cells[e.ColumnIndex];
            var Row  = Cell.OwningRow;
            var Col  = Cell.OwningColumn;

            if (Col.IsDataBound && Col.Name == "CatCmdIdColumn")
            {
                if (mapControlToCommandGrid.CurrentCell.EditType == typeof(DataGridViewComboBoxEditingControl))
                {
                    DataGridViewComboBoxCell cb = (DataGridViewComboBoxCell)mapControlToCommandGrid[e.ColumnIndex, e.RowIndex];
                    cb.DataSource = catCmdsFilteredBindingSource;
                    var TypeValue = Row.Cells["midiControlTypeColumn"].Value;

                    //string filter = "( InUse = False AND ControlType = " + TypeValue.ToString() + " OR ControlType = 0 )";
                    string filter = "( ControlType = " + TypeValue.ToString() + " OR ControlType = 0 )";
                    if (string.IsNullOrEmpty(Cell.Value.ToString()) == false)
                    {
                        filter += " OR ( CmdId = " + Cell.Value.ToString() + ")";
                    }


                    //System.Diagnostics.Debug.WriteLine(filter);
                    catCmdsFilteredBindingSource.Filter = filter;

                    bool valueOk = false;
                    foreach (DataRowView rowView in catCmdsFilteredBindingSource)
                    {
                        //System.Diagnostics.Debug.WriteLine("Required=" + ((CatCmd)Cell.Value) + "(" + Cell.Value.ToString() + ")" + " cmd=" + ((CatCmd)rowView["CmdId"]) + " val=" + rowView["CmdId"].ToString()+" Inuse=" + rowView["InUse"].ToString());
                        if (rowView["CmdId"].ToString() == Cell.Value.ToString())
                        {
                            valueOk = true;
                            break;
                        }
                    }
                    if (valueOk == false)
                    {
                        System.Data.DataRowView obj = (System.Data.DataRowView)mapControlToCommandGrid.CurrentRow.DataBoundItem;
                        obj.BeginEdit();
                        obj.Row["CatCmdId"] = 0;
                        obj.Row.EndEdit();
                    }
                    cb.DataSource = catCmdsFilteredBindingSource;
                }
            }
        }
示例#4
0
        private bool UpdateRtInStationHead(DataRowView drInStationHead, DataRow drStationHead, DataRowView drEmp, DateTime detctime, int inOutFlag, string strDirectional)
        {
            drInStationHead.BeginEdit();
            drInStationHead["stationHeadID"] = drStationHead["stationHeadID"];
            drInStationHead["CsSetID"] = drEmp["CsSetID"];
            drInStationHead["CsTypeID"] = drEmp["CsTypeID"];
            drInStationHead["UserID"] = drEmp["UserID"];
            drInStationHead["InAntennaPlace"] = drStationHead["StationHeadPlace"];
            drInStationHead["InStationHeadTime"] = detctime;
            if (inOutFlag == 0)
            {
                drInStationHead["stationHeadTime"] = detctime;
            }
            drInStationHead["Directional"] = strDirectional;
            drInStationHead["inOutFlag"] = inOutFlag;
            drInStationHead.EndEdit();

            return UpdateRtInStationHead(drInStationHead);
        }
 /// <summary>
 /// Запускает форму для редактирования строки.
 /// </summary>
 /// <param name="source"></param>
 private void EditRow(DataRowView source)
 {
     source.BeginEdit();
     Editor.ReBindControlsToDataRow(source);
     if (Editor.ShowDialog() == DialogResult.OK)
     {
         source.EndEdit();
     }
     else
     {
         source.CancelEdit();
     }
 }
 private void frmVentas_Load(object sender, EventArgs e)
 {
     System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator = ",";
     System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator = ",";
     this.CenterToScreen();
     instanciaVentas = this;
     this.AutoValidate = System.Windows.Forms.AutoValidate.EnablePreventFocusChange;
     System.Drawing.Icon ico = Properties.Resources.icono_app;
     this.Icon = ico;
     this.ControlBox = true;
     this.MaximizeBox = false;
     FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
     CargarComboLocales();
     grpABM.Enabled = false;
     tblArticulos = BL.GetDataBLL.Articulos();
     tblArticulos.TableName = "Articulos";
     var source = new AutoCompleteStringCollection();
     String[] stringArray =
         Array.ConvertAll<DataRow, String>(tblArticulos.Select(), delegate(DataRow row) { return (String)row["IdArticuloART"]; });
     source.AddRange(stringArray);
     txtArticulo.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
     txtArticulo.AutoCompleteCustomSource = source;
     txtArticulo.AutoCompleteSource = AutoCompleteSource.CustomSource;
     txtArticulo.BackColor = Color.White;
     txtDescripcion.BackColor = Color.White;
     txtDescripcion.TabStop = false;
     txtDescripcion.ReadOnly = true;
     txtCantidad.BackColor = Color.White;
     txtPrecio.BackColor = Color.White;
     tblFormasPago = BL.GetDataBLL.FormasPago();
     cmbForma.ValueMember = "IdFormaPagoFOR";
     cmbForma.DisplayMember = "DescripcionFOR";
     cmbForma.DropDownStyle = ComboBoxStyle.DropDown;
     cmbForma.DataSource = tblFormasPago;
     cmbForma.SelectedValue = -1;
     cmbForma.BackColor = Color.White;
     AutoCompleteStringCollection formasPagoColection = new AutoCompleteStringCollection();
     foreach (DataRow row in tblFormasPago.Rows)
     {
         formasPagoColection.Add(Convert.ToString(row["DescripcionFOR"]));
     }
     cmbForma.AutoCompleteCustomSource = formasPagoColection;
     cmbForma.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
     cmbForma.AutoCompleteSource = AutoCompleteSource.CustomSource;
     cmbForma.Validating += new System.ComponentModel.CancelEventHandler(BL.Utilitarios.ValidarComboBox);
     lblCosto.Visible = false;
     txtCosto.Visible = false;
     grpVentas.CausesValidation = false;
     dateTimePicker1.CausesValidation = false;
     cmbLocal.CausesValidation = false;
     cmbCliente.CausesValidation = false;
     btnClientes.CausesValidation = false;
     btnEditar.CausesValidation = false;
     btnBorrar.CausesValidation = false;
     btnArticulos.CausesValidation = false;
     dsVentas = new DataSet();
     dsVentas.DataSetName = "dsVentas";
     if (tblVentas.DataSet == null)
     {
         dsVentas.Tables.Add(tblVentas);
         dsVentas.Tables.Add(tblVentasDetalle);
     }
     tblVentasDetalle.PrimaryKey = new DataColumn[] { tblVentasDetalle.Columns["IdDVEN"] };
     viewVentas = new DataView(tblVentas);
     viewDetalle = new DataView(tblVentasDetalle);
     viewDetalle.Sort = "OrdenarDVEN ASC";
     bindingSource1.DataSource = viewDetalle;
     bindingNavigator1.BindingSource = bindingSource1;
     dgvDatos.ReadOnly = true;
     dgvDatos.AllowUserToAddRows = false;
     dgvDatos.AllowUserToOrderColumns = false;
     dgvDatos.DataSource = bindingSource1;
     dgvDatos.Columns["IdDVEN"].Visible = false;
     dgvDatos.Columns["IdVentaDVEN"].Visible = false;
     dgvDatos.Columns["IdLocalDVEN"].Visible = false;
     dgvDatos.Columns["PrecioCostoDVEN"].Visible = false;
     dgvDatos.Columns["PrecioMayorDVEN"].Visible = false;
     dgvDatos.Columns["IdFormaPagoDVEN"].Visible = false;
     dgvDatos.Columns["NroCuponDVEN"].Visible = false;
     dgvDatos.Columns["IdEmpleadoDVEN"].Visible = false;
     dgvDatos.Columns["LiquidadoDVEN"].Visible = false;
     dgvDatos.Columns["EsperaDVEN"].Visible = false;
     dgvDatos.Columns["OrdenarDVEN"].Visible = false;
     dgvDatos.Columns["CantidadDVEN"].Width = 55;
     dgvDatos.Columns["CantidadDVEN"].HeaderText = "Cantidad";
     dgvDatos.Columns["IdArticuloDVEN"].HeaderText = "Artículo";
     dgvDatos.Columns["DescripcionDVEN"].HeaderText = "Descripción";
     dgvDatos.Columns["PrecioPublicoDVEN"].Width = 100;
     dgvDatos.Columns["PrecioPublicoDVEN"].HeaderText = "Precio";
     dgvDatos.Columns["PrecioPublicoDVEN"].DefaultCellStyle.Format = "C2";
     dgvDatos.Columns["NroFacturaDVEN"].Width = 100;
     dgvDatos.Columns["NroFacturaDVEN"].HeaderText = "Nº fact.";
     dgvDatos.Columns.Remove("DevolucionDVEN");
     dgvDatos.Columns.Remove("IdFormaPagoDVEN");
     DataGridViewComboBoxColumn cmbFormaPago = new DataGridViewComboBoxColumn();
     cmbFormaPago.Name = "FormaPago";
     cmbFormaPago.HeaderText = "Forma de pago";
     cmbFormaPago.DataSource = tblFormasPago;
     cmbFormaPago.ValueMember = "IdFormaPagoFOR";
     cmbFormaPago.DisplayMember = "DescripcionFOR";
     cmbFormaPago.DataPropertyName = "IdFormaPagoDVEN";
     dgvDatos.Columns.Insert(7, cmbFormaPago);
     DataGridViewCheckBoxColumn chkDevolucion = new DataGridViewCheckBoxColumn();
     chkDevolucion.Name = "DevolucionDVEN";
     chkDevolucion.Width = 40;
     chkDevolucion.HeaderText = "Dev.";
     chkDevolucion.DataPropertyName = "DevolucionDVEN";
     chkDevolucion.TrueValue = 1;
     chkDevolucion.FalseValue = 0;
     dgvDatos.Columns.Insert(12, chkDevolucion);
     dgvDatos.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
     lblTotal.Text = "$ 0";
     if (PK == "") //registro nuevo
     {
         lblNro.ForeColor = System.Drawing.Color.DarkRed;
         Random rand = new Random();
         int clave = rand.Next(-2000000000, 2000000000);
         lblNro.Text = clave.ToString();
         rowView = viewVentas.AddNew();
         rowView["IdVentaVEN"] = clave.ToString();
         rowView["FechaVEN"] = dateTimePicker1.Value;
         rowView.EndEdit();
       //  SetStateForm(FormState.inicial);
     }
     else // editar registros
     {
         viewVentas.RowFilter = "IdVentaVEN = '" + PK + "'";
         rowView = viewVentas[0];
         rowView.BeginEdit();
         viewDetalle.RowFilter = "IdVentaDVEN = '" + PK + "'";
         lblNro.Text = viewVentas[0][0].ToString();
         cmbLocal.Enabled = false;
         lblTotal.Text = "$ " + CalcularTotal();
         dateTimePicker1.TabStop = false;
         cmbLocal.TabStop = false;
         cmbCliente.Focus();
         SetStateForm(FormState.inicial);
     }
     dateTimePicker1.DataBindings.Add("Text", rowView, "FechaVEN", false, DataSourceUpdateMode.OnPropertyChanged);
     cmbLocal.DataBindings.Add("SelectedValue", rowView, "IdPCVEN", false, DataSourceUpdateMode.OnPropertyChanged);
     cmbCliente.DataBindings.Add("SelectedValue", rowView, "IdClienteVEN", false, DataSourceUpdateMode.OnPropertyChanged);
     rowView.CancelEdit();
     ToolTip tooltip = new ToolTip();
     tooltip.SetToolTip(btnClientes, "Agregar nuevo cliente");
     cmbLocal.SelectedIndexChanged += new EventHandler(this.ValidarMaestro);
     cmbCliente.Validating += new System.ComponentModel.CancelEventHandler(BL.Utilitarios.ValidarComboBox);
     txtPrecio.KeyPress += new KeyPressEventHandler(BL.Utilitarios.SoloNumerosConComa);
     txtCantidad.KeyPress += new KeyPressEventHandler(BL.Utilitarios.SoloNumeros);
     txtArticulo.Enter += new System.EventHandler(BL.Utilitarios.SelTextoTextBox);
     txtCantidad.Enter += new System.EventHandler(BL.Utilitarios.SelTextoTextBox);
     txtPrecio.Enter += new System.EventHandler(BL.Utilitarios.SelTextoTextBox);
     cmbForma.Enter += new System.EventHandler(BL.Utilitarios.SelTextoTextBox);
     txtArticulo.KeyDown += new System.Windows.Forms.KeyEventHandler(BL.Utilitarios.EnterTab);
     txtCantidad.KeyDown += new System.Windows.Forms.KeyEventHandler(BL.Utilitarios.EnterTab);
     txtPrecio.KeyDown += new System.Windows.Forms.KeyEventHandler(BL.Utilitarios.EnterTab);
     cmbForma.KeyDown += new System.Windows.Forms.KeyEventHandler(BL.Utilitarios.EnterTab);
     chkDev.KeyDown += new System.Windows.Forms.KeyEventHandler(BL.Utilitarios.EnterTab);
 }