public int SalvarCota(List <EstruturaCotaItem> listaCotaItem, EstruturaCota cota) { try { bd.IniciarTransacao(); int cotaID = 0; this.Nome.Valor = cota.Nome; this.LocalID.Valor = cota.LocalID; this.Quantidade.Valor = cota.Quantidade; this.QuantidadePorCliente.Valor = cota.QuantidadePorCliente; if (cota.Novo) { this.Inserir(bd); cotaID = this.Control.ID; } else { cotaID = cota.ID; this.Control.ID = cotaID; this.Atualizar(bd); } CotaItem oCotaItem = new CotaItem(this.Control.UsuarioID); oCotaItem.SalvarItem(bd, listaCotaItem, cotaID, !cota.Novo); bd.FinalizarTransacao(); return(cotaID); } catch (Exception ex) { bd.DesfazerTransacao(); throw ex; } finally { bd.Fechar(); } }
public EstruturaCota buscaCota(int id) { try { EstruturaCota item = null; string strSQL = "SELECT TOP 1 ID, Nome, LocalID, Quantidade, QuantidadePorCliente FROM tCota (NOLOCK) WHERE ID = @ID"; List <SqlParameter> parametros = new List <SqlParameter>(); parametros.Add(new SqlParameter() { ParameterName = "@ID", Value = id, DbType = DbType.Int32 }); bd.Consulta(strSQL, parametros); while (bd.Consulta().Read()) { item = new EstruturaCota(); item.ID = bd.LerInt("ID"); item.Nome = bd.LerString("Nome"); item.Quantidade = bd.LerInt("Quantidade"); item.QuantidadePorCliente = bd.LerInt("QuantidadePorCliente"); break; } return(item); } catch (Exception) { throw; } finally { bd.Fechar(); } }
public int SalvarCota(EstruturaCota cota) { try { bd.IniciarTransacao(); int cotaID = 0; this.Nome.Valor = cota.Nome; this.LocalID.Valor = cota.LocalID; this.Quantidade.Valor = cota.Quantidade; this.QuantidadePorCliente.Valor = cota.QuantidadePorCliente; if (cota.Novo) { this.Inserir(bd); cotaID = this.Control.ID; } else { cotaID = cota.ID; this.Control.ID = cotaID; this.Atualizar(bd); } bd.FinalizarTransacao(); return(cotaID); } catch (Exception ex) { bd.DesfazerTransacao(); throw ex; } finally { bd.Fechar(); } }