Ejemplo n.º 1
0
        public int grabarArea(Models.AreaPreventa oAreaPreventa, List <Models.FiguraAreaPreventa> lstFigurasArea)
        {
            Guid methodOwnerID  = new Guid("532e7c11-3ff0-4640-b531-d9a267300e9b");
            int  idAreaPreventa = 0;
            int  nFiguras       = 0;

            OpenDbConn();

            if (cDblib.Transaction.ownerID.Equals(new Guid()))
            {
                cDblib.beginTransaction(methodOwnerID);
            }

            try
            {
                DAL.AreaPreventa cAreaPreventa = new DAL.AreaPreventa(cDblib);

                DataTable dtFiguras = new DataTable();
                dtFiguras.Columns.Add(new DataColumn("col_1", typeof(int)));
                dtFiguras.Columns.Add(new DataColumn("col_2", typeof(char)));


                //Recorremos la lista
                foreach (Models.FiguraAreaPreventa oFiguras in lstFigurasArea)
                {
                    DataRow row = dtFiguras.NewRow();
                    row["col_1"] = oFiguras.t001_idficepi;
                    row["col_2"] = oFiguras.ta202_figura;

                    dtFiguras.Rows.Add(row);
                }

                idAreaPreventa = cAreaPreventa.grabarArea(oAreaPreventa);

                nFiguras = cAreaPreventa.grabarFigurasArea(oAreaPreventa.ta200_idareapreventa, dtFiguras);

                //Finalizar transacción
                if (cDblib.Transaction.ownerID.Equals(methodOwnerID))
                {
                    cDblib.commitTransaction(methodOwnerID);
                }

                return(idAreaPreventa);
            }
            catch (Exception ex)
            {
                //rollback
                if (cDblib.Transaction.ownerID.Equals(methodOwnerID))
                {
                    cDblib.rollbackTransaction(methodOwnerID);
                }

                throw ex;
            }
        }