Beispiel #1
0
        // boton para almacenar en la base de datos un nuevo caso
        private void btn_guardar_Click(object sender, EventArgs e)
        {
            //try
            //{
            //    string valor_empresa = cmb_empresa.SelectedValue.ToString();

            //    if (valor_empresa == "")
            //    {
            //        valor_empresa = "0";
            //    }

            //    // conversion de fecha para que sea aceptada por mysql
            //    fecha = dtp_fecha_cierre.DateTime.ToString("yyyy-MM-dd");
            //    if (txt_titulo.Text.Trim() == "" || txt_descripcion.Text.Trim() == "" ||cmb_responsable.Text==""||cmb_categoria.Text==""||cmb_cliente.Text=="" || switch_caso.IsOn == false)
            //    {
            //        MessageBox.Show("Uno o más campos estan vacios","Advertencia",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
            //        switch_caso.IsOn = false;
            //    }
            //    else
            //    {
            //        peticionescapa.Insertar_NuevoCaso(cmb_responsable.SelectedValue.ToString(), cmb_cliente.SelectedValue.ToString(), valor_empresa
            //        , txt_titulo.Text.Trim(), estado, fecha, txt_descripcion.Text.Trim(), cmb_categoria.SelectedValue.ToString());
            //        MessageBox.Show("Caso asignado correctamente", "Mensaje de confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //    }
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message,"ERROR",MessageBoxButtons.OK,MessageBoxIcon.Error);
            //}


            if (actualizar == false)
            {
                if (!String.IsNullOrEmpty(txt_titulo.Text) && cmb_ente.SelectedItem != null && !String.IsNullOrEmpty(txt_descripcion.Text) && dtp_fecha_cierre.EditValue != null)
                {
                    string   titulo      = txt_titulo.Text.Trim();
                    int      perem       = Convert.ToInt32(cbo_perem.SelectedValue);
                    string   descripcion = txt_descripcion.Text.Trim();
                    int      cat         = Convert.ToInt32(cmb_categoria.SelectedValue);
                    int      empleado    = Convert.ToInt32(cmb_responsable.SelectedValue);
                    DateTime fecha       = dtp_fecha_cierre.DateTime;

                    int  res = 3;
                    OpBD o   = new OpBD();
                    if (cmb_ente.SelectedItem.ToString() == "Persona")
                    {
                        res = o.InsertarCasoClie(titulo, perem, descripcion, cat, empleado, fecha.ToString("yyyy-MM-dd"));
                    }
                    else if (cmb_ente.SelectedItem.ToString() == "Empresa")
                    {
                        res = o.InsertarCasoEmp(titulo, perem, descripcion, cat, empleado, 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 (actualizar == true)
            {
                if (!String.IsNullOrEmpty(txt_titulo.Text) && cmb_ente.SelectedItem != null && !String.IsNullOrEmpty(txt_descripcion.Text) && dtp_fecha_cierre.EditValue != null)
                {
                    string   titulo      = txt_titulo.Text.Trim();
                    int      perem       = Convert.ToInt32(cbo_perem.SelectedValue);
                    string   descripcion = txt_descripcion.Text.Trim();
                    int      cat         = Convert.ToInt32(cmb_categoria.SelectedValue);
                    int      empleado    = Convert.ToInt32(cmb_responsable.SelectedValue);
                    DateTime fecha       = dtp_fecha_cierre.DateTime;

                    int  res = 3;
                    OpBD o   = new OpBD();
                    if (cmb_ente.SelectedItem.ToString() == "Persona")
                    {
                        res = o.ActualizarCasoClie(titulo, perem, descripcion, cat, empleado, fecha.ToString("yyyy-MM-dd"), id_caso_e);
                    }
                    else if (cmb_ente.SelectedItem.ToString() == "Empresa")
                    {
                        res = o.ActualizarCasoEmp(titulo, perem, descripcion, cat, empleado, fecha.ToString("yyyy-MM-dd"), id_caso_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);
                }
            }
        }