Beispiel #1
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            bool   _Connection = new lSerializados().CheckConnection(Configuration.UrlConnection);
            string _Message    = "No existe conexión con el servidor de datos... Contacte a un Administrador de Red para ver las opciones de conexión.";
            string _Title      = "Conexión de Red";

            if (_Connection)
            {
                int          Row     = DtCruces.CurrentCell.RowIndex;
                int          IDCruce = Convert.ToInt32(DtCruces.Rows[Row].Cells[0].Value.ToString());
                DialogResult dialogo = MessageBox.Show("Desea eliminar el cruce número " + IDCruce.ToString() + "?",
                                                       "Confirme", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (dialogo == DialogResult.Yes)
                {
                    _Message = ((cmbTipo.SelectedIndex == 0) ? "- Debe seleccionar un tipo de plantilla" : "");
                    if (_Message.Length > 0)
                    {
                        MessageBox.Show(_Message, "Información Faltante", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    DialogResult _response = DialogResult.None;

                    oCruce _Template = new oCruce()
                    {
                        IdCruce         = IDCruce,
                        IdTipoPlantilla = cmbTipo.SelectedIndex,
                        Concepto        = "",
                        Formula         = "",
                        Condicion       = "",
                        Nota            = "",
                        LecturaImportes = 0
                    };
                    KeyValuePair <bool, string[]> _result = new lCrucesAdmin(_Template, "E").Delete();
                    string _Messages = "";
                    foreach (string _Msg in _result.Value)
                    {
                        _Messages += ((_Messages.Length > 0) ? "\r\n" : "") + _Msg;
                    }
                    if (_result.Key && _response != DialogResult.Yes)
                    {
                        _Messages = "Cruce eliminado con éxito";
                    }
                    MessageBox.Show(_Messages, (_result.Key) ? "Proceso Existoso" : "Información Faltante", MessageBoxButtons.OK, (_result.Key) ? MessageBoxIcon.Information : MessageBoxIcon.Exclamation);
                    if (_result.Key)
                    {
                        this.Hide();
                    }
                }
            }
            else
            {
                MessageBox.Show(_Message, _Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btguardar_Click(object sender, EventArgs e)
        {
            bool   _Connection = new lSerializados().CheckConnection(Configuration.UrlConnection);
            string _Message    = "No existe conexión con el servidor de datos... Contacte a un Administrador de Red para ver las opciones de conexión.";
            string _Title      = "Conexión de Red";

            if (_Connection)
            {
                _Message  = (txtConcepto.Text.Trim() == "") ? "- Debe indicar concepto." : "";
                _Message += (txtcruzar.Text.Trim() == "") ? ((_Message.Length > 0) ? "\r\n" : "") + "- Debe indicar cruzar." : "";
                _Message += (txtcontra.Text.Trim() == "") ? ((_Message.Length > 0) ? "\r\n" : "") + "- Debe indicar contra." : "";
                _Message += (chkCondicionar.Checked && txtCondicion.Text.Trim() == "") ? ((_Message.Length > 0) ? "\r\n" : "") + "- Debe indicar condición." : "";

                if (_Message.Length > 0)
                {
                    MessageBox.Show(_Message, "Información Faltante", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                DialogResult _response = DialogResult.None;
                string       Formulax  = (txtcruzar.Text + "=" + txtcontra.Text);
                string       condicion = "";
                int          Valor     = 0;
                if (chkCondicionar.Checked)
                {
                    condicion = txtCondicion.Text;
                }
                if (rbConsideraSigno.Checked)
                {
                    Valor = 1;
                }

                oCruce _Template = new oCruce()
                {
                    IdCruce         = Convert.ToInt32(txtNro.Text),
                    IdTipoPlantilla = TpPlantilla,//buscar
                    Concepto        = txtConcepto.Text,
                    Formula         = Formulax,
                    Condicion       = condicion,
                    Nota            = txtNota.Text,
                    LecturaImportes = Valor
                };

                if (accion == "A")
                {
                    KeyValuePair <bool, string[]> _result = new lCrucesAdmin(_Template, accion).Add();

                    string _Messages = "";
                    foreach (string _Msg in _result.Value)
                    {
                        _Messages += ((_Messages.Length > 0) ? "\r\n" : "") + _Msg;
                    }
                    if (_result.Key && _response != DialogResult.Yes)
                    {
                        _Messages = "Cruce agregado con éxito";
                    }
                    MessageBox.Show(_Messages, (_result.Key) ? "Proceso Existoso" : "Información Faltante", MessageBoxButtons.OK, (_result.Key) ? MessageBoxIcon.Information : MessageBoxIcon.Exclamation);
                    if (_result.Key)
                    {
                        this.Hide();
                    }
                }
                else
                if (accion == "M")
                {
                    KeyValuePair <bool, string[]> _result = new lCrucesAdmin(_Template, accion).Update();

                    string _Messages = "";
                    foreach (string _Msg in _result.Value)
                    {
                        _Messages += ((_Messages.Length > 0) ? "\r\n" : "") + _Msg;
                    }
                    if (_result.Key && _response != DialogResult.Yes)
                    {
                        _Messages = "Cruce modificado con éxito";
                    }
                    MessageBox.Show(_Messages, (_result.Key) ? "Proceso Existoso" : "Información Faltante", MessageBoxButtons.OK, (_result.Key) ? MessageBoxIcon.Information : MessageBoxIcon.Exclamation);
                    if (_result.Key)
                    {
                        this.Hide();
                    }
                }
            }
            else
            {
                MessageBox.Show(_Message, _Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }