Пример #1
0
        private void Refresh()
        {
            DataSet1TableAdapters.MaterialTableAdapter ta =
                new DataSet1TableAdapters.MaterialTableAdapter();

            DataSet1.MaterialDataTable dt = ta.GetDataMaterial();

            dataGridView1.DataSource            = dt;
            dataGridView1.Columns[0].HeaderText = "Id";
            dataGridView1.Columns[1].HeaderText = "Nombre";
            dataGridView1.Columns[2].HeaderText = "Cantidad";
            dataGridView1.Columns[3].HeaderText = "Presentacion";

            dataGridView1.Columns[4].HeaderText = "Unidades";
            dataGridView1.Columns[5].HeaderText = "Caducidad";


            dataGridView1.Columns[6].HeaderText = "Proveedor";
        }
Пример #2
0
        private void txtBuscarMat_KeyPress(object sender, KeyPressEventArgs e)
        {
            try
            {
                DataSet1TableAdapters.MaterialTableAdapter ta = new DataSet1TableAdapters.MaterialTableAdapter();
                DataSet1.MaterialDataTable dt =
                    ta.GetDataByMaterialFiltering(txtBuscarMat.Text//,//string
                                                  , txtBuscarMat.Text
                                                  , txtBuscarMat.Text
                                                  , txtBuscarMat.Text
                                                  , txtBuscarMat.Text
                                                  , txtBuscarMat.Text
                                                  //   ,txtBuscarMat.Text,// clnFechaExp.SelectionRange.Start.ToShortDateString(),
                                                  //   , Convert.ToDecimal(txtBuscarMat.Text),//decimal
                                                  //   , Convert.ToInt32(txtBuscarMat.Text)//int
                                                  //,Convert.ToInt32(txtBuscarMat.Text)//int
                                                  //   ,txtBuscarMat.Text,// clnFechaExp.SelectionRange.Start.ToShortDateString(),
                                                  //   , Convert.ToDecimal(txtBuscarMat.Text),//decimal
                                                  //   , Convert.ToInt32(txtBuscarMat.Text)//int
                                                  );
                //  (txtNombre.Text.Trim(), (int)udCantidad.Value,
                //      clnFechaExp.SelectionRange.Start.ToShortDateString(), (decimal)udUnidades.Value,

                //   valorIdSupplier
                //  , (int)idd);

                ta.FillByMaterialFiltering(dt, txtBuscarMat.Text//,

                                           , txtBuscarMat.Text
                                           , txtBuscarMat.Text
                                           , txtBuscarMat.Text
                                           , txtBuscarMat.Text
                                           , txtBuscarMat.Text
                                           );

                dataGridView1.DataSource = dt;
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #3
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            string            message = "Esta seguro que desea eliminar este registro?";
            string            title   = "Advertencia";
            MessageBoxButtons buttons = MessageBoxButtons.YesNo;

            //
            int?id = GetId();

            if (id == null)
            {
                MessageBox.Show("No hay registros");
            }
            else
            {
                DialogResult result = MessageBox.Show(message, title, buttons);
                if (result == DialogResult.Yes)
                {
                    if (id != null)
                    {
                        DataSet1TableAdapters.MaterialTableAdapter ta = new DataSet1TableAdapters.MaterialTableAdapter();
                        try
                        {
                            ta.DeleteQueryMaterial((int)id);
                            Refresh();
                        }
                        catch (Exception mensaje)
                        {
                            MessageBox.Show(mensaje.ToString());
                        }
                    }
                }
                else
                {
                    // Do something
                }
            }
        }
Пример #4
0
        private void btnEditar_Click(object sender, EventArgs e)
        {
            int?id = GetId();
            int valorcillo;

            //MessageBox.Show(id.ToString());
            if (id != null)
            {
                DataSet1TableAdapters.MaterialTableAdapter ta = new DataSet1TableAdapters.MaterialTableAdapter();
                DataSet1.MaterialDataTable pt = ta.GetDataByIdMaterial((int)id);

                DataSet1.MaterialRow row = (DataSet1.MaterialRow)pt.Rows[0];

                txtNombre.Text = row.MaterialName;


                udCantidad.Value = row.MaterialQuantity;
                udUnidades.Value = row.MaterialUnits;
                //  txtTipoUnidad.Text = row.MaterialUnitType;
                clnFechaExp.SetDate(row.MaterialExpDate);


                valorcillo = row.idSupplier;
                // MessageBox.Show(valorcillo.ToString());
                //from here
                DataSet1TableAdapters.SupplierTableAdapter tas = new DataSet1TableAdapters.SupplierTableAdapter();
                DataSet1.SupplierDataTable pts = tas.GetDataByIdSupplier((int)valorcillo);
                //  DataSet1.SupplierRow rowsup = (DataSet1.SupplierRow)pts.Rows[0];
                //  txtProveedor.Text = rowsup.ToString();

                dgvProveedor.DataSource = pts;
            }
            else
            {
                MessageBox.Show("No hay registros");
            }
        }
Пример #5
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            int valorIdSupplier = int.Parse(dgvProveedor.Rows[dgvProveedor.CurrentRow.Index].Cells[0].Value.ToString());

            // MessageBox.Show(idd.ToString());
            DataSet1TableAdapters.MaterialTableAdapter ta = new DataSet1TableAdapters.MaterialTableAdapter();
            //   MessageBox.Show(idd.ToString());
            if (string.IsNullOrWhiteSpace(txtNombre.Text))


            {
                MessageBox.Show("Verifique que todos los campos hayan sido llenados correctamente");
            }


            else
            if (idd == 0)
            {
                // ta.InsertQueryMaterial(txtNombre.Text.Trim());

                ta.InsertQueryMaterial(txtNombre.Text.Trim(), (int)udCantidad.Value, clnFechaExp.SelectionRange.Start.ToShortDateString(),
                                       (decimal)udUnidades.Value, (int)valorIdSupplier, txtPresentacion.Text.Trim());
                txtNombre.Clear();
                udCantidad.Value = 0;
                udUnidades.Value = 0;

                clnFechaExp.SetDate(DateTime.Now);


                txtProveedor.Clear();
                txtProveedor.Enabled = true;
                dgvProveedor.Enabled = true;
                btnElegir.Enabled    = true;
                btnLimpiar.Enabled   = true;
                idd = 0;
                Refresh();

                txtPresentacion.Clear();
            }
            else
            {
                //  int valorIdSupplier = int.Parse(dgvProveedor.Rows[dgvProveedor.CurrentRow.Index].Cells[0].Value.ToString());

                ta.UpdateQueryMaterial(txtNombre.Text.Trim(), (int)udCantidad.Value,
                                       clnFechaExp.SelectionRange.Start.ToShortDateString(), (decimal)udUnidades.Value,

                                       valorIdSupplier
                                       , txtPresentacion.Text.Trim(), (int)idd);



                txtNombre.Clear();
                udCantidad.Value = 0;
                udUnidades.Value = 0;
                clnFechaExp.SetDate(DateTime.Now);

                txtPresentacion.Clear();
                txtProveedor.Clear();

                txtProveedor.Enabled = true;
                dgvProveedor.Enabled = true;
                btnElegir.Enabled    = true;
                btnLimpiar.Enabled   = true;
                idd = 0;
                Refresh();
            }

            /*
             *
             *
             *
             */
        }