コード例 #1
0
        private void grdCara_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            bool sw = false;

            try
            {
                if (EsGridCaraContruido)
                {
                    short idCara = Convert.ToInt16(grdCara.Rows[e.RowIndex].Cells["IdCara"].Value.ToString());

                    string idLector = grdCara.Rows[e.RowIndex].Cells["IdLector"].Value.ToString();
                    int    lector   = string.IsNullOrEmpty(idLector) ? 0 : Convert.ToInt32(idLector);

                    if (lector > 0)
                    {
                        oHelper.ValidarLectorCara(idCara);
                    }

                    sw          = true;
                    NumeroIslas = Int32.Parse(this.cmbIslas.Text);

                    if (string.IsNullOrEmpty(grdCara.Rows[e.RowIndex].Cells["ManejaCincoDigitos"].Value.ToString()))
                    {
                        EsCincoDigitos = false;
                    }
                    else
                    {
                        EsCincoDigitos = Boolean.Parse(grdCara.Rows[e.RowIndex].Cells["ManejaCincoDigitos"].Value.ToString());
                    }

                    oHelper.ActualizarCara(idCara, lector, Boolean.Parse(grdCara.Rows[e.RowIndex].Cells["Estado"].Value.ToString()), Int32.Parse(grdCara.Rows[e.RowIndex].Cells["idSurtidor"].Value.ToString()), +
                                           Int32.Parse(grdCara.Rows[e.RowIndex].Cells["CaraAsignada"].Value.ToString()), EsCincoDigitos, Boolean.Parse(grdCara.Rows[e.RowIndex].Cells["PrecioCliente"].Value.ToString()));

                    RecuperarSurtidores();
                }
            }
            catch (Exception ex)
            {
                if (!sw)
                {
                    grdCara.Rows[e.RowIndex].Cells["IdLector"].Value = DBNull.Value;
                }
                MessageBox.Show(ex.Message);
            }
        }