Exemplo n.º 1
0
        protected void cargarDatos()
        {
            try
            {
                var dtSalidas = new dtoSalidas
                {
                    operacion = "SelectByID",
                    activo    = true,
                    idSalida  = _idSalida
                }.CRUD().dtResult;

                foreach (DataRow row in dtSalidas.Rows)
                {
                    txtIdSalida.Text     = row["idSalida"].ToString();
                    txtOtroReceptor.Text = row["otroSolicita"].ToString();
                    txtFolio.Text        = row["folio"].ToString();

                    ddlIdSolicita.SelectedValue = row["idUsuarioSolicita"].ToString();

                    btnGuardar.Enabled  = false;
                    btnAdd.Enabled      = false;
                    txtCode.Enabled     = false;
                    txtCantidad.Enabled = false;
                    //txtPrecioUnit.Enabled = false;
                    ddlIdSolicita.Enabled   = false;
                    txtOtroReceptor.Enabled = false;
                    txtFolio.Enabled        = false;
                    //txtSubTotal.Enabled = false;
                    chkAutomatico.Enabled = false;
                }

                var dtPartidas = new dtoSalidasPartidas
                {
                    operacion = "SelectByidSalida",
                    idSalida  = _idSalida
                }.CRUD().dtResult;


                dt = dtPartidas;
                gvData.DataSource = dtPartidas;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
        private void gvData_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex == -1 || e.ColumnIndex == -1)
                {
                    return;
                }

                string idSalida = gvData.Rows[e.RowIndex].Cells["idSalida"].FormattedValue.ToString();

                if (gvData.Columns[e.ColumnIndex].Name == "Delete")
                {
                    if (MessageBox.Show("¿Está seguro de que desea eliminar el Salida?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        var result = new dtoSalidas
                        {
                            operacion         = "Delete",
                            idSalida          = int.Parse(idSalida),
                            activo            = false,
                            idUsuarioAutoriza = LoginInfo.idUsuario
                        }.CRUD();

                        if (!bool.Parse(result.hasError.ToString()))
                        {
                            string msn = "Registro Eliminado Correctamenete";

                            MessageBox.Show(msn);

                            OnLoad();
                        }
                        else
                        {
                            MessageBox.Show(result.messageError);
                        }
                    }
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 3
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (!validaCampos())
                {
                    return;
                }

                var result = new dtoSalidas
                {
                    operacion         = txtIdSalida.Text != "0" ? "Update" : "Insert",
                    idSalida          = int.Parse(txtIdSalida.Text),
                    fechaAlta         = DateTime.Parse(txtFechaAlta.Text),
                    folio             = txtFolio.Text.Trim(),
                    idUsuarioAutoriza = LoginInfo.idUsuario,
                    otroSolicita      = txtOtroReceptor.Text.Trim(),
                    idUsuarioSolicita = int.Parse(ddlIdSolicita.SelectedValue.ToString()),
                    activo            = true
                }.CRUD();

                if (!bool.Parse(result.hasError.ToString()))
                {
                    int idSalida = int.Parse(result.idOut);

                    //Agergar las partidas
                    foreach (DataRow row in dt.Rows)
                    {
                        var dtoPartidas = new dtoSalidasPartidas
                        {
                            operacion  = "Insert",
                            idSalida   = idSalida,
                            code       = row["code"].ToString(),
                            activo     = true,
                            cantidad   = (decimal)row["cantidad"],
                            idProducto = (int)row["idProducto"],
                            nombre     = row["nombre"].ToString(),
                        }.CRUD();
                    }


                    string msn = "Registro " + (txtIdSalida.Text != "0" ? "Actualizado" : "Agregado") + " Correctamenete";

                    MessageBox.Show(msn);

                    var _frm = Application.OpenForms["Salidas"] as Salidas;
                    if (!((_frm) != null))
                    {
                        Salidas frm = new Salidas();
                        inicializaForm(frm);
                    }
                    else
                    {
                        _frm.Show();
                        //_frm.btnActualizar_Click(null, null);
                    }

                    this.Hide();
                }
                else
                {
                    MessageBox.Show(result.messageError);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }