Ejemplo n.º 1
0
        public static bool AddCutDown(CutDownInfo cutDown)
        {
            bool flag;

            Globals.EntityCoding(cutDown, true);
            using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection())
            {
                connection.Open();
                DbTransaction dbTran = connection.BeginTransaction();
                try
                {
                    CutDownDao dao       = new CutDownDao();
                    int        cutDownId = dao.AddCutDown(cutDown, dbTran);
                    if (cutDownId <= 0)
                    {
                        dbTran.Rollback();
                        return(false);
                    }
                    dbTran.Commit();
                    flag = true;
                }
                catch (Exception)
                {
                    dbTran.Rollback();
                    flag = false;
                }
                finally
                {
                    connection.Close();
                }
            }
            return(flag);
        }
Ejemplo n.º 2
0
        public static bool UpdateCutDown(CutDownInfo cutDown)
        {
            bool flag;

            Globals.EntityCoding(cutDown, true);
            using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection())
            {
                connection.Open();
                DbTransaction dbTran = connection.BeginTransaction();
                try
                {
                    CutDownDao dao = new CutDownDao();
                    if (!dao.UpdateCutDown(cutDown, dbTran))
                    {
                        dbTran.Rollback();
                        return(false);
                    }

                    /*
                     * if (!dao.DeleteCutDownDetail(cutDown.CutDownId, dbTran))
                     * {
                     *  dbTran.Rollback();
                     *  return false;
                     * }
                     */
                    dbTran.Commit();
                    flag = true;
                }
                catch (Exception)
                {
                    dbTran.Rollback();
                    flag = false;
                }
                finally
                {
                    connection.Close();
                }
            }
            return(flag);
        }