Beispiel #1
0
        private void btn_guardar_Click(object sender, EventArgs e)
        {
            if (btn_guardar.Text == "Guardar")
            {
                if (!String.IsNullOrEmpty(txt_titulo.Text) && comboBox1.SelectedItem != null && !String.IsNullOrEmpty(txt_detalles.Text) && !String.IsNullOrEmpty(txt_valor.Text) && dtp_fecha_cierre.EditValue != null)
                {
                    string   titulo   = txt_titulo.Text.Trim();
                    int      perem    = Convert.ToInt32(cbo_perem.SelectedValue);
                    string   detalles = txt_detalles.Text.Trim();
                    int      moneda   = Convert.ToInt32(cbo_monedas.SelectedValue);
                    decimal  valor    = Convert.ToDecimal(txt_valor.Text.Trim());
                    int      cat      = Convert.ToInt32(cbo_cat.SelectedValue);
                    int      empleado = Convert.ToInt32(cbo_empleado.SelectedValue);
                    int      etapa    = tb_etapa.Value;
                    DateTime fecha    = dtp_fecha_cierre.DateTime;

                    int  res = 3;
                    OpBD o   = new OpBD();
                    if (comboBox1.SelectedItem.ToString() == "Persona")
                    {
                        res = o.InsertarNegocioClie(titulo, perem, detalles, moneda, valor, cat, empleado, etapa, fecha.ToString("yyyy-MM-dd"));
                    }
                    else if (comboBox1.SelectedItem.ToString() == "Empresa")
                    {
                        res = o.InsertarNegocioEmp(titulo, perem, detalles, moneda, valor, cat, empleado, etapa, fecha.ToString("yyyy-MM-dd"));
                    }

                    if (res == 1)
                    {
                        MessageBox.Show("Ingreso Exitoso!");
                    }
                    else if (res == 0)
                    {
                        MessageBox.Show("Ingreso fallido!");
                    }
                    else
                    {
                        MessageBox.Show("Ingrese con quien será la negociación!");
                    }
                }
                else
                {
                    MessageBox.Show("Debe llenar todos los campos!!!", "Alerta!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if (btn_guardar.Text == "Actualizar")
            {
                if (!String.IsNullOrEmpty(txt_titulo.Text) && comboBox1.SelectedItem != null && !String.IsNullOrEmpty(txt_detalles.Text) && !String.IsNullOrEmpty(txt_valor.Text) && dtp_fecha_cierre.EditValue != null)
                {
                    string   titulo   = txt_titulo.Text.Trim();
                    int      perem    = Convert.ToInt32(cbo_perem.SelectedValue);
                    string   detalles = txt_detalles.Text.Trim();
                    int      moneda   = Convert.ToInt32(cbo_monedas.SelectedValue);
                    decimal  valor    = Convert.ToDecimal(txt_valor.Text.Trim());
                    int      cat      = Convert.ToInt32(cbo_cat.SelectedValue);
                    int      empleado = Convert.ToInt32(cbo_empleado.SelectedValue);
                    int      etapa    = tb_etapa.Value;
                    DateTime fecha    = dtp_fecha_cierre.DateTime;

                    int  res = 3;
                    OpBD o   = new OpBD();
                    if (comboBox1.SelectedItem.ToString() == "Persona")
                    {
                        res = o.ActualizarNegocioClie(titulo, perem, detalles, moneda, valor, cat, empleado, etapa, fecha.ToString("yyyy-MM-dd"), id_negocio_e);
                    }
                    else if (comboBox1.SelectedItem.ToString() == "Empresa")
                    {
                        res = o.ActualizarNegocioEmp(titulo, perem, detalles, moneda, valor, cat, empleado, etapa, fecha.ToString("yyyy-MM-dd"), id_negocio_e);
                    }

                    if (res == 1)
                    {
                        MessageBox.Show("Modificación Exitosa!");
                    }
                    else if (res == 0)
                    {
                        MessageBox.Show("Ingreso fallido!");
                    }
                }
                else
                {
                    MessageBox.Show("Debe llenar todos los campos!!!", "Alerta!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }