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


C# SqlCeTransaction.Commit方法代码示例

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


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


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