//--------------------------------------------------------------------------------------------------------------------------------------------------
        public int InsertoEncabezadoRemito()
        {
            var R = new RemitoModel();

            foreach (DataGridViewRow filaProd in _vf.dgvFactura.Rows)
            {
                R.ID_Producto = Convert.ToInt32(filaProd.Cells[0].Value);
                R.Cantidad    = Convert.ToInt32(filaProd.Cells[3].Value);

                R.Nro_Remito    = Convert.ToInt16(_vf.txtNroRemito.Text);
                R.Nro_Factura   = Convert.ToInt16(_vf.txtNroFactura.Text);
                R.Fecha_Emision = Convert.ToDateTime(_vf.dtpFacturaFecha.Text);

                _fac_dao.InsertEncabezadoRemito(R);
            }
            return(R.Nro_Remito);
        }
Пример #2
0
        //----------------------------------------------------------------------------------------------------------------


        public bool InsertEncabezadoRemito(RemitoModel R)
        {
            SqlCommand _comand        = null;
            bool       inserteFactura = false;

            try
            {
                _comand = new SqlCommand("insertEncabezadoRemito", _objConexion.getConexion());
                _objConexion.getConexion().Open();

                _comand.CommandType = CommandType.StoredProcedure;
                _comand.Parameters.Add("@Nro_Factura", SqlDbType.Int).Value    = R.Nro_Factura;
                _comand.Parameters.Add("@Nro_Remito", SqlDbType.Int).Value     = R.Nro_Remito;
                _comand.Parameters.Add("@Fecha_Emision", SqlDbType.Date).Value = R.Fecha_Emision;

                _comand.Parameters.Add("@ID_Producto", SqlDbType.Int).Value = R.ID_Producto;
                _comand.Parameters.Add("@Cantidad", SqlDbType.Int).Value    = R.Cantidad;


                _comand.ExecuteNonQuery();

                inserteFactura = true;
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("HAY UN PROBLEMA CON LA BASE DE DATOS" +
                                                     "INFORMACION : " + ex.Message);

                inserteFactura = false;

                _objConexion.getConexion().Close();
            }
            finally
            {
                _comand.Connection.Close();
                _objConexion.cerrarConexion();
            }
            return(inserteFactura);
        }