示例#1
0
        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();
            }
        }
示例#2
0
文件: Cota.cs 项目: icaroferj/ir-api
        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();
            }
        }
示例#3
0
文件: Cota.cs 项目: icaroferj/ir-api
        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();
            }
        }