当前位置: 首页>>代码示例>>C#>>正文


C# SqlCeTransaction.Rollback方法代码示例

本文整理汇总了C#中SqlCeTransaction.Rollback方法的典型用法代码示例。如果您正苦于以下问题:C# SqlCeTransaction.Rollback方法的具体用法?C# SqlCeTransaction.Rollback怎么用?C# SqlCeTransaction.Rollback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SqlCeTransaction的用法示例。


在下文中一共展示了SqlCeTransaction.Rollback方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: deleteDocCheckProduct

        public bool deleteDocCheckProduct(string _DCode)
        {
            bool result = false;
            try
            {

                Conn = OpenConn();

                sb = new StringBuilder();
                sb.Append(" delete from DocCheckProducts  where DCode ='"+_DCode+"'");

                string sqlAdd;
                sqlAdd = sb.ToString();

                tr = Conn.BeginTransaction();
                com = new SqlCeCommand();
                com.CommandText = sqlAdd;
                com.CommandType = CommandType.Text;
                com.Connection = Conn;
                com.Transaction = tr;
                com.ExecuteNonQuery();

                tr.Commit();

                sb = new StringBuilder();
                sb.Append(" delete from DocCheckProductDetails where DCode ='" + _DCode + "'");

                string sqldelete;
                sqldelete = sb.ToString();

                tr = Conn.BeginTransaction();
                com = new SqlCeCommand();
                com.CommandText = sqldelete;
                com.CommandType = CommandType.Text;
                com.Connection = Conn;
                com.Transaction = tr;
                com.ExecuteNonQuery();

                tr.Commit();

                result = true;

            }
            catch (Exception ex)
            {

                tr.Rollback();
                Conn.Close();
                result = false;
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Conn.Close();
            }

            return result;
        }
开发者ID:marcpiulachs,项目名称:sttproject,代码行数:58,代码来源:ProductService.cs

示例2: updateProduct

        public bool updateProduct(Product product)
        {
            bool result = false;
            try
            {

                Conn = OpenConn();

                sb = new StringBuilder();

                sb.Append(" update Products ");
                sb.Append(" set Name ='" + product.Name + "',");
                sb.Append(" Code ='" + product.Code + "',");
                sb.Append(" BarCode ='" + product.BarCode  + "',");
                sb.Append(" Unit ='" + product.Unit  + "',");
                sb.Append(" Price1 ='" + product.Price1  + "',");
                sb.Append(" Price3 ='" + product.Price3 + "',");
                sb.Append(" Price4 ='" + product.Price4 + "',");
                sb.Append(" CreateDate ='" + DatetimeUtil.convertToDateThai2(product.CreateDate.ToString("dd/MM/yyyy")) + "'");
                sb.Append(" where BarCode ='" + product.BarCode + "'");

                string sqlAdd;
                sqlAdd = sb.ToString();

                tr = Conn.BeginTransaction();
                com = new SqlCeCommand();
                com.CommandText = sqlAdd;
                com.CommandType = CommandType.Text;
                com.Connection = Conn;
                com.Transaction = tr;
                com.Parameters.Clear();
                com.ExecuteNonQuery();

                tr.Commit();
                result = true;

            }
            catch (Exception ex)
            {

                tr.Rollback();
                Conn.Close();
                result = false;
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Conn.Close();
            }

            return result;
        }
开发者ID:marcpiulachs,项目名称:sttproject,代码行数:52,代码来源:ProductService.cs

示例3: saveProduct

        public bool saveProduct(Product product)
        {
            bool result = false;
            try
            {

                Conn = OpenConn();

                sb = new StringBuilder();
                sb.Append("INSERT INTO Products(Name,Code,BarCode,Unit,Price1,Price3,Price4,CreateDate)");
                sb.Append(" VALUES (@Name,@Code,@BarCode,@Unit,@Price1,@Price3,@Price4,@CreateDate)");

                string sqlAdd;
                sqlAdd = sb.ToString();

                tr = Conn.BeginTransaction();
                com = new SqlCeCommand();
                com.CommandText = sqlAdd;
                com.CommandType = CommandType.Text;
                com.Connection = Conn;
                com.Transaction = tr;
                com.Parameters.Clear();
                com.Parameters.Add("@Name", SqlDbType.NVarChar).Value = product.Name;
                com.Parameters.Add("@Code", SqlDbType.NVarChar).Value = product.Code;
                com.Parameters.Add("@BarCode", SqlDbType.NVarChar).Value = product.BarCode;
                com.Parameters.Add("@Unit", SqlDbType.NVarChar).Value = product.Unit;
                com.Parameters.Add("@Price1", SqlDbType.NVarChar).Value = product.Price1;
                com.Parameters.Add("@Price3", SqlDbType.NVarChar).Value = product.Price3;
                com.Parameters.Add("@Price4", SqlDbType.NVarChar).Value = product.Price4;
                com.Parameters.Add("@CreateDate", SqlDbType.NVarChar).Value = product.CreateDate;
                com.ExecuteNonQuery();

                tr.Commit();
                result = true;

            }
            catch (Exception ex)
            {

                tr.Rollback();
                Conn.Close();
                result = false;
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Conn.Close();
            }

            return result;
        }
开发者ID:marcpiulachs,项目名称:sttproject,代码行数:51,代码来源:ProductService.cs

示例4: saveDocCheckProductDetail

        public bool saveDocCheckProductDetail(DocCheckProductDetail docCheckProductDetail)
        {
            bool result = false;
            try
            {

                Conn = OpenConn();

                sb = new StringBuilder();
                sb.Append("INSERT INTO DocCheckProductDetails(DCode,PCode,PName,PUnit,NumProduct,CreateDate)");
                sb.Append(" VALUES (@DCode,@PCode,@PName,@PUnit,@NumProduct,@CreateDate)");

                string sqlAdd;
                sqlAdd = sb.ToString();

                tr = Conn.BeginTransaction();
                com = new SqlCeCommand();
                com.CommandText = sqlAdd;
                com.CommandType = CommandType.Text;
                com.Connection = Conn;
                com.Transaction = tr;
                com.Parameters.Clear();
                com.Parameters.Add("@DCode", SqlDbType.NVarChar).Value = docCheckProductDetail.DocCheckProduct.Code;
                com.Parameters.Add("@PCode", SqlDbType.NVarChar).Value = docCheckProductDetail.Product.BarCode;
                com.Parameters.Add("@PName", SqlDbType.NVarChar).Value = docCheckProductDetail.Product.Name;
                com.Parameters.Add("@PUnit", SqlDbType.NVarChar).Value = docCheckProductDetail.Product.Unit;
                com.Parameters.Add("@NumProduct", SqlDbType.NVarChar).Value = docCheckProductDetail.NumProduct;
                com.Parameters.Add("@CreateDate", SqlDbType.DateTime).Value = DateTime.Now;
                com.ExecuteNonQuery();

                tr.Commit();
                result = true;

            }
            catch (Exception ex)
            {

                tr.Rollback();
                Conn.Close();
                result = false;
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Conn.Close();
            }

            return result;
        }
开发者ID:marcpiulachs,项目名称:sttproject,代码行数:49,代码来源:ProductService.cs

示例5: saveDocCheckProduct

        public bool saveDocCheckProduct(DocCheckProduct docCheckProduct)
        {
            bool result = false;
            try
            {

                Conn = OpenConn();

                sb = new StringBuilder();
                sb.Append("INSERT INTO DocCheckProducts(DCode,Warehouse,Location,CreateDate)");
                sb.Append(" VALUES (@DCode,@Warehouse,@Location,@CreateDate)");

                string sqlAdd;
                sqlAdd = sb.ToString();

                tr = Conn.BeginTransaction();
                com = new SqlCeCommand();
                com.CommandText = sqlAdd;
                com.CommandType = CommandType.Text;
                com.Connection = Conn;
                com.Transaction = tr;
                com.Parameters.Clear();
                com.Parameters.Add("@DCode", SqlDbType.NVarChar).Value = docCheckProduct.Code;
                com.Parameters.Add("@Warehouse", SqlDbType.NVarChar).Value = docCheckProduct.Warehouse;
                com.Parameters.Add("@Location", SqlDbType.NVarChar).Value = docCheckProduct.Location;
                com.Parameters.Add("@CreateDate", SqlDbType.DateTime).Value = DateTime.Now;
                com.ExecuteNonQuery();

                tr.Commit();
                result = true;

            }
            catch (Exception ex)
            {

                tr.Rollback();
                Conn.Close();
                result = false;
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Conn.Close();
            }

            return result;
        }
开发者ID:marcpiulachs,项目名称:sttproject,代码行数:47,代码来源:ProductService.cs

示例6: editNumberCheckProduct

        public bool editNumberCheckProduct(string _id,string  _dcode,string _pcode,int numberedit)
        {
            bool result = false;
            try
            {

                Conn = OpenConn();

                sb = new StringBuilder();

                sb.Append(" update DocCheckProductDetails ");
                sb.Append(" set NumProduct ="+numberedit+"");
                sb.Append(" where DCode ='"+_dcode+"'");
                sb.Append(" and PCode='"+_pcode+"'");
                sb.Append(" and ID='" + _id + "'");

                string sqlAdd;
                sqlAdd = sb.ToString();

                tr = Conn.BeginTransaction();
                com = new SqlCeCommand();
                com.CommandText = sqlAdd;
                com.CommandType = CommandType.Text;
                com.Connection = Conn;
                com.Transaction = tr;
                com.ExecuteNonQuery();

                tr.Commit();
                result = true;

            }
            catch (Exception ex)
            {

                tr.Rollback();
                Conn.Close();
                result = false;
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Conn.Close();
            }

            return result;
        }
开发者ID:marcpiulachs,项目名称:sttproject,代码行数:46,代码来源:ProductService.cs

示例7: Inserir

            public int Inserir(SqlCeTransaction dbTrans)
            {
                int rf;

                //Código comentado por estar afetando a performance

                //verifica se existe na tabela saldo estoque
                string sqlExisteSaldoEstoque = @" select count(*) "+
                    @"from saldo_grade" +
                    @" where
                        id_produto =  " + Grade.Produto.Id +
                    @" and id_grade = " + Grade.Produto.IdGrade.V +
                    @" and id_item_grade = " + IdItemGrade +
                    @" and id_atributo = " + IdAtributo +
                    @" and id_item_atributo = " + IdItemAtributo;
                if (D.Bd.I(sqlExisteSaldoEstoque) > 0)
                {
                    //Dá baixa no estoque:
                    string sqlUpdateEstoque = @"
                    update
                        saldo_grade
                    set
                        estoque = estoque - " + Quantidade +
                    @" where
                        id_produto =  " + Grade.Produto.Id +
                    @" and id_grade = " + Grade.Produto.IdGrade.V +
                    @" and id_item_grade = " + IdItemGrade +
                    @" and id_atributo = " + IdAtributo +
                    @" and id_item_atributo = " + IdItemAtributo;

                    rf = D.Bd.ExecuteNonQuery(sqlUpdateEstoque, dbTrans);
                    if (rf < 1)
                    {
                        dbTrans.Rollback();
                        return -1;
                    }
                }

                string sqlInsertItemGrade = @"
                insert into
                    item_pedido_grade
                (id_produto,
                 id_funcionario,
                 id_atributo,
                 id_item_atributo,
                 id_item_grade,
                 id_pedido,
                 id_grade,
                 quantidade)
                        values (" +
                    Grade.Produto.Id + "," +
                    D.Funcionario.Id + "," +
                    IdAtributo + "," +
                    IdItemAtributo + "," +
                    IdItemGrade + ",'" +
                    Grade.Produto.Pedido.Id + "'," +
                    Grade.Produto.IdGrade.V + "," +
                    Quantidade + ")";

                rf = D.Bd.ExecuteNonQuery(sqlInsertItemGrade, dbTrans);
                return rf;
            }
开发者ID:evandrojr,项目名称:NeoPocket,代码行数:62,代码来源:Grade.cs

示例8: inserirTabelaPedido

        //da
        private bool inserirTabelaPedido(SqlCeTransaction dbTrans)
        {
            int rf;

            string sqlInsertPedido = @"
            insert into
                        pedido
            (id_pedido,
             id_cliente_pocket,
             id_cliente_store,
             data,
             id_funcionario,
             id_tabela_preco,
             id_forma_pagamento,
             status,
             valor,
             observacao,
             desconto,
             bdi)
                    values ('" +
            Id + "','" +
            IdClientePocket + "'," +
            Bd.SZ(IdClienteStore) + "," +
            Bd.TimeStampParaBd(Data) + "," +
            Bd.S(D.Funcionario.Id) + "," +
            Bd.S(IdTabelaPreco) + "," +
            Bd.S(IdFormaPagamento) + "," +
            "'N'," +
            Bd.RealPtParaBd(Bd.S(Valor)) + "," +
            Bd.SN(Observacao) + "," +
            Bd.Numerico(Fcn.RoundComputing(desconto, Parametro.ProdutoPrecoCasasDecimais)) + "," +
            Bd.Numerico(bdi) +
            ")";

            rf = D.Bd.ExecuteNonQuery(sqlInsertPedido, dbTrans);
            if (rf < 1)
            {
                dbTrans.Rollback();
                return false;
            }
            //No longer required code since after Guid deployment
            //            Globals.Pedido.Id = Globals.Bd.Guid("SELECT @@IDENTITY AS UltimaIdentity", dbTrans);
            return true;
        }
开发者ID:evandrojr,项目名称:NeoPocket,代码行数:45,代码来源:Pedido.cs

示例9: inserirItemPedido

        private bool inserirItemPedido(SqlCeTransaction dbTrans, Produto p)
        {
            int rf;

            //Dá baixa no estoque:
            string sqlUpdateEstoque = @"
            update
                    produto
            set
                    estoque=estoque - " + p.QuantidadeRequerida +
            @" where
                    id_produto =  " + p.Id;
            rf = D.Bd.ExecuteNonQuery(sqlUpdateEstoque, dbTrans);
            if (rf < 1)
            {
                dbTrans.Rollback();
                return false;
            }

            string sqlInsertItem = "";
            sqlInsertItem = @"
            insert into
                item_pedido
            (id_pedido,
             id_funcionario,
             id_produto,
             quantidade,
             valor_unitario,
             desconto)
                    values ('" +
            D.Pedido.Id + "'," +
            D.Funcionario.Id + "," +
            p.Id + "," +
            p.QuantidadeRequerida + "," +
            Bd.RealPtParaBd(p.PrecoUtilizado.ToString()) + "," +
            Bd.Numerico(Fcn.RoundComputing(p.Desconto, Parametro.ProdutoPrecoCasasDecimais)) + ")";

            rf = D.Bd.ExecuteNonQuery(sqlInsertItem, dbTrans);
            if (rf < 1)
            {
                dbTrans.Rollback();
                return false;
            }

            //Verifica se o pedido tem grade e insere
            p.IdItemPedido.V = D.Bd.I("SELECT @@IDENTITY AS UltimaIdentity", dbTrans);

            if (p.IdGrade.Iniciada)
            {
                rf = p.Grade.Inserir(dbTrans);
                if (rf < 1)
                {
                    try
                    {
                        dbTrans.Rollback();
                    }
                    catch { }
                    return false;
                }
            }
            return true;
        }
开发者ID:evandrojr,项目名称:NeoPocket,代码行数:62,代码来源:Pedido.cs

示例10: atualizaTabelaPedido

        //da
        /// <summary>
        /// Não é permitido editar pedidos com status S
        /// </summary>
        /// <param name="dbTrans"></param>
        /// <returns></returns>
        private bool atualizaTabelaPedido(SqlCeTransaction dbTrans)
        {
            //Iniciar transação
            int rf;

            string sqlInsertPedido = @"
            update pedido
            set
            id_cliente_pocket='" + IdClientePocket + "'," +
            "id_cliente_store=" + Bd.SN(IdClienteStore) + "," +
            "data=" + Bd.TimeStampParaBd(Data) + "," +
            "id_funcionario=" + Bd.S(D.Funcionario.Id) + "," +
            "id_tabela_preco=" + Bd.S(IdTabelaPreco) + "," +
            "id_forma_pagamento=" + Bd.S(IdFormaPagamento) + "," +
            "status='N'" + "," +
            "valor=" + Bd.RealPtParaBd(Bd.S(Valor)) + "," +
            "observacao=" + Bd.SN(Observacao) + "," +
            "desconto=" + Bd.Numerico(desconto) + "," +
            "bdi=" + Bd.Numerico(bdi) +
            " where id_pedido='" + Id + "'";

            rf = D.Bd.ExecuteNonQuery(sqlInsertPedido, dbTrans);
            if (rf < 1)
            {
                dbTrans.Rollback();
                return false;
            }
            return true;
        }
开发者ID:evandrojr,项目名称:NeoPocket,代码行数:35,代码来源:Pedido.cs

示例11: atualizaTabelaItemPedido

        private bool atualizaTabelaItemPedido(SqlCeTransaction dbTrans, Produto p)
        {
            int rf;

            //Atualiza o estoque
            string sqlPedidoOriginalQuantidade = @"
            select
                    quantidade
            from
                    item_pedido
            where id_pedido='" + D.Pedido.Id + "' and id_produto=" + p.Id;

            int quantidadeOriginal = D.Bd.I(sqlPedidoOriginalQuantidade, dbTrans);
            string sqlUpdateEstoque = @"
            update
                    produto
            set
                    estoque=estoque + " + quantidadeOriginal + " - " + p.QuantidadeRequerida + @"
            where
                    id_produto = " + p.Id;
            D.Bd.ExecuteNonQuery(sqlUpdateEstoque, dbTrans);

            string sqlUpdateItem = "";
            sqlUpdateItem = @"
            update item_pedido
            set
            quantidade=" + p.QuantidadeRequerida + "," +
            "id_funcionario=" + D.Funcionario.Id + "," +
            "valor_unitario=" + Bd.RealPtParaBd(p.PrecoUtilizado.ToString()) + "," +
            "desconto=" + p.Desconto +
            " where id_pedido='" + D.Pedido.Id + "' and id_produto=" + p.Id;

            rf = D.Bd.ExecuteNonQuery(sqlUpdateItem, dbTrans);
            if (rf < 1)
            {
                dbTrans.Rollback();
                return false;
            }
            //Verifica se o pedido tem grade e atualiza
            if (p.IdGrade.Iniciada)
            {
                rf = p.Grade.Atualizar(dbTrans);
                if (rf < 1)
                {

                    dbTrans.Rollback();
                    return false;
                }
            }
            return true;
        }
开发者ID:evandrojr,项目名称:NeoPocket,代码行数:51,代码来源:Pedido.cs


注:本文中的SqlCeTransaction.Rollback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。